From 42bed116b411eb25ebd8368b2b4ed6c56ffd85e7 Mon Sep 17 00:00:00 2001
From: Scott Moser <smoser@brickies.net>
Date: Fri, 5 Aug 2016 15:51:34 -0400
Subject: drop modification of version during make-tarball, tools changes.

Modification of the tarball became problematic, as it meant that
any tool extracting source would find the orig source tarball different.
I found this unusable when trying to use 'gbp buildpackage'.

Other changes here are to better support using python3 or python2
for the build.  Makefile will try to call the right python version
and can be told which python to use.

read-version: by adding 'tiny_p' and avoiding the import of
cloudinit.util, we need less dependencies to run this.
---
 tools/make-tarball |  8 +-------
 tools/read-version | 26 +++++++++++++++++++-------
 2 files changed, 20 insertions(+), 14 deletions(-)

(limited to 'tools')

diff --git a/tools/make-tarball b/tools/make-tarball
index bd7399c1..57358447 100755
--- a/tools/make-tarball
+++ b/tools/make-tarball
@@ -62,11 +62,5 @@ if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then
     fi
 fi
 
-git archive --format=tar --prefix="$archive_base/" "$rev" |
-    ( cd "$TEMP_D" && tar xpf - )
-
-sed -i "s,@@EXPORT_VERSION@@,$version," "$archive_base/cloudinit/version.py"
-
-( cd "$TEMP_D" && tar cpzf - "$archive_base/" ) > "$output"
-
+git archive --format=tar.gz --prefix="$archive_base/" "$rev" > "$output"
 echo "$output"
diff --git a/tools/read-version b/tools/read-version
index e585ab2e..78e34157 100755
--- a/tools/read-version
+++ b/tools/read-version
@@ -2,13 +2,28 @@
 
 import os
 import json
+import subprocess
 import sys
 
 if "avoid-pep8-E402-import-not-top-of-file":
     _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
     sys.path.insert(0, _tdir)
     from cloudinit import version as ci_version
-    from cloudinit import util
+
+
+def tiny_p(cmd, capture=True):
+    # python 2.6 doesn't have check_output
+    stdout = subprocess.PIPE
+    stderr = subprocess.PIPE
+    sp = subprocess.Popen(cmd, stdout=stdout,
+                          stderr=stderr, stdin=None,
+                          universal_newlines=True)
+    (out, err) = sp.communicate()
+    ret = sp.returncode
+    if ret not in [0]:
+        raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" %
+                           (cmd, ret, out, err))
+    return out
 
 
 use_long = '--long' in sys.argv or os.environ.get('CI_RV_LONG')
@@ -31,20 +46,17 @@ if os.path.isdir(os.path.join(_tdir, ".git")):
         flags = ['--tags']
     cmd = ['git', 'describe'] + flags
 
-    version = fix_git_version(util.subp(cmd)[0])
+    version = fix_git_version(tiny_p(cmd))
 
     if not version.startswith(src_version):
         sys.stderr.write("git describe version (%s) differs from "
                          "cloudinit.version (%s)\n" % (version, src_version))
         sys.exit(1)
 
-    version_long = fix_git_version(util.subp(cmd + ["--long"])[0])
+    version_long = fix_git_version(tiny_p(cmd + ["--long"]))
 else:
     version = src_version
-    try:
-        version_long = ci_version.full_version_string()
-    except ValueError:
-        pass
+    version_long = None
 
 # version is X.Y.Z[+xxx.gHASH]
 # version_long is None or X.Y.Z+xxx.gHASH
-- 
cgit v1.2.3