diff options
-rwxr-xr-x | packages/bddeb | 109 | ||||
-rwxr-xr-x | packages/brpm | 4 |
2 files changed, 67 insertions, 46 deletions
diff --git a/packages/bddeb b/packages/bddeb index 2a089295..465bd986 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -1,45 +1,66 @@ -#!/bin/sh - -# Ensure we can find the setup.py file which -# should be at the root of the cloud-init tree -PKG_DIR=`pwd` -ROOT="$PKG_DIR/../" -if [ ! -e "$ROOT/setup.py" ]; then - echo "No setup.py found at $ROOT" - exit 1 -fi -echo "Using root directory $ROOT for building your debian package" - -# Ensure tempdir is cleaned and ready to go -TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXXX") -echo "With $TEMP_D as a temporary workspace" -rm -Rf "${TEMP_D}"; mkdir "${TEMP_D}" -set -e - -# Ensure tempdir removed if breaks... -trap "rm -Rf '${TEMP_D}'" EXIT SIGINT SIGTERM - -# Go to the root and start making a package! -cd $ROOT -files=$(bzr ls --versioned) -revno=$(bzr revno) -version=$(tools/read-version) - -mkdir "${TEMP_D}/cloud-init" -otar="$TEMP_D/cloud-init_$version~bzr${revno}.orig.tar.gz" -tar -czf - ${files} > "$otar" -tar -C "${TEMP_D}/cloud-init" -xzf - < "$otar" - -if [ ! -d "${TEMP_D}/cloud-init/debian" ]; then - rsync -a $PKG_DIR/debian.trunk/ "${TEMP_D}/cloud-init/debian" -fi - -sed -i -e "s,VERSION,$version," -e "s,REVNO,bzr$revno," \ - "$TEMP_D/cloud-init/debian/changelog" - -cd "${TEMP_D}/cloud-init" -debuild "$@" -debname="cloud-init_${version}~bzr${revno}-1_all.deb" -mv "../$debname" "$PKG_DIR" -echo "Wrote $debname to $PKG_DIR" +#!/usr/bin/python +import contextlib +import glob +import os +import shutil +import subprocess +import sys +import tempfile + + +@contextlib.contextmanager +def tmpdir(): + t = tempfile.mkdtemp() + try: + yield t + finally: + shutil.rmtree(t) + + +def join(*paths): + p = os.path.join(*paths) + return os.path.abspath(p) + + +def tiny_p(cmd): + # Darn python 2.6 doesn't have check_output (argggg) + info("Running %s" % (cmd)) + sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, stdin=None) + (out, err) = sp.communicate() + if sp.returncode not in [0]: + raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" + % (cmd, sp.returncode, out, err)) + return (out, err) + + +def info(msg): + print("INFO: %s" % (msg)) + + +def warn(msg): + print("WARNING: %s" % (msg)) + + + +def main(): + + with tmpdir() as td: + info("Using %s as a temporary workspace" % (td)) + (stdout, _stderr) = tiny_p(['bzr', 'revno']) + revno = stdout.strip() + + + + cmd = [sys.executable, join(os.pardir, 'tools', 'read-version')] + (stdout, _stderr) = tiny_p(cmd) + version = stdout.strip() + + + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/packages/brpm b/packages/brpm index 241f08fd..febbfb5e 100755 --- a/packages/brpm +++ b/packages/brpm @@ -145,7 +145,7 @@ def main(): # Archive the code (revno, version, archive_fn) = archive_code() real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn)) - shutil.copy(archive_fn, real_archive_fn) + shutil.move(archive_fn, real_archive_fn) info("Archived code to %s" % (real_archive_fn)) # Form the spec file to be used @@ -175,7 +175,7 @@ def main(): for fn in globs: n = os.path.basename(fn) tgt_fn = os.path.join(os.getcwd(), n) - util.copy(fn, tgt_fn) + shutil.move(fn, tgt_fn) info("Copied %s to %s" % (n, tgt_fn)) return 0 |