Ubuntu Pastebin

Paste from smoser at Wed, 23 Sep 2015 20:30:05 +0000

Download as text
  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
=== 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 20:24:22 +0000
@@ -1,6 +1,37 @@
 #!/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
+    #
+    # 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"
+    VERSION=$("$topdir/tools/read-version")
+    if [ -d "$topdir/.git" ]; then
+        out=$(cd "$topdir" && git describe)
+        # this is like: 0.7.6-443-g23d4282
+        # where 443 is commits since last tag.
+        IFS="-"; set -- $out; IFS="$oifs"
+        DVERSION="$2-$3"
+        VCS="git"
+        GIT_HASH="${3#g}"
+    else
+        local revno
+        BZR_REVNO=$(bzr revno "$topdir")
+        DVERSION="$BZR_REVNO"
+        VCS="bzr"
+    fi
+}
 
 find_root() {
    local topd
@@ -19,33 +50,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}~${VCS}${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
Download as text