Example #1
0
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)
Example #2
0
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)
Example #3
0
	def export_submodules(self, target):
		# Export all sub-modules under target
		cwd = os.getcwd()
		target = os.path.abspath(target)
		for scm in self._submodules():
			tmp = tempfile.NamedTemporaryFile(prefix = '0release-')
			try:
				scm.export(prefix = '.', archive_file = tmp.name, revision = scm.rev)
				os.chdir(os.path.join(target, scm.rel_path))
				unpack_tarball(tmp.name)
			finally:
				tmp.close()
		os.chdir(cwd)
Example #4
0
 def export_submodules(self, target):
     # Export all sub-modules under target
     cwd = os.getcwd()
     target = os.path.abspath(target)
     for scm in self._submodules():
         tmp = tempfile.NamedTemporaryFile(prefix='0release-')
         try:
             scm.export(prefix='.', archive_file=tmp.name, revision=scm.rev)
             os.chdir(os.path.join(target, scm.rel_path))
             unpack_tarball(tmp.name)
         finally:
             tmp.close()
     os.chdir(cwd)
Example #5
0
	export_prefix = archive_name
	if add_toplevel_dir is not None:
		export_prefix += os.sep + add_toplevel_dir

	if status.created_archive and os.path.isfile(archive_file):
		print "Archive already created"
	else:
		support.backup_if_exists(archive_file)
		scm.export(export_prefix, archive_file, status.head_at_release)

		has_submodules = scm.has_submodules()

		if phase_actions['generate-archive'] or has_submodules:
			try:
				support.unpack_tarball(archive_file)
				if has_submodules:
					scm.export_submodules(archive_name)
				run_hooks('generate-archive', cwd = archive_name, env = {'RELEASE_VERSION': status.release_version})
				info("Regenerating archive (may have been modified by generate-archive hooks...")
				support.check_call(['tar', 'cjf', archive_file, archive_name])
			except SafeException:
				scm.reset_hard(scm.get_current_branch())
				fail_candidate()
				raise

		status.created_archive = 'true'
		status.save()

	if need_set_snapshot:
		set_to_snapshot(status.release_version + '-post')
Example #6
0
	export_prefix = archive_name
	if add_toplevel_dir is not None:
		export_prefix += os.sep + add_toplevel_dir

	if status.created_archive and os.path.isfile(archive_file):
		print "Archive already created"
	else:
		support.backup_if_exists(archive_file)
		scm.export(export_prefix, archive_file, status.head_at_release)

		has_submodules = scm.has_submodules()

		if phase_actions['generate-archive'] or has_submodules:
			try:
				support.unpack_tarball(archive_file)
				if has_submodules:
					scm.export_submodules(archive_name)
				run_hooks('generate-archive', cwd = archive_name, env = {'RELEASE_VERSION': status.release_version})
				info("Regenerating archive (may have been modified by generate-archive hooks...")
				support.check_call(['tar', 'cjf', archive_file, archive_name])
			except SafeException:
				scm.reset_hard(scm.get_current_branch())
				fail_candidate()
				raise

		status.created_archive = 'true'
		status.save()

	if need_set_snapshot:
		set_to_snapshot(status.release_version + '-post')