Browse Source

Update MKit to version v0.0.9

Alois Mahdal 8 years ago
parent
commit
157847710c
5 changed files with 64 additions and 46 deletions
  1. 13
    12
      utils/mkit/include/build.sh
  2. 24
    7
      utils/mkit/include/mkit.sh
  3. 24
    17
      utils/mkit/include/release.sh
  4. 1
    1
      utils/mkit/make
  5. 2
    9
      utils/mkit/mkit.mk

+ 13
- 12
utils/mkit/include/build.sh View File

92
     #       rpmstuff, hence -f hack for gzip
92
     #       rpmstuff, hence -f hack for gzip
93
     #
93
     #
94
     local version=$(get_version)
94
     local version=$(get_version)
95
-    local dirname=$MKIT_PKGNAME-$version
95
+    local dirname=$MKIT_PROJ_PKGNAME-$version
96
     mkdir -p "$dirname"
96
     mkdir -p "$dirname"
97
     ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
97
     ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
98
-    sed -i -e "s/^VERSION = .*/VERSION = $version/" "$dirname/config.mk"
98
+    update_version "$version" "$dirname/mkit.ini"
99
     tar -cf "$dirname.tar" "$dirname"
99
     tar -cf "$dirname.tar" "$dirname"
100
     gzip -f "$dirname.tar"      # see above FIXME
100
     gzip -f "$dirname.tar"      # see above FIXME
101
     mkdir -p "$MKIT_LOCAL"
101
     mkdir -p "$MKIT_LOCAL"
107
     #
107
     #
108
     # Build specfile
108
     # Build specfile
109
     #
109
     #
110
-    local specname="$(ini 1value ENV:PKGNAME).spec"
110
+    local specname="$MKIT_PROJ_PKGNAME.spec"
111
     local specsrc="$(ini 1value "rpmstuff:spec_skel")"
111
     local specsrc="$(ini 1value "rpmstuff:spec_skel")"
112
     test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
112
     test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
113
     test -f "$specsrc" || die "specfile template not found: $specsrc"
113
     test -f "$specsrc" || die "specfile template not found: $specsrc"
156
                 debug_var varname varvalue
156
                 debug_var varname varvalue
157
             done
157
             done
158
     done
158
     done
159
-    echo "s|__CODENAME__|$CODENAME|;"     >> "$script"
160
-    echo "s|__VERSION__|$(get_version)|;" >> "$script"
159
+    echo "s|__MKIT_PROJ_CODENAME__|$(ini 1value project:codename)|;" >> "$script"
160
+    echo "s|__MKIT_PROJ_TAGLINE__|$(ini 1value project:tagline)|;" >> "$script"
161
+    echo "s|__MKIT_PROJ_VERSION__|$(get_version)|;" >> "$script"
161
     perl -wp "$script" || die "expand_variables failed"
162
     perl -wp "$script" || die "expand_variables failed"
162
     rm "$script"
163
     rm "$script"
163
 }
164
 }
169
     # Build version string from available info using following
170
     # Build version string from available info using following
170
     # logic:
171
     # logic:
171
     #
172
     #
172
-    #  1. use VERSION (from config.mk)
173
+    #  1. use project.version (from mkit.ini)
173
     #  2. if we are in git, override the version with last tag
174
     #  2. if we are in git, override the version with last tag
174
-    #  3. if set, add PRERELEASE (from config.mk) as pre-release ID
175
+    #  3. if set, add project:prerl (from mkit.ini) as pre-release ID
175
     #     (afer dash)
176
     #     (afer dash)
176
     #  4. if we are at a later commit than the last tag, add branch
177
     #  4. if we are at a later commit than the last tag, add branch
177
     #     name and commit sha1 to build metadata (after plus sign)
178
     #     name and commit sha1 to build metadata (after plus sign)
183
     # Examples:
184
     # Examples:
184
     #
185
     #
185
     #     myprog v1.0.7                         # all clear
186
     #     myprog v1.0.7                         # all clear
