예제 #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)
예제 #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)
예제 #3
0
파일: release.py 프로젝트: talex5/0release
	def release_without_0repo(archive_file, new_impls_feed):
		assert options.master_feed_file

		if not options.archive_dir_public_url:
			raise SafeException("Archive directory public URL is not set! Edit configuration and try again.")

		if status.updated_master_feed:
			print "Already added to master feed. Not changing."
		else:
			publish_opts = {}
			if os.path.exists(options.master_feed_file):
				# Check we haven't already released this version
				master = support.load_feed(os.path.realpath(options.master_feed_file))
				existing_releases = [impl for impl in master.implementations.values() if impl.get_version() == status.release_version]
				if len(existing_releases):
					raise SafeException("Master feed %s already contains an implementation with version number %s!" % (options.master_feed_file, status.release_version))

				previous_release = get_previous_release(status.release_version)
				previous_testing_releases = [impl for impl in master.implementations.values() if impl.get_version() == previous_release
													     and impl.upstream_stability == model.stability_levels["testing"]]
				if previous_testing_releases:
					print "The previous release, version %s, is still marked as 'testing'. Set to stable?" % previous_release
					if support.get_choice(['Yes', 'No']) == 'Yes':
						publish_opts['select_version'] = previous_release
						publish_opts['set_stability'] = "stable"

			support.publish(options.master_feed_file, local = new_impls_feed, xmlsign = True, key = options.key, **publish_opts)

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

		# Copy files...
		uploads = [os.path.basename(archive_file)]
		for b in compiler.get_binary_feeds():
			binary_feed = support.load_feed(b)
			impl, = binary_feed.implementations.values()
			uploads.append(os.path.basename(impl.download_sources[0].url))

		upload_archives(options, status, uploads)

		feed_base = os.path.dirname(list(local_feed.feed_for)[0])
		feed_files = [options.master_feed_file]
		print "Upload %s into %s" % (', '.join(feed_files), feed_base)
		cmd = options.master_feed_upload_command.strip()
		if cmd:
			support.show_and_run(cmd, feed_files)
		else:
			print "NOTE: No feed upload command set => you'll have to upload them yourself!"
예제 #4
0
	def release_without_0repo(archive_file, new_impls_feed):
		assert options.master_feed_file

		if not options.archive_dir_public_url:
			raise SafeException("Archive directory public URL is not set! Edit configuration and try again.")

		if status.updated_master_feed:
			print "Already added to master feed. Not changing."
		else:
			publish_opts = {}
			if os.path.exists(options.master_feed_file):
				# Check we haven't already released this version
				master = support.load_feed(os.path.realpath(options.master_feed_file))
				existing_releases = [impl for impl in master.implementations.values() if impl.get_version() == status.release_version]
				if len(existing_releases):
					raise SafeException("Master feed %s already contains an implementation with version number %s!" % (options.master_feed_file, status.release_version))

				previous_release = get_previous_release(status.release_version)
				previous_testing_releases = [impl for impl in master.implementations.values() if impl.get_version() == previous_release
													     and impl.upstream_stability == model.stability_levels["testing"]]
				if previous_testing_releases:
					print "The previous release, version %s, is still marked as 'testing'. Set to stable?" % previous_release
					if support.get_choice(['Yes', 'No']) == 'Yes':
						publish_opts['select_version'] = previous_release
						publish_opts['set_stability'] = "stable"

			support.publish(options.master_feed_file, local = new_impls_feed, xmlsign = True, key = options.key, **publish_opts)

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

		# Copy files...
		uploads = [os.path.basename(archive_file)]
		for b in compiler.get_binary_feeds():
			binary_feed = support.load_feed(b)
			impl, = binary_feed.implementations.values()
			uploads.append(os.path.basename(impl.download_sources[0].url))

		upload_archives(options, status, uploads)

		feed_base = os.path.dirname(list(local_feed.feed_for)[0])
		feed_files = [options.master_feed_file]
		print "Upload %s into %s" % (', '.join(feed_files), feed_base)
		cmd = options.master_feed_upload_command.strip()
		if cmd:
			support.show_and_run(cmd, feed_files)
		else:
			print "NOTE: No feed upload command set => you'll have to upload them yourself!"
예제 #5
0
    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)
