From 07953faf071b069b2cb896d112a1b9171757ef08 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 18 Mar 2013 18:25:25 +0000 Subject: [PATCH] Expand $RELEASE_VERSION in generated binary feeds too --- compile.py | 5 ++--- release.py | 12 +++--------- support.py | 6 ++++++ tests/testrelease.py | 4 +++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/compile.py b/compile.py index 649cf0d..19d00e0 100644 --- a/compile.py +++ b/compile.py @@ -9,11 +9,10 @@ from zeroinstall.support import basedir import support class Compiler: - def __init__(self, options, src_feed_name): + def __init__(self, options, src_feed_name, release_version): self.src_feed_name = src_feed_name self.src_feed = support.load_feed(src_feed_name) - self.archive_dir_public_url = options.archive_dir_public_url - assert options.archive_dir_public_url + self.archive_dir_public_url = support.get_archive_url(options, release_version, '') self.config = ConfigParser.RawConfigParser() diff --git a/release.py b/release.py index 32a3435..25f9ccf 100644 --- a/release.py +++ b/release.py @@ -27,12 +27,6 @@ def run_unit_tests(local_feed): if exitstatus: raise SafeException("Self-test failed with exit status %d" % exitstatus) -def get_archive_url(options, status, archive): - archive_dir_public_url = options.archive_dir_public_url.replace('$RELEASE_VERSION', status.release_version) - if not archive_dir_public_url.endswith('/'): - archive_dir_public_url += '/' - return archive_dir_public_url + archive - def upload_archives(options, status, uploads): # For each binary or source archive in uploads, ensure it is available # from options.archive_dir_public_url @@ -42,7 +36,7 @@ def upload_archives(options, status, uploads): # from an incoming queue before we can test them. def url(archive): - return get_archive_url(options, status, archive) + return support.get_archive_url(options, status.release_version, archive) # Check that url exists and has the given size def is_uploaded(url, size): @@ -242,7 +236,7 @@ def do_release(local_feed, options): support.publish(target_feed, set_main = main, - archive_url = get_archive_url(options, status, os.path.basename(archive_file)), + archive_url = support.get_archive_url(options, status.release_version, os.path.basename(archive_file)), archive_file = archive_file, archive_extract = archive_name) @@ -490,7 +484,7 @@ def do_release(local_feed, options): print "Wrote source feed as %s" % src_feed_name # If it's a source package, compile the binaries now... - compiler = compile.Compiler(options, os.path.abspath(src_feed_name)) + compiler = compile.Compiler(options, os.path.abspath(src_feed_name), release_version = status.release_version) compiler.build_binaries() previous_release = get_previous_release(status.release_version) diff --git a/support.py b/support.py index 953e042..4c8cbec 100644 --- a/support.py +++ b/support.py @@ -230,3 +230,9 @@ def make_readonly_recursive(path): full = os.path.join(root, d) mode = os.stat(full).st_mode os.chmod(full, mode & 0o555) + +def get_archive_url(options, release_version, archive): + archive_dir_public_url = options.archive_dir_public_url.replace('$RELEASE_VERSION', release_version) + if not archive_dir_public_url.endswith('/'): + archive_dir_public_url += '/' + return archive_dir_public_url + archive diff --git a/tests/testrelease.py b/tests/testrelease.py index 159fba9..542f091 100755 --- a/tests/testrelease.py +++ b/tests/testrelease.py @@ -45,7 +45,7 @@ def make_releases_dir(src_feed = '../hello/HelloWorld.xml', auto_upload = False) assert os.path.isfile('make-release') lines = file('make-release').readlines() - lines[lines.index('ARCHIVE_DIR_PUBLIC_URL=\n')] = 'ARCHIVE_DIR_PUBLIC_URL=http://TESTING/releases\n' + lines[lines.index('ARCHIVE_DIR_PUBLIC_URL=\n')] = 'ARCHIVE_DIR_PUBLIC_URL=http://TESTING/releases/\\$RELEASE_VERSION\n' # Force us to test against this version of 0release for i, line in enumerate(lines): @@ -142,6 +142,8 @@ class TestRelease(unittest.TestCase): assert os.path.basename(src_impl.download_sources[0].url) in archives host_download = host_impl.download_sources[0] + self.assertEqual('http://TESTING/releases/1.1/helloworld-in-c-linux-x86_64-1.1.tar.bz2', + host_download.url) host_archive = os.path.basename(host_download.url) assert host_archive in archives support.check_call(['tar', 'xjf', os.path.join('archives', host_archive)]) -- 2.11.4.GIT