Ver código fonte

Update own dog food to v0.0.7

Alois Mahdal 8 anos atrás
pai
commit
e7d99dbd58

+ 9
- 2
utils/mkit/include/build.sh Ver arquivo

@@ -212,7 +212,14 @@ get_version() {
212 212
     grep ":" <<<"$prerl" && warn "colon in PRERELEASE may corrupt version data: $prerl"
213 213
     if git rev-parse HEAD >&/dev/null;
214 214
     then    # we are in git repo... so we can get smart
215
-        local lasttag=$(git tag | grep ^v | sort -V | tail -n1)
215
+        local latest_tag=$(
216
+            git log --format="%D" \
217
+              | sed 's/,/\n/g' \
218
+              | sed 's/^[[:blank:]]*//; ' \
219
+              | grep -E '^tag: v[[:digit:]]+\.' \
220
+              | cut -d' ' -f2 \
221
+              | head -1
222
+        )
216 223
         if ! git describe --tags --exact-match HEAD >&/dev/null;
217 224
         then    # we are at a later commit than the last tag
218 225
             local sha=g$(git log -1 --pretty=format:%h HEAD)
@@ -223,7 +230,7 @@ get_version() {
223 230
         then    # the tree is "dirty", i.e. has been edited
224 231
             local dirty=dirty
225 232
         fi
226
-        test -n "$lasttag" && version=${lasttag:1}
233
+        test -n "$latest_tag" && version=${latest_tag:1}
227 234
         local suffix=""
228 235
         case "$commit:$dirty" in
229 236
             :)       suffix=""                ;;

+ 6
- 26
utils/mkit/include/deploy.sh Ver arquivo

@@ -14,14 +14,6 @@ _maybe() {
14 14
     esac
15 15
 }
16 16
 
17
-check_env() {
18
-    #
19
-    # Check that critical variables are set correctly
20
-    #
21
-    test -n "$destdir" || die "could not determine DESTDIR"
22
-    test -d "$destdir" || die "DESTDIR: no such directory: $destdir"
23
-}
24
-
25 17
 deploy_item() {
26 18
     #
27 19
     # Deploy item and make it look like wanted
@@ -52,24 +44,16 @@ deploy_item() {
52 44
     then
53 45
         _maybe mkdir -vp "$(dirname "$dst")"
54 46
         _maybe cp -Tvr "$src" "$dst"
55
-        find "$dst" -type f -print0 | xargs -0 chmod -c "$mode"
47
+        find "$dst" -type f \
48
+          | while read chmod_item;
49
+            do
50
+                _maybe chmod "$mode" "$chmod_item"
51
+            done
56 52
     else
57 53
         _maybe install -DTvm "$mode" "$src" "$dst"
58 54
     fi
59 55
 }
60 56
 
61
-get_destdir() {
62
-    #
63
-    # Get DESTDIR: first from ENV:DESTDIR, then the default
64
-    #
65
-    {
66
-        ini 1value ENV:DESTDIR | grep . && return
67
-        echo "$MKIT_DEFAULT_DESTDIR"
68
-    } \
69
-      | xargs readlink -m \
70
-      | grep -m 1 .
71
-}
72
-
73 57
 get_dst() {
74 58
     #
75 59
     # Find out target path for src file $2 of group $1
@@ -86,7 +70,7 @@ get_root() {
86 70
     local grp="$1"
87 71
     local root=$(ini 1value "roots:$grp")
88 72
     test -n "$root" || die "missing in config.ini: roots:$grp"
89
-    echo "$destdir/$root"
73
+    echo "$(ini 1value ENV:DESTDIR)$root"
90 74
 }
91 75
 
92 76
 install() {
@@ -94,8 +78,6 @@ install() {
94 78
     # Install product
95 79
     #
96 80
     local dst group mode src
97
-    local destdir=$(get_destdir)
98
-    check_env
99 81
     ini values "lists:group" \
100 82
       | while read group;
101 83
         do
@@ -116,8 +98,6 @@ uninstall() {
116 98
     # Uninstall product
117 99
     #
118 100
     local dst group src
119
-    local destdir=$(get_destdir)
120
-    check_env
121 101
     ini values "lists:group" \
122 102
       | while read group;
123 103
         do

+ 1
- 0
utils/mkit/include/ini.sh Ver arquivo

@@ -8,6 +8,7 @@ ini() {
8 8
     local arg=$2
9 9
     local fn
10 10
     local limit=_ini_cat
11
+    debug_var op arg
11 12
     case $op in
12 13
         lskeys) fn=_ini_lskeys   ;;
13 14
         sec)    fn=_ini_grepsec  ;;

+ 22
- 22
utils/mkit/include/mkit.sh Ver arquivo

@@ -5,27 +5,6 @@
5 5
 . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
6 6
 . "$MKIT_DIR/include/ini.sh"    || die "cannot import ini.sh"
7 7
 
8
-MKIT_INI=${MKIT_INI:-mkit.ini}
9
-MKIT_INI_EXPAND=2
10
-MKIT_PKGNAME=$(ini 1value "ENV:PKGNAME")
11
-MKIT_PROJNAME=$(ini 1value "ENV:PROJNAME")
12
-MKIT_DEFAULT_MODE="644"
13
-
14
-mkit_init() {
15
-    #
16
-    # Do basic initialization
17
-    #
18
-    # Check for ini file, load variables from config.mk
19
-    #
20
-    test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
21
-    tmp=$(mktemp)
22
-    sed -e 's/ = /=/' < config.mk > "$tmp"
23
-    . "$tmp"
24
-    rm -f "$tmp"
25
-    test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
26
-     || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
27
-}
28
-
29 8
 debug() {
30 9
     #
31 10
     # Print debug message
@@ -51,6 +30,27 @@ debug_var() {
51 30
     done
52 31
 }
53 32
 
33
+MKIT_INI=${MKIT_INI:-mkit.ini}
34
+MKIT_INI_EXPAND=2
35
+MKIT_PKGNAME=$(ini 1value "ENV:PKGNAME")
36
+MKIT_PROJNAME=$(ini 1value "ENV:PROJNAME")
37
+MKIT_DEFAULT_MODE="644"
38
+
39
+mkit_init() {
40
+    #
41
+    # Do basic initialization
42
+    #
43
+    # Check for ini file, load variables from config.mk
44
+    #
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")" \
51
+     || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
52
+}
53
+
54 54
 die() {
55 55
     #
56 56
     # Exit with message and non-zero exit status
@@ -71,7 +71,7 @@ route() {
71 71
     # Call correct function based on $1
72 72
     #
73 73
     case $1 in
74
-        build|build_manpages|clean|dist|rpmstuff|install|release_?|uninstall)
74
+        build|build_manpages|clean|dist|rpmstuff|install|release_?|uninstall|vbump_?)
75 75
             $1
76 76
             ;;
77 77
         *)

+ 115
- 30
utils/mkit/include/release.sh Ver arquivo

@@ -1,5 +1,75 @@
1 1
 #!/bin/bash
2 2
 
3
+__die_if() {
4
+    #
5
+    # Die if blocking condition $1 is detected
6
+    #
7
+    local condition="$1"
8
+    local x
9
+    case "$condition" in
10
+        nogit)
11
+            git rev-parse HEAD >&/dev/null\
12
+             || die "cannot do this outside git repo"
13
+            ;;
14
+        norelbr)
15
+            __git_info curbranch \
16
+              | grep -qFx "$RELSRC" \
17
+             || die "you are not on RELSRC branch: $RELSRC"
18
+            ;;
19
+        dirty)
20
+            git diff --shortstat 2>/dev/null \
21
+              | grep -q . \
22
+             && die "tree is dirty: $dirt"
23
+            ;;
24
+        novertag)
25
+            __git_info lasttag \
26
+              | grep -q . \
27
+             || die "cannot find last tag"
28
+            ;;
29
+        nobump)
30
+            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"
33
+            ;;
34
+        wip)
35
+            __git_info reldiff \
36
+              | grep '^....... WIP ' \
37
+             && die "WIP commit since $(__git_info lasttag)"
38
+            ;;
39
+        old_c)
40
+            x=$(__ver_info nextver_g)
41
+            __ver_info currver_c \
42
+              | grep -qFx "$x" config.mk \
43
+             || die "new version not in config.mk: $x"
44
+            ;;
45
+    esac
46
+}
47
+
48
+__git_info() {
49
+    #
50
+    # Get git info $1
51
+    #
52
+    local info="$1"
53
+    case "$info" in
54
+        lasttag)    git tag | grep ^v | sort -V | tail -n1  ;;
55
+        curbranch)  git rev-parse --abbrev-ref HEAD         ;;
56
+        reldiff)    git log --oneline "$(__git_info lasttag)..HEAD" ;;
57
+    esac
58
+}
59
+
60
+__ver_info() {
61
+    #
62
+    # Get git info $1
63
+    #
64
+    local info="$1"
65
+    case "$info" in
66
+        lastver_g)  __git_info lasttag | sed s/v$// ;;
67
+        nextver_g)  __make_ver "$level" "$(__ver_info lastver_g)" ;;
68
+        currver_c)  grep -m 1 -w VERSION config.mk | cut -d = -f 2 | xargs echo ;;
69
+        nextver_c)  __make_ver "$level" "$(__ver_info currver_c)" ;;
70
+    esac
71
+}
72
+
3 73
 __make_ver() {
4 74
     local level=$1
5 75
     local old=$2
@@ -27,43 +97,58 @@ __release() {
27 97
     #        compatible with this release strategy
28 98
     #
29 99
     local level=$1
30
-    git rev-parse HEAD >&/dev/null || die "cannot release outside git repo"
31
-    local lastfile=$(git diff-tree --no-commit-id --name-only -r HEAD)
32
-    local lasttag=$(git tag | grep ^v | sort -V | tail -n1)
33
-    local changelog="$(git log --oneline "$lasttag..HEAD")"
34
-    local curbranch=$(git rev-parse --abbrev-ref HEAD)
35
-    local dirt="$(git diff --shortstat 2>/dev/null)"
100
+    local newtag
36 101
 
37
-    local newver=$(__make_ver "$level" "${lasttag#v}")
38
-    local newtag=v$newver
39
-    local higher=$(echo -e "$oldtag\n$newtag" | sort -V | tail -n1)
102
+    __die_if nogit
103
+    __die_if norelbr
104
+    __die_if dirty
105
+    __die_if novertag
106
+    __die_if nobump
107
+    __die_if wip
108
+    __die_if old_c
40 109
 
41
-    test "$lastfile" = config.mk \
42
-     || die "last change must be version bump in config.mk"
43
-
44
-    test -n "$lasttag" \
45
-     || die "cannot find last tag"
46
-
47
-    test "$newtag" = "$higher" \
48
-     || die "generated tag looks older: $oldtag<$newtag"
49
-
50
-    grep -qw "$newver" config.mk \
51
-     || die "new version not in config.mk: $newver"
110
+    newtag=v$(__ver_info nextver_g)
111
+    set -e
112
+    debug_var newtag
113
+    $MKIT_DRY && return
114
+    git tag -m "$MKIT_PROJNAME $newtag - $CODENAME" "$newtag"
115
+    git branch -f "$RELDST" "$newtag"
116
+}
52 117
 
53
-    grep '^....... WIP ' <<<"$changelog" \
54
-     && die "WIP commit since $lasttag"
118
+__git_msg_vbump() {
119
+    echo "Bump version"
120
+    echo ""
121
+    __git_info reldiff | sed 's/^/ *  '
122
+}
55 123
 
56
-    grep -qw "$curbranch" <<<"$RELSRC" \
57
-     || die "you are not on RELSRC branch: $RELSRC"
124
+__vbump() {
125
+    local level="$1"
126
+    local lastver   # current from config.mk
127
+    local nextver   # after the bump
128
+    __die_if nogit
129
+    __die_if norelbr
130
+    __die_if dirty
131
+    lastver=$(__ver_info currver_c)
132
+    nextver=$(__ver_info nextver_c)
133
+    debug_var lastver nextver
134
+    $MKIT_DRY && return
135
+    sed -i "s/$lastver/$nextver/" config.mk \
136
+      || die "failed to update config.mk"
137
+    git add config.mk \
138
+      || die "failed to add config.mk to the index"
139
+    git commit -e -m "$(__git_msg_vbump)"
140
+}
58 141
 
59
-    test -z "$dirt" \
60
-     || die "tree is dirty: $dirt"
142
+vbump_x() {
143
+    __vbump x
144
+}
61 145
 
62
-    # FIXME: Have user prepare proper message with changelog
146
+vbump_y() {
147
+    __vbump y
148
+}
63 149
 
64
-    set -e
65
-    git tag -m "$MKIT_PROJNAME $newtag - $CODENAME" "$newtag"
66
-    git branch -f "$RELDST" "$newtag"
150
+vbump_z() {
151
+    __vbump z
67 152
 }
68 153
 
69 154
 release_x() {

+ 1
- 2
utils/mkit/make Ver arquivo

@@ -6,12 +6,11 @@ die() {
6 6
     echo "$@" && exit 9
7 7
 }
8 8
 
9
-export MKIT_VERSION=0.0.6+dirty
9
+export MKIT_VERSION=0.0.7
10 10
 
11 11
 export MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
12 12
 export MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
13 13
 export MKIT_DRY=${MKIT_DRY:-false}
14
-export MKIT_DEFAULT_DESTDIR=${MKIT_DEFAULT_DESTDIR:-/}
15 14
 export MKIT_DEBUG=${MKIT_DEBUG:-false}
16 15
 
17 16
 . "$MKIT_DIR/include/mkit.sh" || die "failed to init; check if MKIT_DIR is set properly: $MKIT_DIR"

+ 10
- 1
utils/mkit/mkit.mk Ver arquivo

@@ -42,4 +42,13 @@ release_z:
42 42
 uninstall:
43 43
 	@$(MKIT_DIR)/make uninstall
44 44
 
45
-.PHONY: all options clean dist rpmstuff install uninstall release_x release_y release_z
45
+vbump_x:
46
+	@$(MKIT_DIR)/make vbump_x
47
+
48
+vbump_y:
49
+	@$(MKIT_DIR)/make vbump_y
50
+
51
+vbump_z:
52
+	@$(MKIT_DIR)/make vbump_z
53
+
54
+.PHONY: all options clean dist rpmstuff install uninstall release_x release_y release_z vbump_x vbump_y vbump_z