186
-    #     myprog v1.0.7-alpha                   # PRERELEASE="alpha"
187
+    #     myprog v1.0.7-alpha                   # mkit.ini: project:prerl="alpha"
187
     #     myprog v1.0.7-alpha+g1aef811.master   # ^^ + some commits after
188
     #     myprog v1.0.7-alpha+g1aef811.master   # ^^ + some commits after
188
     #     myprog v1.0.7-alpha+gf14fc4f.api2     # ^^ + on a feature branch
189
     #     myprog v1.0.7-alpha+gf14fc4f.api2     # ^^ + on a feature branch
189
     #     myprog v1.0.7-alpha+gf14fc4f.api2.dirty  # ^^ + tree edited
190
     #     myprog v1.0.7-alpha+gf14fc4f.api2.dirty  # ^^ + tree edited
204
     # meta-data is to *identify* the code, and provide safe path back
205
     # meta-data is to *identify* the code, and provide safe path back
205
     # to tree; commit refs are already perfect for that.
206
     # to tree; commit refs are already perfect for that.
206
     #
207
     #
207
-    # FIXME:  Using PRERELEASE for release IDs may not be compatible with
208
+    # FIXME:  Using project:prerl for release IDs may not be compatible with
208
     #         release strategy implemented in release.sh
209
     #         release strategy implemented in release.sh
209
     #
210
     #
210
-    local version=$VERSION
211
-    local prerl=$PRERELEASE
212
-    grep ":" <<<"$prerl" && warn "colon in PRERELEASE may corrupt version data: $prerl"
211
+    local version=$(ini 1value project:version)
212
+    local prerl=$(ini 1value project:prerl)
213
+    grep ":" <<<"$prerl" && warn "colon in project:prerl may corrupt version data: $prerl"
213
     if git rev-parse HEAD >&/dev/null;
214
     if git rev-parse HEAD >&/dev/null;
214
     then    # we are in git repo... so we can get smart
215
     then    # we are in git repo... so we can get smart
215
         local latest_tag=$(
216
         local latest_tag=$(

+ 24
- 7
utils/mkit/include/mkit.sh View File

32
 
32
 
33
 MKIT_INI=${MKIT_INI:-mkit.ini}
33
 MKIT_INI=${MKIT_INI:-mkit.ini}
34
 MKIT_INI_EXPAND=2
34
 MKIT_INI_EXPAND=2
35
-MKIT_PKGNAME=$(ini 1value "ENV:PKGNAME")
36
-MKIT_PROJNAME=$(ini 1value "ENV:PROJNAME")
35
+MKIT_PROJ_NAME=$(ini 1value "project:name")
36
+MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
37
 MKIT_DEFAULT_MODE="644"
37
 MKIT_DEFAULT_MODE="644"
38
 
38
 
39
 mkit_init() {
39
 mkit_init() {
40
     #
40
     #
41
     # Do basic initialization
41
     # Do basic initialization
42
     #
42
     #
43
-    # Check for ini file, load variables from config.mk
43
+    # Check for ini file and some variables
44
     #
44
     #
45
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
45
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
46
-    tmp=$(mktemp)
47
-    sed -e 's/ = /=/' < config.mk > "$tmp"
48
-    . "$tmp"
49
-    rm -f "$tmp"
50
     test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
46
     test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
51
      || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
47
      || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
52
 }
48
 }
66
     echo "$@" >&2
62
     echo "$@" >&2
67
 }
63
 }
68
 
64
 
