include ~bzr in make-tarball output tarball and top level dir

output of 'make-tarball' now is tarball with name formatted as:
    cloud-init-$VERSION~bzr$REVNO.tar.gz
Instead of
    cloud-init-$VERSION-$REVNO.tar.gz

The former is desireable for apt at least as the '~' is understood
to mean less than.

This merges revno 569 and 570 from lp:~harlowja/cloud-init/rework
This commit is contained in:
Joshua Harlow 2012-07-09 15:49:06 -04:00 committed by Scott Moser
parent 324f22e4dd
commit d3060c76ac
3 changed files with 15 additions and 8 deletions

View File

@ -43,6 +43,8 @@ PKG_MP = {
'argparse': 'python-argparse'
}
RPM_BUILD_SUBDIRS = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']
def get_log_header(version):
# Try to find the version in the tags output
@ -88,7 +90,7 @@ def format_change_line(ds, who, comment=None):
return "* %s" % (d)
def generate_spec_contents(args, tmpl_fn):
def generate_spec_contents(args, tmpl_fn, arc_fn):
# Figure out the version and revno
cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
@ -103,8 +105,8 @@ def generate_spec_contents(args, tmpl_fn):
subs = {}
subs['version'] = version
subs['revno'] = revno
subs['release'] = revno
subs['archive_name'] = '%{name}-%{version}-' + revno + '.tar.gz'
subs['release'] = "bzr%s" % (revno)
subs['archive_name'] = arc_fn
subs['bd_requires'] = ['python-devel', 'python-setuptools']
cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]
@ -177,8 +179,13 @@ def main():
root_dir = os.path.expanduser("~/rpmbuild")
if os.path.isdir(root_dir):
shutil.rmtree(root_dir)
arc_dir = util.abs_join(root_dir, 'SOURCES')
util.ensure_dirs([root_dir, arc_dir])
build_dirs = [root_dir, arc_dir]
for dname in RPM_BUILD_SUBDIRS:
build_dirs.append(util.abs_join(root_dir, dname))
build_dirs.sort()
util.ensure_dirs(build_dirs)
# Archive the code
cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]
@ -189,7 +196,7 @@ def main():
# Form the spec file to be used
tmpl_fn = util.abs_join(find_root(), 'packages', 'redhat', 'cloud-init.spec')
contents = generate_spec_contents(args, tmpl_fn)
contents = generate_spec_contents(args, tmpl_fn, os.path.basename(archive_fn))
spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
util.write_file(spec_fn, contents)

View File

@ -54,7 +54,7 @@ need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts.
%prep
%setup -q -n %{name}-%{version}-{{revno}}
%setup -q -n %{name}-%{version}~{{release}}
%build
%{__python} setup.py build

View File

@ -23,13 +23,13 @@ if [ ! -z "$1" ]; then
else
REVNO=$(bzr revno $ROOT_DIR)
VERSION=$($ROOT_DIR/tools/read-version)
ARCHIVE_FN="$PWD/cloud-init-$VERSION-$REVNO.tar.gz"
ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
fi
FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive)
echo "$FILES" | tar czf $ARCHIVE_FN \
-C "$ROOT_DIR" \
--transform "s,^,cloud-init-$VERSION-$REVNO/," \
--transform "s,^,cloud-init-$VERSION~bzr$REVNO/," \
--no-recursion --files-from -
echo "$ARCHIVE_FN"