def build_binaries(self): if not self.targets: return print "Source package, so generating binaries..." archive_file = support.get_archive_basename(self.src_impl) for target in self.targets: start = self.get('builder-' + target, 'start', None) command = self.config.get('builder-' + target, 'build') stop = self.get('builder-' + target, 'stop', None) binary_feed = 'binary-' + target + '.xml' if os.path.exists(binary_feed): print "Feed %s already exists; not rebuilding" % binary_feed else: print "\nBuilding binary with builder '%s' ...\n" % target if start: support.show_and_run(start, []) try: args = [ os.path.basename(self.src_feed_name), archive_file, self.archive_dir_public_url, binary_feed + '.new' ] if not command: assert target == 'host', 'Missing build command' support.check_call( [sys.executable, sys.argv[0], '--build-slave'] + args) else: support.show_and_run(command, args) finally: if stop: support.show_and_run(stop, []) 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) portable_rename(binary_feed + '.new', binary_feed)
def build_slave(src_feed, archive_file, archive_dir_public_url, target_feed): try: COMPILE = [os.environ['0COMPILE']] except KeyError: # (build slave has an old 0release) COMPILE = [ '0launch', '--not-before=1.2', 'http://0install.net/2006/interfaces/0compile.xml' ] feed = support.load_feed(src_feed) src_feed = os.path.abspath(src_feed) archive_file = os.path.abspath(archive_file) target_feed = os.path.abspath(target_feed) impl, = feed.implementations.values() tmpdir = tempfile.mkdtemp(prefix='0release-') try: os.chdir(tmpdir) depdir = os.path.join(tmpdir, 'dependencies') os.mkdir(depdir) support.unpack_tarball(archive_file) portable_rename(impl.download_sources[0].extract, os.path.join(depdir, impl.id)) config = ConfigParser.RawConfigParser() config.add_section('compile') config.set('compile', 'download-base-url', archive_dir_public_url) config.set('compile', 'version-modifier', '') config.set('compile', 'interface', src_feed) config.set('compile', 'selections', '') config.set('compile', 'metadir', '0install') stream = open(os.path.join(tmpdir, '0compile.properties'), 'w') try: config.write(stream) finally: stream.close() support.check_call(COMPILE + ['build'], cwd=tmpdir) support.check_call(COMPILE + ['publish', '--target-feed', target_feed], cwd=tmpdir) # 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 else: shutil.rmtree(tmpdir)
def build_slave(src_feed, archive_file, archive_dir_public_url, target_feed): try: COMPILE = [os.environ['0COMPILE']] except KeyError: # (build slave has an old 0release) COMPILE = ['0launch', '--not-before=0.30', 'http://0install.net/2006/interfaces/0compile.xml'] feed = support.load_feed(src_feed) src_feed = os.path.abspath(src_feed) archive_file = os.path.abspath(archive_file) target_feed = os.path.abspath(target_feed) impl, = feed.implementations.values() tmpdir = tempfile.mkdtemp(prefix = '0release-') try: os.chdir(tmpdir) depdir = os.path.join(tmpdir, 'dependencies') os.mkdir(depdir) support.unpack_tarball(archive_file) portable_rename(impl.download_sources[0].extract, os.path.join(depdir, impl.id)) config = ConfigParser.RawConfigParser() config.add_section('compile') config.set('compile', 'download-base-url', archive_dir_public_url) config.set('compile', 'version-modifier', '') config.set('compile', 'interface', src_feed) config.set('compile', 'selections', '') config.set('compile', 'metadir', '0install') stream = open(os.path.join(tmpdir, '0compile.properties'), 'w') try: config.write(stream) finally: stream.close() support.check_call(COMPILE + ['build'], cwd = tmpdir) support.check_call(COMPILE + ['publish', '--target-feed', target_feed], cwd = tmpdir) # 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 else: shutil.rmtree(tmpdir)
def build_binaries(self): if not self.targets: return print "Source package, so generating binaries..." archive_file = support.get_archive_basename(self.src_impl) for target in self.targets: start = self.get('builder-' + target, 'start', None) command = self.config.get('builder-' + target, 'build') stop = self.get('builder-' + target, 'stop', None) binary_feed = 'binary-' + target + '.xml' if os.path.exists(binary_feed): print "Feed %s already exists; not rebuilding" % binary_feed else: print "\nBuilding binary with builder '%s' ...\n" % target if start: support.show_and_run(start, []) try: args = [os.path.basename(self.src_feed_name), archive_file, self.archive_dir_public_url, binary_feed + '.new'] if not command: assert target == 'host', 'Missing build command' support.check_call([sys.executable, sys.argv[0], '--build-slave'] + args) else: support.show_and_run(command, args) finally: if stop: support.show_and_run(stop, []) 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) portable_rename(binary_feed + '.new', binary_feed)