65
+update_version() {
66
+    #
67
+    # Change project.version in mkit.ini at path $2 to version $1
68
+    #
69
+    local version="$1"
70
+    local inifile="$2"
71
+    local tmp=$(mktemp -t mkit.update_version.XXXXXXXX)
72
+    <"$inifile" perl -e '
73
+        my $hit = 0;
74
+        my $done = 0;
75
+        foreach (<STDIN>) {
76
+            if      ($done) { print; next; }
77
+            elsif   (m/\[project\]/) { $hit++; print; next; }
78
+            elsif   (m/\[/) { $hit = 0; print; next; }
79
+            elsif   ($hit) { s/\bversion\b *=.*/version = $ARGV[0]/ and $done++; print; }
80
+            else { print; next; }
81
+        }
82
+    ' "$version" >"$tmp" || die "failed to update version in mkit.ini"
83
+    mv "$tmp" "$inifile"
84
+}
85
+
69
 route() {
86
 route() {
70
     #
87
     #
71
     # Call correct function based on $1
88
     # Call correct function based on $1

+ 24
- 17
utils/mkit/include/release.sh View File

12
              || die "cannot do this outside git repo"
12
              || die "cannot do this outside git repo"
13
             ;;
13
             ;;
14
         norelbr)
14
         norelbr)
15
+            local relsrc=$(ini 1value project:relsrc)
15
             __git_info curbranch \
16
             __git_info curbranch \
16
-              | grep -qFx "$RELSRC" \
17
-             || die "you are not on RELSRC branch: $RELSRC"
17
+              | grep -qFx "$relsrc" \
18
+             || die "you are not on release source branch: $relsrc"
18
             ;;
19
             ;;
19
         dirty)
20
         dirty)
20
             git diff --shortstat 2>/dev/null \
21
             git diff --shortstat 2>/dev/null \
28
             ;;
29
             ;;
29
         nobump)
30
         nobump)
30
             git diff-tree --no-commit-id --name-only -r HEAD \
31
             git diff-tree --no-commit-id --name-only -r HEAD \
31
-              | grep -qFx config.mk \
32
-             || die "last change must be version bump in config.mk"
32
+              | grep -qFx mkit.ini \
33
+             || die "last change must be version bump in mkit.ini"
33
             ;;
34
             ;;
34
         wip)
35
         wip)
35
             __git_info reldiff \
36
             __git_info reldiff \
40
             x=$(__ver_info nextver_g)
41
             x=$(__ver_info nextver_g)
41
             __ver_info currver_c \
42
             __ver_info currver_c \
42
               | grep -qFx "$x" \
43
               | grep -qFx "$x" \
43
-             || die "new version not in config.mk: $x"
44
+             || die "new version not in mkit.ini: $x"
44
             ;;
45
             ;;
45
     esac
46
     esac
46
 }
47
 }
53
     case "$info" in
54
     case "$info" in
54
         lasttag)    git tag | grep ^v | sort -V | tail -n1  ;;
55
         lasttag)    git tag | grep ^v | sort -V | tail -n1  ;;
55
         curbranch)  git rev-parse --abbrev-ref HEAD         ;;
56
         curbranch)  git rev-parse --abbrev-ref HEAD         ;;
56
-        reldiff)    git log --oneline "$(__git_info lasttag)..HEAD" ;;
57
+        reldiff)    git log --oneline "$(__git_info lasttag)..HEAD" --name-only ;;
57
     esac
58
     esac
58
 }
59
 }
59
 
60
 
65
     case "$info" in
66
     case "$info" in
66
         lastver_g)  __git_info lasttag | sed s/^v// ;;
67
         lastver_g)  __git_info lasttag | sed s/^v// ;;
67
         nextver_g)  __make_ver "$level" "$(__ver_info lastver_g)" ;;
68
         nextver_g)  __make_ver "$level" "$(__ver_info lastver_g)" ;;
68
-        currver_c)  grep -m 1 -w VERSION config.mk \
69
-                     | sed 's/ *= */=/' | cut -d = -f 2 | xargs echo ;;
69
+        currver_c)  ini 1value project:version ;;
70
         nextver_c)  __make_ver "$level" "$(__ver_info currver_c)" ;;
70
         nextver_c)  __make_ver "$level" "$(__ver_info currver_c)" ;;
71
     esac
71
     esac
72
 }
72
 }
94
     # Span release routines: make a signed tag, check branch
94
     # Span release routines: make a signed tag, check branch
95
     # and update release branch
95
     # and update release branch
96
     #
96
     #
97
-    # FIXME: Using PRERELEASE as build.sh:get_version() does may not be
97
+    # FIXME: Using project:prerl as build.sh:get_version() does may not be
98
     #        compatible with this release strategy
