summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-08-05 15:51:34 -0400
committerScott Moser <smoser@brickies.net>2016-08-05 16:53:53 -0400
commit42bed116b411eb25ebd8368b2b4ed6c56ffd85e7 (patch)
tree60af1c21adda46878ccf9a0c6ab1b3640fa61a4a
parent10f82bd474c5bc91b330beccd883da06b0014a99 (diff)
downloadvyos-cloud-init-42bed116b411eb25ebd8368b2b4ed6c56ffd85e7.tar.gz
vyos-cloud-init-42bed116b411eb25ebd8368b2b4ed6c56ffd85e7.zip
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.
-rw-r--r--Makefile19
-rw-r--r--cloudinit/version.py9
-rwxr-xr-xpackages/debian/rules.in2
-rwxr-xr-xsetup.py4
-rwxr-xr-xtools/make-tarball8
-rwxr-xr-xtools/read-version26
6 files changed, 34 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 32c50aee..5d35dcc0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,20 @@
CWD=$(shell pwd)
-PYVER ?= 3
+PYVER ?= $(shell for p in python3 python2; do \
+ out=$(which $$p 2>&1) && echo $$p && exit; done; \
+ exit 1)
noseopts ?= -v
YAML_FILES=$(shell find cloudinit bin tests tools -name "*.yaml" -type f )
YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f )
-CHANGELOG_VERSION=$(shell $(CWD)/tools/read-version)
-CODE_VERSION=$(shell python -c "from cloudinit import version; print version.version_string()")
-
PIP_INSTALL := pip install
-ifeq ($(PYVER),3)
+ifeq ($(PYVER),python3)
pyflakes = pyflakes3
unittests = unittest3
yaml = yaml
else
-ifeq ($(PYVER),2)
+ifeq ($(PYVER),python2)
pyflakes = pyflakes
unittests = unittest
else
@@ -28,6 +27,10 @@ ifeq ($(distro),)
distro = redhat
endif
+READ_VERSION=$(shell $(PYVER) $(CWD)/tools/read-version)
+CODE_VERSION=$(shell $(PYVER) -c "from cloudinit import version; print(version.version_string())")
+
+
all: check
check: check_version pep8 $(pyflakes) test $(yaml)
@@ -58,8 +61,8 @@ pip-test-requirements:
test: $(unittests)
check_version:
- @if [ "$(CHANGELOG_VERSION)" != "$(CODE_VERSION)" ]; then \
- echo "Error: ChangeLog version $(CHANGELOG_VERSION)" \
+ @if [ "$(READ_VERSION)" != "$(CODE_VERSION)" ]; then \
+ echo "Error: read-version version $(READ_VERSION)" \
"not equal to code version $(CODE_VERSION)"; exit 2; \
else true; fi
diff --git a/cloudinit/version.py b/cloudinit/version.py
index 01785eb8..aa8ccd7e 100644
--- a/cloudinit/version.py
+++ b/cloudinit/version.py
@@ -17,16 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__VERSION__ = "0.7.6"
-__EXPORT_VERSION__ = "@@EXPORT_VERSION@@"
def version_string():
- if not __EXPORT_VERSION__.startswith("@@"):
- return __EXPORT_VERSION__
return __VERSION__
-
-
-def full_version_string():
- if __EXPORT_VERSION__.startswith("@@"):
- raise ValueError("No full version available")
- return __EXPORT_VERSION__
diff --git a/packages/debian/rules.in b/packages/debian/rules.in
index cf2dd405..9b004357 100755
--- a/packages/debian/rules.in
+++ b/packages/debian/rules.in
@@ -14,7 +14,7 @@ override_dh_install:
override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
- http_proxy= make PYVER=${pyver} check
+ http_proxy= make PYVER=python${pyver} check
else
@echo check disabled by DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS)
endif
diff --git a/setup.py b/setup.py
index 0af576a9..4abbb67e 100755
--- a/setup.py
+++ b/setup.py
@@ -116,13 +116,13 @@ def in_virtualenv():
def get_version():
- cmd = ['tools/read-version']
+ cmd = [sys.executable, 'tools/read-version']
(ver, _e) = tiny_p(cmd)
return str(ver).strip()
def read_requires():
- cmd = ['tools/read-dependencies']
+ cmd = [sys.executable, 'tools/read-dependencies']
(deps, _e) = tiny_p(cmd)
return str(deps).splitlines()
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