emerge: accept --pkg-format option
authorTomáš Čech <sleep_walker@suse.cz>
Sat, 27 Jul 2013 23:09:39 +0000 (01:09 +0200)
committerZac Medico <zmedico@gentoo.org>
Tue, 30 Jul 2013 05:23:55 +0000 (22:23 -0700)
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 <sleep_walker@suse.cz>
man/emerge.1
man/make.conf.5
pym/_emerge/EbuildBuild.py
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/const.py

index fd4808965e7cc2b919da96f8923ad39aa45ccf4a..ac4651f24781a8242fe0638eeed01225f704c57c 100644 (file)
@@ -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
index ddacf56c97e2d5450f2d171056e2b4c89a118d42..451dba917bd88e012e2f14ead46555f5f5c72f58 100644 (file)
@@ -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.
index 75d906ffbbdfba9d4bf4bbd871ab7ea53ecdf496..e13b1cf3993aba13dfb20093c809325477858dfb 100644 (file)
@@ -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):
                """
index 03074fe216b190a4113be36ebcb155f3c54490e9..4c53c255a01e9cf7412ca33b30d4ce2b3ac492cd 100644 (file)
@@ -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"],
index fe9fb292448b281b2cc9054da1514951d2a7d07b..edf40a5da12c25800eb0e6fba4bb80e578ad2daf 100644 (file)
@@ -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",
index c05b1c09a18e709cab90e504826738cbe6ddb060..1f660a1f2a7cc9c34399287357d25309925a3f55 100644 (file)
@@ -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
 # ===========================================================================