From 34de63a570b7d8acf44e0eee0fc5e0522c283ad7 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 19 Apr 2009 20:46:27 +0100 Subject: [PATCH] Copy generated binary archive to releases directory --- compile.py | 21 +++++++++++++++++---- support.py | 3 +++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/compile.py b/compile.py index c587c1b..fd72a66 100644 --- a/compile.py +++ b/compile.py @@ -1,7 +1,7 @@ # Copyright (C) 2009, Thomas Leonard # See the README file for details, or visit http://0install.net. -import tempfile, shutil, subprocess, os, urlparse +import tempfile, shutil, subprocess, os import ConfigParser from zeroinstall.injector import model @@ -29,7 +29,7 @@ class Compiler: print "Source package, so generating binaries..." - archive_file = os.path.basename(urlparse.urlparse(self.src_impl.download_sources[0].url).path) + archive_file = support.get_archive_basename(self.src_impl) for arch in self.targets: if arch == 'host': @@ -43,6 +43,14 @@ class Compiler: else: print "\nBuilding binary for %s architecture...\n" % arch subprocess.check_call(command + [self.src_feed_name, archive_file, self.archive_dir_public_url, binary_feed + '.new']) + bin_feed = support.load_feed(binary_feed + '.new') + bin_impl = support.get_singleton_impl(bin_feed) + bin_archive_file = support.get_archive_basename(bin_impl) + bin_size = bin_impl.download_sources[0].size + + assert os.path.exists(bin_archive_file), "Compiled binary '%s' not found!" % os.path.abspath(bin_archive_file) + assert os.path.getsize(bin_archive_file) == bin_size, "Compiled binary '%s' has wrong size!" % os.path.abspath(bin_archive_file) + os.rename(binary_feed + '.new', binary_feed) def get_binary_feeds(self): @@ -81,9 +89,14 @@ def build_slave(src_feed, archive_file, archive_dir_public_url, target_feed): subprocess.check_call(['0launch', COMPILE, 'build'], cwd = tmpdir) subprocess.check_call(['0launch', COMPILE, 'publish', '--target-feed', target_feed], cwd = tmpdir) - subprocess.check_call(['0launch', COMPILE, 'clean'], cwd = tmpdir) - # TODO: unit-tests + # TODO: run unit-tests + + feed = support.load_feed(target_feed) + impl = support.get_singleton_impl(feed) + archive_file = support.get_archive_basename(impl) + + shutil.move(archive_file, os.path.join(os.path.dirname(target_feed), archive_file)) except: print "\nLeaving temporary directory %s for inspection...\n" % tmpdir raise diff --git a/support.py b/support.py index 3f6fe18..c97885f 100644 --- a/support.py +++ b/support.py @@ -204,3 +204,6 @@ def load_feed(path): return model.ZeroInstallFeed(qdom.parse(stream), local_path = path) finally: stream.close() + +def get_archive_basename(impl): + return os.path.basename(urlparse.urlparse(impl.download_sources[0].url).path) -- 2.11.4.GIT