From 73a972e0cac5d7e5f59a58c11e998793fe2b1a2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tom=C3=A1=C5=A1=20=C4=8Cech?= Date: Sun, 28 Jul 2013 01:09:39 +0200 Subject: [PATCH] emerge: accept --pkg-format option MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Accept --pkg-format option which will override settings of PORTAGE_BINPKG_FORMAT. Currently takes choices of 'tar' (original gentoo binary package), 'rpm' or its combinations. Signed-off-by: Tomáš Čech --- man/emerge.1 | 4 ++++ man/make.conf.5 | 4 ++++ pym/_emerge/EbuildBuild.py | 18 +++++++++++++++--- pym/_emerge/actions.py | 17 +++++++++++++++++ pym/_emerge/main.py | 5 +++++ pym/portage/const.py | 1 + 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index fd4808965..ac4651f24 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -628,6 +628,10 @@ exhaustively apply the entire history of package moves, regardless of whether or not any of the package moves have been previously applied. .TP +.BR \-\-pkg\-format +Specify which binary package format will be created as target. +Possible choices now are tar and rpm or their combinations. +.TP .BR \-\-prefix=DIR Set the \fBEPREFIX\fR environment variable. .TP diff --git a/man/make.conf.5 b/man/make.conf.5 index ddacf56c9..451dba917 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -711,6 +711,10 @@ setting as the base URI. This variable contains options to be passed to the tar command for creation of binary packages. .TP +.B PORTAGE_BINPKG_FORMAT +This variable sets default format used for binary packages. Possible values +are tar and rpm or both. +.TP \fBPORTAGE_BUNZIP2_COMMAND\fR = \fI[bunzip2 command string]\fR This variable should contain a command that is suitable for portage to call for bunzip2 extraction operations. diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index 75d906ffb..e13b1cf39 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -10,6 +10,8 @@ from _emerge.EbuildMerge import EbuildMerge from _emerge.EbuildFetchonly import EbuildFetchonly from _emerge.EbuildBuildDir import EbuildBuildDir from _emerge.MiscFunctionsProcess import MiscFunctionsProcess +from _emerge.TaskSequence import TaskSequence + from portage.util import writemsg import portage from portage import os @@ -306,10 +308,20 @@ class EbuildBuild(CompositeTask): self.scheduler.output(msg, log_path=self.settings.get("PORTAGE_LOG_FILE")) - packager = EbuildBinpkg(background=self.background, pkg=self.pkg, - scheduler=self.scheduler, settings=self.settings) + binpkg_tasks = TaskSequence() + requested_binpkg_formats = self.settings.get("PORTAGE_BINPKG_FORMAT", "tar").split() + for pkg_fmt in portage.const.SUPPORTED_BINPKG_FORMATS: + if pkg_fmt in requested_binpkg_formats: + if pkg_fmt == "rpm": + binpkg_tasks.add(EbuildPhase(background=self.background, + phase="rpm", scheduler=self.scheduler, + settings=self.settings)) + else: + binpkg_tasks.add(EbuildBinpkg(background=self.background, + pkg=self.pkg, scheduler=self.scheduler, + settings=self.settings)) - self._start_task(packager, self._buildpkg_exit) + self._start_task(binpkg_tasks, self._buildpkg_exit) def _buildpkg_exit(self, packager): """ diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 03074fe21..4c53c255a 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -39,6 +39,7 @@ from portage import shutil from portage import eapi_is_supported, _encodings, _unicode_decode from portage.cache.cache_errors import CacheError from portage.const import GLOBAL_CONFIG_PATH, VCS_DIRS, _DEPCLEAN_LIB_CHECK_DEFAULT +from portage.const import SUPPORTED_BINPKG_FORMATS from portage.dbapi.dep_expand import dep_expand from portage.dbapi._expand_new_virt import expand_new_virt from portage.dep import Atom @@ -2933,6 +2934,10 @@ def adjust_config(myopts, settings): settings["NOCOLOR"] = "true" settings.backup_changes("NOCOLOR") + if "--pkg-format" in myopts: + settings["PORTAGE_BINPKG_FORMAT"] = myopts["--pkg-format"] + settings.backup_changes("PORTAGE_BINPKG_FORMAT") + def display_missing_pkg_set(root_config, set_name): msg = [] @@ -3615,6 +3620,18 @@ def run_action(emerge_config): adjust_configs(emerge_config.opts, emerge_config.trees) apply_priorities(emerge_config.target_config.settings) + for fmt in emerge_config.target_config.settings["PORTAGE_BINPKG_FORMAT"].split(): + if not fmt in portage.const.SUPPORTED_BINPKG_FORMATS: + if "--pkg-format" in emerge_config.opts: + problematic="--pkg-format" + else: + problematic="PORTAGE_BINPKG_FORMAT" + + writemsg_level(("emerge: %s is not set correctly. Format " + \ + "'%s' is not supported.\n") % (problematic, fmt), + level=logging.ERROR, noiselevel=-1) + return 1 + if emerge_config.action == 'version': writemsg_stdout(getportageversion( emerge_config.target_config.settings["PORTDIR"], diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index fe9fb2924..edf40a5da 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -546,6 +546,11 @@ def parse_opts(tmpcmdline, silent=False): "action" : "store" }, + "--pkg-format": { + "help" : "format of result binary package", + "action" : "store", + }, + "--quiet": { "shortopt" : "-q", "help" : "reduced or condensed output", diff --git a/pym/portage/const.py b/pym/portage/const.py index c05b1c09a..1f660a1f2 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -172,6 +172,7 @@ if "PORTAGE_OVERRIDE_EPREFIX" in os.environ: VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn") +SUPPORTED_BINPKG_FORMATS = ("tar", "rpm") # =========================================================================== # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT # =========================================================================== -- 2.26.2