예제 #6
0
    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 = support.get_archive_url(
            options, release_version, '')

        self.config = ConfigParser.RawConfigParser()

        # Start with a default configuration
        self.config.add_section('global')
        self.config.set('global', 'builders', 'host')

        self.config.add_section('builder-host')
        #self.config.set('builder-host', 'build', '0launch --not-before 0.10 http://0install.net/2007/interfaces/0release.xml --build-slave "$@"')
        self.config.set('builder-host', 'build', '')

        self.src_impl = support.get_singleton_impl(self.src_feed)
        if self.src_impl.arch and self.src_impl.arch.endswith('-src'):
            path = basedir.load_first_config('0install.net', '0release',
                                             'builders.conf')
            if path:
                info("Loading configuration file '%s'", path)
                self.config.read(path)
            else:
                info(
                    "No builders.conf configuration; will build a binary for this host only"
                )

            if options.builders is not None:
                builders = options.builders
            else:
                builders = self.config.get('global', 'builders').strip()
            if builders:
                self.targets = [x.strip() for x in builders.split(',')]
                info("%d build targets configured: %s", len(self.targets),
                     self.targets)
            else:
                self.targets = []
                info("No builders set; no binaries will be built")
        else:
            self.targets = []
예제 #7
0
	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)
예제 #8
0
	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 = support.get_archive_url(options, release_version, '')

		self.config = ConfigParser.RawConfigParser()

		# Start with a default configuration
		self.config.add_section('global')
		self.config.set('global', 'builders', 'host')

		self.config.add_section('builder-host')
		#self.config.set('builder-host', 'build', '0launch --not-before 0.10 http://0install.net/2007/interfaces/0release.xml --build-slave "$@"')
		self.config.set('builder-host', 'build', '')

		self.src_impl = support.get_singleton_impl(self.src_feed)
		if self.src_impl.arch and self.src_impl.arch.endswith('-src'):
			path = basedir.load_first_config('0install.net', '0release', 'builders.conf')
			if path:
				info("Loading configuration file '%s'", path)
				self.config.read(path)
			else:
				info("No builders.conf configuration; will build a binary for this host only")

			if options.builders is not None:
				builders = options.builders
			else:
				builders = self.config.get('global', 'builders').strip()
			if builders:
				self.targets = [x.strip() for x in builders.split(',')]
				info("%d build targets configured: %s", len(self.targets), self.targets)
			else:
				self.targets = []
				info("No builders set; no binaries will be built")
		else:
			self.targets = []
예제 #9
0
파일: release.py 프로젝트: talex5/0release
		status.created_archive = 'true'
		status.save()

	if need_set_snapshot:
		set_to_snapshot(status.release_version + '-post')
		# Revert back to the original revision, so that any fixes the user makes
		# will get applied before the tag
		scm.reset_hard(scm.get_current_branch())

	#backup_if_exists(archive_name)
	support.unpack_tarball(archive_file)

	extracted_feed_path = os.path.abspath(os.path.join(export_prefix, local_iface_rel_root_path))
	assert os.path.isfile(extracted_feed_path), "Local feed not in archive! Is it under version control?"
	extracted_feed = support.load_feed(extracted_feed_path)
	extracted_impl = support.get_singleton_impl(extracted_feed)

	if extracted_impl.main:
		# Find main executable, relative to the archive root
		abs_main = os.path.join(os.path.dirname(extracted_feed_path), extracted_impl.id, extracted_impl.main)
		main = os.path.relpath(abs_main, archive_name + os.sep)
		if main != extracted_impl.main:
			print "(adjusting main: '%s' for the feed inside the archive, '%s' externally)" % (extracted_impl.main, main)
			# XXX: this is going to fail if the feed uses the new <command> syntax
		if not os.path.exists(abs_main):
			raise SafeException("Main executable '%s' not found after unpacking archive!" % abs_main)
		if main == extracted_impl.main:
			main = None	# Don't change the main attribute
	else:
		main = None
예제 #10
0
		status.created_archive = 'true'
		status.save()

	if need_set_snapshot:
		set_to_snapshot(status.release_version + '-post')
		# Revert back to the original revision, so that any fixes the user makes
		# will get applied before the tag
		scm.reset_hard(scm.get_current_branch())

	#backup_if_exists(archive_name)
	support.unpack_tarball(archive_file)

	extracted_feed_path = os.path.abspath(os.path.join(export_prefix, local_iface_rel_root_path))
	assert os.path.isfile(extracted_feed_path), "Local feed not in archive! Is it under version control?"
	extracted_feed = support.load_feed(extracted_feed_path)
	extracted_impl = support.get_singleton_impl(extracted_feed)

	if extracted_impl.main:
		# Find main executable, relative to the archive root
		abs_main = os.path.join(os.path.dirname(extracted_feed_path), extracted_impl.id, extracted_impl.main)
		main = os.path.relpath(abs_main, archive_name + os.sep)
		if main != extracted_impl.main:
			print "(adjusting main: '%s' for the feed inside the archive, '%s' externally)" % (extracted_impl.main, main)
			# XXX: this is going to fail if the feed uses the new <command> syntax
		if not os.path.exists(abs_main):
			raise SafeException("Main executable '%s' not found after unpacking archive!" % abs_main)
		if main == extracted_impl.main:
			main = None	# Don't change the main attribute
	else:
		main = None