1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 | === modified file 'tools/make-dist-tarball'
--- tools/make-dist-tarball 2013-04-09 21:57:41 +0000
+++ tools/make-dist-tarball 2015-09-23 20:29:01 +0000
@@ -16,6 +16,14 @@
out="${topdir}/cloud-init-${tag}.tar.gz"
-bzr export --format=tgz --root="cloud-init-$tag" \
- "--revision=tag:${tag}" "$out" "$topdir" &&
- echo "Wrote ${out}"
+if [ -d "$topdir/.git" ]; then
+ git archive --format=tar.gz --prefix="cloud-init-$tag/" \
+ --output="$out" "$tag" &&
+ echo "Wrote ${out}"
+else
+ bzr export --format=tgz --root="cloud-init-$tag" \
+ "--revision=tag:${tag}" "$out" "$topdir" &&
+ echo "Wrote ${out}"
+fi
+
+# vi: ts=4 expandtab
=== modified file 'tools/make-tarball'
--- tools/make-tarball 2015-09-16 21:52:16 +0000
+++ tools/make-tarball 2015-09-23 21:01:34 +0000
@@ -1,6 +1,36 @@
#!/bin/sh
-set -e
+set -ef
+
+get_version_info() {
+ # for our versions we want to set
+ # VERSION: the current not-yet-released version in X.Y.Z format.
+ # it is shown by ./tools/read-version (or python setup.py --version)
+ # DVERSION: an increasing counter only guaranteed to increase
+ # inside a given VERSION
+ #
+ # then the version of the snapshot is VERSION~(bzr|git)DVERSION
+ # for git, we have a trailing -HASH
+ #
+ # the bzr and git numbers are generally incompatible as bzr counts
+ # from beginning of time and 'git describe' counts only since last tag.
+ #
+ # in dpkg compare the ~gitXXX will sort newer than ~bzrXXX as 'g' is > 'b'
+ local topdir="$1" out="" oifs="$IFS" dver=""
+ out=$(cd "$topdir" && "$topdir/tools/read-version" --dev)
+ set -- $out
+ VERSION="$1"
+ DVERSION="$2"
+ case "$DVERSION" in
+ bzr*)
+ BZR_REVNO=${DVERSION#bzr}
+ VCS="bzr";;
+ git*)
+ GIT_HASH=${DVERSION#*-}
+ VCS="git";;
+ *) echo "bad dver: $DVERSION"; exit 1;;
+ esac
+}
find_root() {
local topd
@@ -19,33 +49,36 @@
exit 1;
fi
-if [ -d "$ROOT_DIR/.git" ]; then
- VERSION=$(cd $ROOT_DIR && python setup.py --version)
- REVPOSTFIX=""
-else
- REVNO=$(bzr revno "$ROOT_DIR")
- REVPOSTFIX="~bzr$REVNO"
- VERSION=$("$ROOT_DIR/tools/read-version")
-fi
+get_version_info "$ROOT_DIR" ||
+ { echo "Failed to get version info from $ROOT_DIR"; exit 1; }
+snapshot_ver="${VERSION}~${DVERSION}"
+dir_pre="cloud-init-${snapshot_ver}"
if [ ! -z "$1" ]; then
- ARCHIVE_FN="$1"
+ if [ "${1#/}" != "$1" ]; then
+ ARCHIVE_FN="$PWD/$ARCHIVE_FN"
+ else
+ ARCHIVE_FN="$ARCHIVE_FN"
+ fi
else
- ARCHIVE_FN="$PWD/cloud-init-${VERSION}${REVPOSTFIX}.tar.gz"
+ ARCHIVE_FN="$PWD/cloud-init-$snapshot_ver.tar.gz"
fi
+ARCHIVE_FN_USER="${1:-${ARCHIVE_FN}}"
-if [ -d "$ROOT_DIR/.git" ]; then
- git_hash=$(cd $ROOT_DIR && git log --pretty=format:'%h' -n 1)
- cd $ROOT_DIR && git archive -o "$ARCHIVE_FN" \
- --prefix="cloud-init-${VERSION}${REVPOSTFIX}/" "$git_hash"
+if [ "$VCS" = "git" ]; then
+ cd "$ROOT_DIR"
+ git archive --format=tar.gz --output="$ARCHIVE_FN" \
+ --prefix="${dir_pre}/" "$GIT_HASH"
else
export_uncommitted=""
if [ "${UNCOMMITTED:-0}" != "0" ]; then
export_uncommitted="--uncommitted"
fi
bzr export ${export_uncommitted} \
- --format=tgz --root="cloud-init-${VERSION}${REVPOSTFIX}" \
- "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
+ --format=tgz --root="${dir_pre}" \
+ "--revision=${BZR_REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
fi
-echo "$ARCHIVE_FN"
+echo "${ARCHIVE_FN_USER}"
+
+# vi: ts=4 expandtab
=== modified file 'tools/read-version'
--- tools/read-version 2014-01-23 20:17:17 +0000
+++ tools/read-version 2015-09-23 20:52:09 +0000
@@ -3,6 +3,11 @@
import os
import re
import sys
+import subprocess
+
+show_dver = False
+if len(sys.argv) > 1 and sys.argv[1] == "--dev":
+ show_dver = True
if 'CLOUD_INIT_TOP_D' in os.environ:
topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
@@ -17,10 +22,27 @@
vermatch = re.compile(r"^[0-9]+[.][0-9]+[.][0-9]+:$")
+version = None
with open(os.path.join(topd, "ChangeLog"), "r") as fp:
for line in fp:
if vermatch.match(line):
- sys.stdout.write(line.strip()[:-1] + "\n")
+ version = line.strip()[:-1]
break
-sys.exit(0)
+if not show_dver:
+ sys.stdout.write(version + "\n")
+ sys.exit(0)
+
+os.chdir(topd)
+if os.path.isdir(".git"):
+ # git describe this is like: 0.7.6-443-g23d4282
+ # where 443 is commits since last tag.
+ describe_out = subprocess.check_output(["git", "describe"]).strip()
+ last_tag, count, ghash = describe_out.split("-")
+ barehash = ghash[1:]
+ dver = "git" + "-".join([count, barehash])
+else:
+ revno_out = subprocess.check_output(["bzr", "revno"]).strip()
+ dver = "bzr" + revno_out
+
+sys.stdout.write("%s %s\n" % (version, dver))
|