summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2016-07-22 15:09:24 -0400
committerScott Moser <smoser@brickies.net>2016-08-03 16:00:52 -0400
commit72d6adcb2e4cb5911f7809b89835965d4bf04476 (patch)
tree64b33f605847b5b26f67e37882442ea0c3620552 /tools
parenteed7fccdb9e59e5b2cc9e6d94af06f075c6ced67 (diff)
downloadvyos-cloud-init-72d6adcb2e4cb5911f7809b89835965d4bf04476.tar.gz
vyos-cloud-init-72d6adcb2e4cb5911f7809b89835965d4bf04476.zip
Update build tools to work with git
- Update HACKING.rst to include git instructions - update MANIFEST.in and .gitignore to ignore git-related things - replaced tarball generation scripts with git-based script - have the spec files correctly identify themselves as cheetah templates - make brpm work with git
Diffstat (limited to 'tools')
-rwxr-xr-xtools/make-dist-tarball21
-rwxr-xr-xtools/make-tarball54
-rwxr-xr-xtools/read-dependencies22
3 files changed, 41 insertions, 56 deletions
diff --git a/tools/make-dist-tarball b/tools/make-dist-tarball
deleted file mode 100755
index 5b078515..00000000
--- a/tools/make-dist-tarball
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-Usage() {
- cat <<EOF
-Usage: ${0##*/} version
- make a tarball of 'version'
- must be in a bzr directory, and 'version' must be a tag
-
-EOF
-}
-
-topdir="$PWD"
-tag="$1"
-
-[ -n "$tag" ] || { Usage 1>&2 ; exit 1; }
-
-out="${topdir}/cloud-init-${tag}.tar.gz"
-
-bzr export --format=tgz --root="cloud-init-$tag" \
- "--revision=tag:${tag}" "$out" "$topdir" &&
- echo "Wrote ${out}"
diff --git a/tools/make-tarball b/tools/make-tarball
index b7039150..4828a622 100755
--- a/tools/make-tarball
+++ b/tools/make-tarball
@@ -1,39 +1,33 @@
#!/bin/sh
set -e
-find_root() {
- local topd
- if [ -z "${CLOUD_INIT_TOP_D}" ]; then
- topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
- else
- topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
- fi
- [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
- ROOT_DIR="$topd"
-}
+rev=${1:-HEAD}
+revname=$(git describe $rev)
-if ! find_root; then
- echo "Unable to locate 'setup.py' file that should" \
- "exist in the cloud-init root directory." 1>&2
- exit 1;
-fi
-
-REVNO=$(bzr revno "$ROOT_DIR")
+# revname could be 0.7.5 or 0.7.5-NNN-gHASH
+# turn that into 0.7.5 or 0.7.5+NNN.gHASH
+case "$revname" in
+ *-*) revname=$(echo "$revname" | sed -e 's/-/+/' -e 's/-/./')
+esac
-if [ ! -z "$1" ]; then
- ARCHIVE_FN="$1"
-else
- VERSION=$("$ROOT_DIR/tools/read-version")
- ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
-fi
+archive_base="cloud-init-$revname"
-export_uncommitted=""
-if [ "${UNCOMMITTED:-0}" != "0" ]; then
- export_uncommitted="--uncommitted"
+# when building an archiving from HEAD, ensure that there aren't any
+# uncomitted changes in the working directory (because these would not
+# end up in the archive).
+if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then
+ if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then
+ echo "ERROR: There are uncommitted changes in your working directory." >&2
+ exit 1
+ else
+ echo "WARNING: There are uncommitted changes in your working directory." >&2
+ echo " This changes will not be included in the archive." >&2
+ fi
fi
-bzr export ${export_uncommitted} \
- --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \
- "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
+git archive \
+ --format=tar.gz \
+ --prefix="$archive_base/" "$rev" \
+ "--output=$archive_base.tar.gz"
-echo "$ARCHIVE_FN"
+echo "${archive_base}.tar.gz"
diff --git a/tools/read-dependencies b/tools/read-dependencies
index 6a6f3e12..9fc503eb 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -1,8 +1,13 @@
#!/usr/bin/env python
+# You might be tempted to rewrite this as a shell script, but you
+# would be surprised to discover that things like 'egrep' or 'sed' may
+# differ between Linux and *BSD.
+
import os
import re
import sys
+import subprocess
if 'CLOUD_INIT_TOP_D' in os.environ:
topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
@@ -16,14 +21,21 @@ for fname in ("setup.py", "requirements.txt"):
sys.exit(1)
if len(sys.argv) > 1:
- reqfile = sys.argv[1]
+ reqfile = sys.argv[1]
else:
- reqfile = "requirements.txt"
-
+ reqfile = "requirements.txt"
+
with open(os.path.join(topd, reqfile), "r") as fp:
for line in fp:
- if not line.strip() or line.startswith("#"):
+ line = line.strip()
+ if not line or line.startswith("#"):
continue
- sys.stdout.write(re.split("[>=.<]*", line)[0].strip() + "\n")
+
+ # remove pip-style markers
+ dep = line.split(';')[0]
+
+ # remove version requirements
+ dep = re.split("[>=.<]*", dep)[0].strip()
+ print(dep)
sys.exit(0)