浏览代码

Move version to mkit.ini

Alois Mahdal 9 年前
父节点
当前提交
ebb7510cee
共有 4 个文件被更改,包括 36 次插入20 次删除
  1. 2
    2
      mkit.ini
  2. 3
    3
      src/include/build.sh
  3. 22
    5
      src/include/mkit.sh
  4. 9
    10
      src/include/release.sh

+ 2
- 2
mkit.ini 查看文件

7
 
7
 
8
 [project]
8
 [project]
9
 
9
 
10
-    name = Mkit
10
+    version = 0.0.8
11
+    name = MKit
11
     pkgname = mkit
12
     pkgname = mkit
12
     tagline = simple install helper
13
     tagline = simple install helper
13
     relsrc = master
14
     relsrc = master
18
     group = bin
19
     group = bin
19
     group = rest
20
     group = rest
20
 
21
 
21
-    dist = config.mk
22
     dist = Makefile
22
     dist = Makefile
23
     dist = mkit.ini
23
     dist = mkit.ini
24
     dist = README.md
24
     dist = README.md

+ 3
- 3
src/include/build.sh 查看文件

95
     local dirname=$MKIT_PROJ_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"
170
     # Build version string from available info using following
170
     # Build version string from available info using following
171
     # logic:
171
     # logic:
172
     #
172
     #
173
-    #  1. use VERSION (from config.mk)
173
+    #  1. use project.version (from mkit.ini)
174
     #  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
175
     #  3. if set, add project:prerl (from mkit.ini) as pre-release ID
175
     #  3. if set, add project:prerl (from mkit.ini) as pre-release ID
176
     #     (afer dash)
176
     #     (afer dash)
208
     # FIXME:  Using project:prerl for release IDs may not be compatible with
208
     # FIXME:  Using project:prerl for release IDs may not be compatible with
209
     #         release strategy implemented in release.sh
209
     #         release strategy implemented in release.sh
210
     #
210
     #
211
-    local version=$VERSION
211
+    local version=$(ini 1value project:version)
212
     local prerl=$(ini 1value project:prerl)
212
     local prerl=$(ini 1value project:prerl)
213
     grep ":" <<<"$prerl" && warn "colon in project:prerl may corrupt version data: $prerl"
213
     grep ":" <<<"$prerl" && warn "colon in project:prerl may corrupt version data: $prerl"
214
     if git rev-parse HEAD >&/dev/null;
214
     if git rev-parse HEAD >&/dev/null;

+ 22
- 5
src/include/mkit.sh 查看文件

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

+ 9
- 10
src/include/release.sh 查看文件

29
             ;;
29
             ;;
30
         nobump)
30
         nobump)
31
             git diff-tree --no-commit-id --name-only -r HEAD \
31
             git diff-tree --no-commit-id --name-only -r HEAD \
32
-              | grep -qFx config.mk \
33
-             || 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"
34
             ;;
34
             ;;
35
         wip)
35
         wip)
36
             __git_info reldiff \
36
             __git_info reldiff \
41
             x=$(__ver_info nextver_g)
41
             x=$(__ver_info nextver_g)
42
             __ver_info currver_c \
42
             __ver_info currver_c \
43
               | grep -qFx "$x" \
43
               | grep -qFx "$x" \
44
-             || die "new version not in config.mk: $x"
44
+             || die "new version not in mkit.ini: $x"
45
             ;;
45
             ;;
46
     esac
46
     esac
47
 }
47
 }
66
     case "$info" in
66
     case "$info" in
67
         lastver_g)  __git_info lasttag | sed s/^v// ;;
67
         lastver_g)  __git_info lasttag | sed s/^v// ;;
68
         nextver_g)  __make_ver "$level" "$(__ver_info lastver_g)" ;;
68
         nextver_g)  __make_ver "$level" "$(__ver_info lastver_g)" ;;
69
-        currver_c)  grep -m 1 -w VERSION config.mk \
70
-                     | sed 's/ *= */=/' | cut -d = -f 2 | xargs echo ;;
69
+        currver_c)  ini 1value project:version ;;
71
         nextver_c)  __make_ver "$level" "$(__ver_info currver_c)" ;;
70
         nextver_c)  __make_ver "$level" "$(__ver_info currver_c)" ;;
72
     esac
71
     esac
73
 }
72
 }
132
 
131
 
133
 __vbump() {
132
 __vbump() {
134
     local level="$1"
133
     local level="$1"
135
-    local lastver   # current from config.mk
134
+    local lastver   # current from mkit.ini
136
     local nextver   # after the bump
135
     local nextver   # after the bump
137
     __die_if nogit
136
     __die_if nogit
138
     __die_if norelbr
137
     __die_if norelbr
141
     nextver=$(__ver_info nextver_c)
140
     nextver=$(__ver_info nextver_c)
142
     debug_var lastver nextver
141
     debug_var lastver nextver
143
     $MKIT_DRY && return
142
     $MKIT_DRY && return
144
-    sed -i "s/$lastver/$nextver/" config.mk \
145
-      || die "failed to update config.mk"
146
-    git add config.mk \
147
-      || 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"
148
     git commit -e -m "$(__git_msg_vbump)"
147
     git commit -e -m "$(__git_msg_vbump)"
149
 }
148
 }
150
 
149