98
     #        compatible with this release strategy
99
     #
99
     #
100
     local level=$1
100
     local level=$1
112
     set -e
112
     set -e
113
     debug_var newtag
113
     debug_var newtag
114
     $MKIT_DRY && return
114
     $MKIT_DRY && return
115
-    git tag -m "$MKIT_PROJNAME $newtag - $CODENAME" "$newtag"
116
-    git branch -f "$RELDST" "$newtag"
115
+    git tag -m "$MKIT_PROJ_NAME $newtag - $CODENAME" "$newtag"
116
+    git branch -f "$(ini 1value project:reldst)" "$newtag"
117
 }
117
 }
118
 
118
 
119
 __git_msg_vbump() {
119
 __git_msg_vbump() {
120
     echo "Bump version"
120
     echo "Bump version"
121
     echo ""
121
     echo ""
122
-    __git_info reldiff | sed 's/^/ *  /'
122
+    echo "Overview of changes:"
123
+    echo ""
124
+    __git_info reldiff \
125
+      | sed '
126
+            s/^[a-f0-9]\{7\} / *  &/; t PATHS
127
+            s/^/        /
128
+            :PATHS
129
+        '
123
 }
130
 }
124
 
131
 
125
 __vbump() {
132
 __vbump() {
126
     local level="$1"
133
     local level="$1"
127
-    local lastver   # current from config.mk
134
+    local lastver   # current from mkit.ini
128
     local nextver   # after the bump
135
     local nextver   # after the bump
129
     __die_if nogit
136
     __die_if nogit
130
     __die_if norelbr
137
     __die_if norelbr
133
     nextver=$(__ver_info nextver_c)
140
     nextver=$(__ver_info nextver_c)
134
     debug_var lastver nextver
141
     debug_var lastver nextver
135
     $MKIT_DRY && return
142
     $MKIT_DRY && return
136
-    sed -i "s/$lastver/$nextver/" config.mk \
137
-      || die "failed to update config.mk"
138
-    git add config.mk \
139
-      || die "failed to add config.mk to the index"
143
+    update_version "$nextver" mkit.ini \
144
+      || die "failed to update version in mkit.ini"
145
+    git add mkit.ini \
146
+      || die "failed to add mkit.ini to the index"
140
     git commit -e -m "$(__git_msg_vbump)"
147
     git commit -e -m "$(__git_msg_vbump)"
141
 }
148
 }
142
 
149
 

+ 1
- 1
utils/mkit/make View File

6
     echo "$@" && exit 9
6
     echo "$@" && exit 9
7
 }
7
 }
8
 
8
 
9
-export MKIT_VERSION=0.0.8
9
+export MKIT_VERSION=0.0.9
10
 
10
 
11
 export MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
11
 export MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
12
 export MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
12
 export MKIT_LOCAL=${MKIT_LOCAL:-.mkit}

+ 2
- 9
utils/mkit/mkit.mk View File

3
 
3
 
4
 export MKIT_DIR
4
 export MKIT_DIR
5
 
5
 
6
-all: options build
7
-
8
-options:
9
-	@echo build options:
10
-	@echo "VERSION  = ${VERSION}"
11
-	@echo "PRERELEASE = ${PRERELEASE}"
12
-	@echo "DESTDIR   = ${DESTDIR}"
13
-	@echo "PREFIX   = ${PREFIX}"
6
+all: build
14
 
7
 
15
 build:
8
 build:
16
 	@$(MKIT_DIR)/make build
9
 	@$(MKIT_DIR)/make build
51
 vbump_z:
44
 vbump_z:
52
 	@$(MKIT_DIR)/make vbump_z
45
 	@$(MKIT_DIR)/make vbump_z
53
 
46
 
54
-.PHONY: all options clean dist rpmstuff install uninstall release_x release_y release_z vbump_x vbump_y vbump_z
47
+.PHONY: all clean dist rpmstuff install uninstall release_x release_y release_z vbump_x vbump_y vbump_z