public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Tomáš Čech" <sleep_walker@suse.cz>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Tomáš Čech" <sleep_walker@suse.cz>
Subject: [gentoo-portage-dev] [PATCH] emerge: accept --pkg-format option
Date: Sun, 28 Jul 2013 01:09:39 +0200	[thread overview]
Message-ID: <1374966579-315-1-git-send-email-sleep_walker@suse.cz> (raw)
In-Reply-To: <51F00550.8070700@gentoo.org>

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                |  4 ++++
 man/make.conf.5             |  4 ++++
 pym/_emerge/EbuildBinpkg.py | 18 +++++++++++-------
 pym/_emerge/EbuildBuild.py  | 12 +++++++++---
 pym/_emerge/actions.py      | 17 +++++++++++++++++
 pym/_emerge/main.py         |  5 +++++
 pym/portage/const.py        |  1 +
 7 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index da6bcba..1571e8a 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -633,6 +633,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 adf32bd..8811513 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -707,6 +707,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/EbuildBinpkg.py b/pym/_emerge/EbuildBinpkg.py
index 34a6aef..145cd31 100644
--- a/pym/_emerge/EbuildBinpkg.py
+++ b/pym/_emerge/EbuildBinpkg.py
@@ -10,22 +10,26 @@ class EbuildBinpkg(CompositeTask):
 	This assumes that src_install() has successfully completed.
 	"""
 	__slots__ = ('pkg', 'settings') + \
-		('_binpkg_tmpfile',)
+		('_binpkg_tmpfile', 'pkg_format')
 
 	def _start(self):
 		pkg = self.pkg
 		root_config = pkg.root_config
 		bintree = root_config.trees["bintree"]
 		bintree.prevent_collision(pkg.cpv)
-		binpkg_tmpfile = os.path.join(bintree.pkgdir,
-			pkg.cpv + ".tbz2." + str(os.getpid()))
-		bintree._ensure_dir(os.path.dirname(binpkg_tmpfile))
+		if self.pkg_format == "rpm":
+			requested_phase = "rpm"
+		else:
+			requested_phase = "package"
+			binpkg_tmpfile = os.path.join(bintree.pkgdir,
+				pkg.cpv + ".tbz2." + str(os.getpid()))
+			bintree._ensure_dir(os.path.dirname(binpkg_tmpfile))
 
-		self._binpkg_tmpfile = binpkg_tmpfile
-		self.settings["PORTAGE_BINPKG_TMPFILE"] = self._binpkg_tmpfile
+			self._binpkg_tmpfile = binpkg_tmpfile
+			self.settings["PORTAGE_BINPKG_TMPFILE"] = self._binpkg_tmpfile
 
 		package_phase = EbuildPhase(background=self.background,
-			phase='package', scheduler=self.scheduler,
+			phase=requested_phase, scheduler=self.scheduler,
 			settings=self.settings)
 
 		self._start_task(package_phase, self._package_phase_exit)
diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
index 75d906f..8755815 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,14 @@ 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:
+				binpkg_tasks.add(EbuildBinpkg(background=self.background, pkg=self.pkg,
+					pkg_format=pkg_fmt, 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 6d5d535..9ba50a0 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -38,6 +38,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
@@ -2909,6 +2910,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 = []
@@ -3591,6 +3596,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 fe9fb29..edf40a5 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 087c0e7..bf22977 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -169,6 +169,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
 # ===========================================================================
-- 
1.8.3.1



  reply	other threads:[~2013-07-27 23:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  6:28 [gentoo-portage-dev] emerge: add support for --pkg-format Tomáš Čech
2013-07-24  6:33 ` [gentoo-portage-dev] [PATCH] emerge: accept --pkg-format option Tomáš Čech
2013-07-24 16:48   ` Zac Medico
2013-07-27 23:09     ` Tomáš Čech [this message]
2013-07-30  5:25       ` Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374966579-315-1-git-send-email-sleep_walker@suse.cz \
    --to=sleep_walker@suse.cz \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox