diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-06 17:29:09 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-06 17:29:09 -0700 |
commit | c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0 (patch) | |
tree | 032389ae7e0e7ffb1541086a9c60731492825e06 /tools | |
parent | b2a21ed1dc682a262d55a4202c6b9606496d211f (diff) | |
download | vyos-cloud-init-c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0.tar.gz vyos-cloud-init-c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0.zip |
Reworking these to look attempt to find the right parent directory, as well
as adjustments due to sysvinit rename.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/make-dist-tarball | 25 | ||||
-rwxr-xr-x | tools/make-tarball | 33 | ||||
-rwxr-xr-x | tools/read-dependencies | 75 | ||||
-rwxr-xr-x | tools/read-version | 85 |
4 files changed, 109 insertions, 109 deletions
diff --git a/tools/make-dist-tarball b/tools/make-dist-tarball new file mode 100755 index 00000000..622283bd --- /dev/null +++ b/tools/make-dist-tarball @@ -0,0 +1,25 @@ +#!/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; } + +tmpd=$(mktemp -d ); +trap "rm -Rf '${tmpd}'" 0 + +out=${topdir}/cloud-init-${tag}.tar.gz + +cd ${tmpd} && + bzr branch -r "tag:${tag}" "${topdir}" ./cloud-init-${tag} && + tar czf "${out}" cloud-init-${tag}/ --exclude cloud-init-${tag}/.bzr && + echo "Wrote ${out}" diff --git a/tools/make-tarball b/tools/make-tarball new file mode 100755 index 00000000..7fce5e28 --- /dev/null +++ b/tools/make-tarball @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +ROOT_DIR="" +if [ -e "setup.py" ] +then + ROOT_DIR="$PWD" +elif [ -e "../setup.py" ] +then + ROOT_DIR="$PWD/../" +else + echo "Unable to locate 'setup.py' file that should" \ + "exist in the cloud-init root directory." + exit 1 +fi + +if [ ! -z "$1" ] +then + ARCHIVE_FN="$1" +else + REVNO=$(bzr revno $ROOT_DIR) + VERSION=$($ROOT_DIR/tools/read-version) + ARCHIVE_FN="$PWD/cloud-init-$REVNO-$VERSION.tar.gz" +fi + +FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive) +echo "$FILES" | tar czf $ARCHIVE_FN \ + -C "$ROOT_DIR" \ + --no-recursion --files-from - + +echo "$ARCHIVE_FN" + diff --git a/tools/read-dependencies b/tools/read-dependencies index 72e1e095..3aa6e286 100755 --- a/tools/read-dependencies +++ b/tools/read-dependencies @@ -1,45 +1,30 @@ -#!/usr/bin/python -# vi: ts=4 expandtab - -import os -import sys -import re - - -def parse_requires(fn): - requires = [] - with open(fn, 'r') as fh: - lines = fh.read().splitlines() - for line in lines: - line = line.strip() - if not line or line[0] == '#': - continue - else: - requires.append(line) - return requires - - -def find_requires(args): - p_files = [] - if args: - p_files.append(args[0]) - p_files.append(os.path.join(os.pardir, "Requires")) - p_files.append(os.path.join(os.getcwd(), 'Requires')) - found = None - for fn in p_files: - if os.path.isfile(fn): - found = fn - break - return found - - -if __name__ == '__main__': - run_args = sys.argv[1:] - fn = find_requires(run_args) - if not fn: - sys.stderr.write("'Requires' file not found!\n") - sys.exit(1) - else: - deps = parse_requires(fn) - for entry in deps: - print entry +#!/bin/sh + +set -e + +if [ -e "setup.py" ] +then + ROOT_DIR="$PWD" +elif [ -e "../setup.py" ] +then + ROOT_DIR="$PWD/../" +else + echo "Unable to locate 'setup.py' file that should" \ + "exist in the cloud-init root directory." + exit 1 +fi + +REQUIRES="$ROOT_DIR/Requires" + +if [ ! -e "$REQUIRES" ] +then + echo "Unable to find 'Requires' file located at $REQUIRES" + exit 1 +fi + +# Filter out comments and empty liens +DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$') +echo "$DEPS" | sort -d -f + + + diff --git a/tools/read-version b/tools/read-version index e6167a2c..690666b5 100755 --- a/tools/read-version +++ b/tools/read-version @@ -1,70 +1,27 @@ -#!/usr/bin/python -# vi: ts=4 expandtab +#!/bin/sh -import os -import sys -import re +set -e -from distutils import version as ver +if [ -e "setup.py" ] +then + ROOT_DIR="$PWD" +elif [ -e "../setup.py" ] +then + ROOT_DIR="$PWD/../" +else + echo "Unable to locate 'setup.py' file that should" \ + "exist in the cloud-init root directory." + exit 1 +fi -possible_topdir = os.path.normpath(os.path.join(os.path.abspath( - sys.argv[0]), os.pardir, os.pardir)) -if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")): - sys.path.insert(0, possible_topdir) +CHNG_LOG="$ROOT_DIR/ChangeLog" -from cloudinit import version as cver +if [ ! -e "$CHNG_LOG" ] +then + echo "Unable to find 'ChangeLog' file located at $CHNG_LOG" + exit 1 +fi -def parse_versions(fn): - with open(fn, 'r') as fh: - lines = fh.read().splitlines() - versions = [] - for line in lines: - line = line.strip() - if line.startswith("-") or not line: - continue - if not re.match(r"[\d]", line): - continue - line = line.strip(":") - if (re.match(r"^[\d+]\.[\d+]\.[\d+]$", line) or - re.match(r"^[\d+]\.[\d+]$", line)): - versions.append(line) - return versions +VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1) +echo $VERSION -def find_changelog(args): - p_files = [] - if args: - p_files.append(args[0]) - p_files.append(os.path.join(os.pardir, "ChangeLog")) - p_files.append(os.path.join(os.getcwd(), 'ChangeLog')) - found = None - for fn in p_files: - if os.path.isfile(fn): - found = fn - break - return found - - -if __name__ == '__main__': - run_args = sys.argv[1:] - fn = find_changelog(run_args) - if not fn: - sys.stderr.write("'ChangeLog' file not found!\n") - sys.exit(1) - else: - versions = parse_versions(fn) - if not versions: - sys.stderr.write("No versions found in %s!\n" % (fn)) - sys.exit(1) - else: - # Check that the code version is the same - # as the version we found! - ch_ver = versions[0].strip() - code_ver = cver.version() - ch_ver_obj = ver.StrictVersion(ch_ver) - if ch_ver_obj != code_ver: - sys.stderr.write(("Code version %s does not match" - " changelog version %s\n") % - (code_ver, ch_ver_obj)) - sys.exit(1) - sys.stdout.write(ch_ver) - sys.exit(0) |