public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2011-12-10  3:23 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2011-12-10  3:23 UTC (permalink / raw
  To: gentoo-commits

commit:     0b32a054ea5e30f127addf7246e0f8dfafbab091
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 03:21:44 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 03:21:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0b32a054

Binpkg: add chpathtool support for prefix

This uses a python-based chpathtool implementation which is intended to
be compatible with the C-based implemenation that the prefix branch
uses.

---
 bin/chpathtool.py     |  182 +++++++++++++++++++++++++++++++++++++++++++++++++
 pym/_emerge/Binpkg.py |   64 ++++++++++++++++--
 2 files changed, 241 insertions(+), 5 deletions(-)

diff --git a/bin/chpathtool.py b/bin/chpathtool.py
new file mode 100755
index 0000000..d0d49cb
--- /dev/null
+++ b/bin/chpathtool.py
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import io
+import optparse
+import os
+import stat
+import sys
+
+CONTENT_ENCODING = "utf_8"
+FS_ENCODING = "utf_8"
+
+try:
+	import magic
+except ImportError:
+	magic = None
+else:
+	try:
+		magic.MIME_TYPE
+	except AttributeError:
+		# magic module seems to be broken
+		magic = None
+
+class IsTextFile(object):
+
+	def __init__(self):
+		if magic is not None:
+			self._call = self._is_text_magic
+			self._m = magic.open(magic.MIME_TYPE)
+			self._m.load()
+		else:
+			self._call = self._is_text_encoding
+			self._encoding = CONTENT_ENCODING
+
+	def __call__(self, filename):
+		"""
+		Returns True if the given file is a text file, and False otherwise.
+		"""
+		return self._call(filename)
+
+	def _is_text_magic(self, filename):
+		mime_type = self._m.file(filename)
+		return mime_type.startswith("text/")
+
+	def _is_text_encoding(self, filename):
+		try:
+			for line in io.open(filename, mode='r', encoding=self._encoding):
+				pass
+		except UnicodeDecodeError:
+			return False
+		return True
+
+def chpath_inplace(filename, is_text_file, old, new):
+	"""
+	Returns True if any modifications were made, and False otherwise.
+	"""
+
+	modified = False
+	orig_stat = os.lstat(filename)
+	try:
+		f = io.open(filename, buffering=0, mode='r+b')
+	except IOError:
+		try:
+			orig_mode = stat.S_IMODE(os.lstat(filename).st_mode)
+		except OSError as e:
+			sys.stderr.write("%s: %s\n" % (e, filename))
+			return
+		temp_mode = 0o200 | orig_mode
+		os.chmod(filename, temp_mode)
+		try:
+			f = io.open(filename, buffering=0, mode='r+b')
+		finally:
+			os.chmod(filename, orig_mode)
+
+	len_old = len(old)
+	len_new = len(new)
+	matched_byte_count = 0
+	while True:
+		in_byte = f.read(1)
+
+		if not in_byte:
+			break
+
+		if in_byte == old[matched_byte_count]:
+			matched_byte_count += 1
+			if matched_byte_count == len_old:
+				modified = True
+				matched_byte_count = 0
+				end_position = f.tell()
+				start_position = end_position - len_old
+				if not is_text_file:
+					# search backwards for leading slashes written by
+					# a previous invocation of this tool
+					num_to_write = len_old
+					f.seek(start_position - 1)
+					while True:
+						if f.read(1) != b'/':
+							break
+						num_to_write += 1
+						f.seek(f.tell() - 2)
+
+					# pad with as many leading slashes as necessary
+					while num_to_write > len_new:
+						f.write(b'/')
+						num_to_write -= 1
+					f.write(new)
+				else:
+					remainder = f.read()
+					f.seek(start_position)
+					f.write(new)
+					if remainder:
+						f.write(remainder)
+						f.truncate()
+						f.seek(start_position + len_new)
+		elif matched_byte_count > 0:
+			# back up an try to start a new match after
+			# the first byte of the previous partial match
+			f.seek(f.tell() - matched_byte_count)
+			matched_byte_count = 0
+
+	f.close()
+	if modified:
+		orig_mtime = orig_stat[stat.ST_MTIME]
+		os.utime(filename, (orig_mtime, orig_mtime))
+	return modified
+
+def chpath_inplace_symlink(filename, st, old, new):
+	target = os.readlink(filename)
+	if target.startswith(old):
+		new_target = new + target[len(old):]
+		os.unlink(filename)
+		os.symlink(new_target, filename)
+		os.lchown(filename, st.st_uid, st.st_gid)
+
+def main(argv):
+
+	usage = "%s [options] <location> <old> <new>" % (os.path.basename(argv[0],))
+	parser = optparse.OptionParser(usage=usage)
+	options, args = parser.parse_args(argv[1:])
+
+	if len(args) != 3:
+		parser.error("3 args required, got %s" % (len(args),))
+
+	location, old, new = args
+
+	is_text_file = IsTextFile()
+
+	if not isinstance(location, bytes):
+		location = location.encode(FS_ENCODING)
+	if not isinstance(old, bytes):
+		old = old.encode(FS_ENCODING)
+	if not isinstance(new, bytes):
+		new = new.encode(FS_ENCODING)
+
+	st = os.lstat(location)
+
+	if stat.S_ISDIR(st.st_mode):
+		for parent, dirs, files in os.walk(location):
+			for filename in files:
+				filename = os.path.join(parent, filename)
+				try:
+					st = os.lstat(filename)
+				except OSError:
+					pass
+				else:
+					if stat.S_ISREG(st.st_mode):
+						chpath_inplace(filename,
+							is_text_file(filename), old, new)
+					elif stat.S_ISLNK(st.st_mode):
+						chpath_inplace_symlink(filename, st, old, new)
+
+	elif stat.S_ISREG(st.st_mode):
+		chpath_inplace(location,
+			is_text_file(location), old, new)
+	elif stat.S_ISLNK(st.st_mode):
+		chpath_inplace_symlink(location, st, old, new)
+
+	return os.EX_OK
+
+if __name__ == "__main__":
+	sys.exit(main(sys.argv))

diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index bc6511e..5a58ad2 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -9,8 +9,9 @@ from _emerge.CompositeTask import CompositeTask
 from _emerge.BinpkgVerifier import BinpkgVerifier
 from _emerge.EbuildMerge import EbuildMerge
 from _emerge.EbuildBuildDir import EbuildBuildDir
+from _emerge.SpawnProcess import SpawnProcess
 from portage.eapi import eapi_exports_replace_vars
-from portage.util import writemsg
+from portage.util import ensure_dirs, writemsg
 import portage
 from portage import os
 from portage import _encodings
@@ -18,6 +19,7 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 import io
 import logging
+import shutil
 from portage.output import colorize
 
 class Binpkg(CompositeTask):
@@ -25,7 +27,8 @@ class Binpkg(CompositeTask):
 	__slots__ = ("find_blockers",
 		"ldpath_mtimes", "logger", "opts",
 		"pkg", "pkg_count", "prefetcher", "settings", "world_atom") + \
-		("_bintree", "_build_dir", "_ebuild_path", "_fetched_pkg",
+		("_bintree", "_build_dir", "_build_prefix",
+		"_ebuild_path", "_fetched_pkg",
 		"_image_dir", "_infloc", "_pkg_path", "_tree", "_verify")
 
 	def _writemsg_level(self, msg, level=0, noiselevel=0):
@@ -83,9 +86,9 @@ class Binpkg(CompositeTask):
 
 			waiting_msg = ("Fetching '%s' " + \
 				"in the background. " + \
-				"To view fetch progress, run `tail -f " + \
+				"To view fetch progress, run `tail -f %s" + \
 				"/var/log/emerge-fetch.log` in another " + \
-				"terminal.") % prefetcher.pkg_path
+				"terminal.") % (prefetcher.pkg_path, settings["EPREFIX"])
 			msg_prefix = colorize("GOOD", " * ")
 			from textwrap import wrap
 			waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
@@ -299,10 +302,61 @@ class Binpkg(CompositeTask):
 		self._start_task(extractor, self._extractor_exit)
 
 	def _extractor_exit(self, extractor):
-		if self._final_exit(extractor) != os.EX_OK:
+		if self._default_exit(extractor) != os.EX_OK:
 			self._unlock_builddir()
 			self._writemsg_level("!!! Error Extracting '%s'\n" % \
 				self._pkg_path, noiselevel=-1, level=logging.ERROR)
+			self.wait()
+			return
+
+		try:
+			with io.open(_unicode_encode(os.path.join(self._infloc, "EPREFIX"),
+				encoding=_encodings['fs'], errors='strict'), mode='r',
+				encoding=_encodings['repo.content'], errors='replace') as f:
+				self._build_prefix = f.read().rstrip('\n')
+		except IOError:
+			self._build_prefix = ""
+
+		if self._build_prefix == self.settings["EPREFIX"]:
+			self._current_task = None
+			self.returncode = os.EX_OK
+			self.wait()
+			return
+
+		chpathtool = SpawnProcess(
+			args=[portage._python_interpreter,
+			os.path.join(self.settings["PORTAGE_BIN_PATH"], "chpathtool.py"),
+			self.settings["D"], self._build_prefix, self.settings["EPREFIX"]],
+			background=self.background, env=self.settings.environ(), 
+			scheduler=self.scheduler,
+			logfile=self.settings.get('PORTAGE_LOG_FILE'))
+		self._writemsg_level(">>> Adjusting Prefix to %s\n" % self.settings["EPREFIX"])
+		self._start_task(chpathtool, self._chpathtool_exit)
+
+	def _chpathtool_exit(self, chpathtool):
+		if self._final_exit(chpathtool) != os.EX_OK:
+			self._unlock_builddir()
+			self._writemsg_level("!!! Error Adjusting Prefix to %s" %
+				(self.settings["EPREFIX"],),
+				noiselevel=-1, level=logging.ERROR)
+			self.wait()
+			return
+
+		# We want to install in "our" prefix, not the binary one
+		with io.open(_unicode_encode(os.path.join(self._infloc, "EPREFIX"),
+			encoding=_encodings['fs'], errors='strict'), mode='w',
+			encoding=_encodings['repo.content'], errors='strict') as f:
+			f.write(self.settings["EPREFIX"] + "\n")
+
+		# Move the files to the correct location for merge.
+		image_tmp_dir = os.path.join(
+			self.settings["PORTAGE_BUILDDIR"], "image_tmp")
+		os.rename(os.path.join(self.settings["D"],
+			self._build_prefix.lstrip(os.sep)), image_tmp_dir)
+		shutil.rmtree(self._image_dir)
+		ensure_dirs(os.path.dirname(self.settings["ED"]))
+		os.rename(image_tmp_dir, self.settings["ED"])
+
 		self.wait()
 
 	def _unlock_builddir(self):



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2018-04-30 19:28 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2018-04-30 19:28 UTC (permalink / raw
  To: gentoo-commits

commit:     b313716f09b039957864fda3bd1e1f2b54c85586
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 30 19:15:59 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Apr 30 19:25:37 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b313716f

AbstractPollTask: change timeout units to seconds

 bin/ebuild-ipc.py               | 6 +++---
 pym/_emerge/AbstractPollTask.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index c2773cb6a..6d0cdbef9 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -104,7 +104,7 @@ class EbuildIpc(object):
 
 	# Timeout for each individual communication attempt (we retry
 	# as long as the daemon process appears to be alive).
-	_COMMUNICATE_RETRY_TIMEOUT_MS = 15000
+	_COMMUNICATE_RETRY_TIMEOUT = 15 # seconds
 
 	def __init__(self):
 		self.fifo_dir = os.environ['PORTAGE_BUILDDIR']
@@ -161,7 +161,7 @@ class EbuildIpc(object):
 		eof = fifo_writer.poll() is not None
 
 		while not eof:
-			fifo_writer._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT_MS)
+			fifo_writer._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT)
 
 			eof = fifo_writer.poll() is not None
 			if eof:
@@ -187,7 +187,7 @@ class EbuildIpc(object):
 		eof = pipe_reader.poll() is not None
 
 		while not eof:
-			pipe_reader._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT_MS)
+			pipe_reader._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT)
 			eof = pipe_reader.poll() is not None
 			if not eof:
 				if self._daemon_is_alive():

diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index 6cccb27d9..dff4b3efd 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -113,7 +113,7 @@ class AbstractPollTask(AsynchronousTask):
 		tasks = [self.async_wait()]
 		if timeout is not None:
 			tasks.append(asyncio.ensure_future(
-				asyncio.sleep(timeout / 1000, loop=loop), loop=loop))
+				asyncio.sleep(timeout, loop=loop), loop=loop))
 		try:
 			loop.run_until_complete(asyncio.ensure_future(
 				asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED,


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2018-03-28  6:52 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2018-03-28  6:52 UTC (permalink / raw
  To: gentoo-commits

commit:     9a41593d4245c4b4b867015b5e3d91d8ef71feb2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 25 06:29:24 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 28 06:03:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9a41593d

EbuildPhase: add PackagePhase class for PKG_INSTALL_MASK

The PackagePhase class will be a convient place to invoke
a python implementation of PKG_INSTALL_MASK.

 bin/misc-functions.sh       | 23 ++++---------
 pym/_emerge/EbuildPhase.py  |  7 ++++
 pym/_emerge/PackagePhase.py | 80 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 17 deletions(-)

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index ee65450f2..3c01280c7 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -503,29 +503,20 @@ preinst_selinux_labels() {
 }
 
 __dyn_package() {
-	local PROOT
 
 	if ! ___eapi_has_prefix_variables; then
-		local EPREFIX= ED=${D}
+		local EPREFIX=
 	fi
 
 	# Make sure $PWD is not ${D} so that we don't leave gmon.out files
 	# in there in case any tools were built with -pg in CFLAGS.
-
 	cd "${T}" || die
 
 	if [[ -n ${PKG_INSTALL_MASK} ]] ; then
-		PROOT=${T}/packaging/
-		# make a temporary copy of ${D} so that any modifications we do that
-		# are binpkg specific, do not influence the actual installed image.
-		rm -rf "${PROOT}" || die "failed removing stale package tree"
-		cp -pPR $(cp --help | grep -qs -e-l && echo -l) \
-			"${D}" "${PROOT}" \
-			|| die "failed creating packaging tree"
-
-		install_mask "${PROOT%/}${EPREFIX}/" "${PKG_INSTALL_MASK}"
-	else
-		PROOT=${D}
+		# The caller makes ${D} refer to a temporary copy in this
+		# case, so that this does not mask files from the normal
+		# install image.
+		install_mask "${D%/}${EPREFIX}/" "${PKG_INSTALL_MASK}"
 	fi
 
 	local tar_options=""
@@ -539,7 +530,7 @@ __dyn_package() {
 	mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed"
 	[ -z "${PORTAGE_COMPRESSION_COMMAND}" ] && \
         die "PORTAGE_COMPRESSION_COMMAND is unset"
-	tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${PROOT}" . | \
+	tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${D}" . | \
 		$PORTAGE_COMPRESSION_COMMAND -c > "$PORTAGE_BINPKG_TMPFILE"
 	assert "failed to pack binary package: '$PORTAGE_BINPKG_TMPFILE'"
 	PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
@@ -561,8 +552,6 @@ __dyn_package() {
 		echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
 	__vecho ">>> Done."
 
-	# cleanup our temp tree
-	[[ -n ${PKG_INSTALL_MASK} ]] && rm -rf "${PROOT}"
 	cd "${PORTAGE_BUILDDIR}"
 	>> "$PORTAGE_BUILDDIR/.packaged" || \
 		die "Failed to create $PORTAGE_BUILDDIR/.packaged"

diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py
index d3fada622..3174cac1a 100644
--- a/pym/_emerge/EbuildPhase.py
+++ b/pym/_emerge/EbuildPhase.py
@@ -11,6 +11,7 @@ from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
 from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
 from _emerge.EbuildProcess import EbuildProcess
 from _emerge.CompositeTask import CompositeTask
+from _emerge.PackagePhase import PackagePhase
 from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir,
 		_prepare_fake_distdir, _prepare_fake_filesdir)
 from portage.util import writemsg
@@ -169,6 +170,12 @@ class EbuildPhase(CompositeTask):
 		return logfile
 
 	def _start_ebuild(self):
+		if self.phase == "package":
+			self._start_task(PackagePhase(actionmap=self.actionmap,
+				background=self.background, fd_pipes=self.fd_pipes,
+				logfile=self._get_log_path(), scheduler=self.scheduler,
+				settings=self.settings), self._ebuild_exit)
+			return
 
 		if self.phase == "unpack":
 			alist = self.settings.configdict["pkg"].get("A", "").split()

diff --git a/pym/_emerge/PackagePhase.py b/pym/_emerge/PackagePhase.py
new file mode 100644
index 000000000..ed8256ee0
--- /dev/null
+++ b/pym/_emerge/PackagePhase.py
@@ -0,0 +1,80 @@
+# Copyright 2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import io
+
+from _emerge.CompositeTask import CompositeTask
+from _emerge.EbuildProcess import EbuildProcess
+from _emerge.SpawnProcess import SpawnProcess
+
+import portage
+from portage import os
+from portage import _encodings
+from portage import _unicode_encode
+
+
+class PackagePhase(CompositeTask):
+	"""
+	Invokes the package phase and handles PKG_INSTALL_MASK.
+	"""
+
+	__slots__ = ("actionmap", "fd_pipes", "logfile", "settings",
+		"_pkg_install_mask", "_proot")
+
+	_shell_binary = portage.const.BASH_BINARY
+
+	def _start(self):
+		try:
+			with io.open(_unicode_encode(
+				os.path.join(self.settings["PORTAGE_BUILDDIR"],
+				"build-info", "PKG_INSTALL_MASK"),
+				encoding=_encodings['fs'], errors='strict'),
+				mode='r', encoding=_encodings['repo.content'],
+				errors='replace') as f:
+				self._pkg_install_mask = f.read()
+		except EnvironmentError:
+			self._pkg_install_mask = None
+		if self._pkg_install_mask:
+			self._proot = os.path.join(self.settings['T'], 'packaging')
+			self._start_task(SpawnProcess(
+				args=[self._shell_binary, '-e', '-c', ('rm -rf {PROOT}; '
+				'cp -pPR $(cp --help | grep -q -- "^[[:space:]]*-l," && echo -l)'
+				' "${{D}}" {PROOT}').format(PROOT=portage._shell_quote(self._proot))],
+				background=self.background, env=self.settings.environ(),
+				scheduler=self.scheduler, logfile=self.logfile),
+				self._copy_proot_exit)
+		else:
+			self._proot = self.settings['D']
+			self._start_package_phase()
+
+	def _copy_proot_exit(self, proc):
+		if self._default_exit(proc) != os.EX_OK:
+			self.wait()
+		else:
+			self._start_package_phase()
+
+	def _start_package_phase(self):
+		ebuild_process = EbuildProcess(actionmap=self.actionmap,
+			background=self.background, fd_pipes=self.fd_pipes,
+			logfile=self.logfile, phase="package",
+			scheduler=self.scheduler, settings=self.settings)
+
+		if self._pkg_install_mask:
+			d_orig = self.settings["D"]
+			try:
+				self.settings["D"] = self._proot
+				self._start_task(ebuild_process, self._pkg_install_mask_cleanup)
+			finally:
+				self.settings["D"] = d_orig
+		else:
+			self._start_task(ebuild_process, self._default_final_exit)
+
+	def _pkg_install_mask_cleanup(self, proc):
+		if self._default_exit(proc) != os.EX_OK:
+			self.wait()
+		else:
+			self._start_task(SpawnProcess(
+				args=['rm', '-rf', self._proot],
+				background=self.background, env=self.settings.environ(),
+				scheduler=self.scheduler, logfile=self.logfile),
+				self._default_final_exit)


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2015-09-28 16:08 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2015-09-28 16:08 UTC (permalink / raw
  To: gentoo-commits

commit:     e6be71af3f67ea274db455e9c24d5f84bd372c39
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 27 23:10:40 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 28 16:01:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e6be71af

AbstractEbuildProcess: remove cgroup with release_agent (bug 561264)

Use the cgroup release_agent hook to remove cgroups automatically
upon release.

X-Gentoo-bug: 561264
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=561264
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

 bin/cgroup-release-agent             |  2 ++
 pym/_emerge/AbstractEbuildProcess.py | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/bin/cgroup-release-agent b/bin/cgroup-release-agent
new file mode 100755
index 0000000..7aa6d56
--- /dev/null
+++ b/bin/cgroup-release-agent
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec rmdir "/sys/fs/cgroup/portage/${1}"

diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
index 68d96e4..2b5d9c7 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -89,6 +89,13 @@ class AbstractEbuildProcess(SpawnProcess):
 					subprocess.check_call(['mount', '-t', 'cgroup',
 						'-o', 'rw,nosuid,nodev,noexec,none,name=portage',
 						'tmpfs', cgroup_portage])
+					with open(os.path.join(
+						cgroup_portage, 'release_agent'), 'w') as f:
+						f.write(os.path.join(self.settings['PORTAGE_BIN_PATH'],
+							'cgroup-release-agent'))
+					with open(os.path.join(
+						cgroup_portage, 'notify_on_release'), 'w') as f:
+						f.write('1')
 
 				cgroup_path = tempfile.mkdtemp(dir=cgroup_portage,
 					prefix='%s:%s.' % (self.settings["CATEGORY"],
@@ -313,13 +320,6 @@ class AbstractEbuildProcess(SpawnProcess):
 	def _set_returncode(self, wait_retval):
 		SpawnProcess._set_returncode(self, wait_retval)
 
-		if self.cgroup is not None:
-			try:
-				shutil.rmtree(self.cgroup)
-			except EnvironmentError as e:
-				if e.errno != errno.ENOENT:
-					raise
-
 		if self._exit_timeout_id is not None:
 			self.scheduler.source_remove(self._exit_timeout_id)
 			self._exit_timeout_id = None


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2013-12-27 18:06 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 16+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2013-12-27 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     0331526698e485508a1040d24acca5f5eff1c3f3
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Fri Dec 27 18:06:10 2013 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
CommitDate: Fri Dec 27 18:06:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=03315266

Bug #496134: Preserve extended attributes in binary packages.

---
 bin/misc-functions.sh               |  1 +
 pym/_emerge/Binpkg.py               |  1 +
 pym/_emerge/BinpkgExtractorAsync.py | 15 ++++++++++++---
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 2c4d248..5ccf7c2 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -1166,6 +1166,7 @@ __dyn_package() {
 
 	local tar_options=""
 	[[ $PORTAGE_VERBOSE = 1 ]] && tar_options+=" -v"
+	has xattr ${FEATURES} && [[ $(tar --help 2> /dev/null) == *--xattrs* ]] && tar_options+=" --xattrs"
 	# Sandbox is disabled in case the user wants to use a symlink
 	# for $PKGDIR and/or $PKGDIR/All.
 	export SANDBOX_ON="0"

diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index 36f8516..a740efd 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -298,6 +298,7 @@ class Binpkg(CompositeTask):
 
 		extractor = BinpkgExtractorAsync(background=self.background,
 			env=self.settings.environ(),
+			features=self.settings.features,
 			image_dir=self._image_dir,
 			pkg=self.pkg, pkg_path=self._pkg_path,
 			logfile=self.settings.get("PORTAGE_LOG_FILE"),

diff --git a/pym/_emerge/BinpkgExtractorAsync.py b/pym/_emerge/BinpkgExtractorAsync.py
index f25cbf9..be74c2f 100644
--- a/pym/_emerge/BinpkgExtractorAsync.py
+++ b/pym/_emerge/BinpkgExtractorAsync.py
@@ -1,23 +1,31 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.SpawnProcess import SpawnProcess
 import portage
 import signal
+import subprocess
 
 class BinpkgExtractorAsync(SpawnProcess):
 
-	__slots__ = ("image_dir", "pkg", "pkg_path")
+	__slots__ = ("features", "image_dir", "pkg", "pkg_path")
 
 	_shell_binary = portage.const.BASH_BINARY
 
 	def _start(self):
+		tar_options = ""
+		if "xattr" in self.features:
+			process = subprocess.Popen(["tar", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+			output = process.communicate()[0]
+			if b"--xattrs" in output:
+				tar_options = "--xattrs"
+
 		# Add -q to bzip2 opts, in order to avoid "trailing garbage after
 		# EOF ignored" warning messages due to xpak trailer.
 		# SIGPIPE handling (128 + SIGPIPE) should be compatible with
 		# assert_sigpipe_ok() that's used by the ebuild unpack() helper.
 		self.args = [self._shell_binary, "-c",
-			("${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -cq -- %s | tar -xp -C %s -f - ; " + \
+			("${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -cq -- %s | tar -xp %s -C %s -f - ; " + \
 			"p=(${PIPESTATUS[@]}) ; " + \
 			"if [[ ${p[0]} != 0 && ${p[0]} != %d ]] ; then " % (128 + signal.SIGPIPE) + \
 			"echo bzip2 failed with status ${p[0]} ; exit ${p[0]} ; fi ; " + \
@@ -25,6 +33,7 @@ class BinpkgExtractorAsync(SpawnProcess):
 			"echo tar failed with status ${p[1]} ; exit ${p[1]} ; fi ; " + \
 			"exit 0 ;") % \
 			(portage._shell_quote(self.pkg_path),
+			tar_options,
 			portage._shell_quote(self.image_dir))]
 
 		SpawnProcess._start(self)


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2013-08-03  0:38 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2013-08-03  0:38 UTC (permalink / raw
  To: gentoo-commits

commit:     6c0d165a602f7394b19b26059fd6b11a7a661e80
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  3 00:35:15 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Aug  3 00:37:11 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c0d165a

chpathtool.py: portage.util._argparse

---
 bin/chpathtool.py     | 7 ++++---
 pym/_emerge/Binpkg.py | 6 ++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/bin/chpathtool.py b/bin/chpathtool.py
index a040bab..c35acd1 100755
--- a/bin/chpathtool.py
+++ b/bin/chpathtool.py
@@ -3,11 +3,12 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import io
-import optparse
 import os
 import stat
 import sys
 
+from portage.util._argparse import ArgumentParser
+
 CONTENT_ENCODING = "utf_8"
 FS_ENCODING = "utf_8"
 
@@ -142,8 +143,8 @@ def chpath_inplace_symlink(filename, st, old, new):
 def main(argv):
 
 	usage = "%s [options] <location> <old> <new>" % (os.path.basename(argv[0],))
-	parser = optparse.OptionParser(usage=usage)
-	options, args = parser.parse_args(argv[1:])
+	parser = ArgumentParser(usage=usage)
+	options, args = parser.parse_known_args(argv[1:])
 
 	if len(args) != 3:
 		parser.error("3 args required, got %s" % (len(args),))

diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index ea8a1ad..36f8516 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.EbuildPhase import EbuildPhase
@@ -328,11 +328,13 @@ class Binpkg(CompositeTask):
 			self.wait()
 			return
 
+		env = self.settings.environ()
+		env["PYTHONPATH"] = self.settings["PORTAGE_PYTHONPATH"]
 		chpathtool = SpawnProcess(
 			args=[portage._python_interpreter,
 			os.path.join(self.settings["PORTAGE_BIN_PATH"], "chpathtool.py"),
 			self.settings["D"], self._build_prefix, self.settings["EPREFIX"]],
-			background=self.background, env=self.settings.environ(), 
+			background=self.background, env=env,
 			scheduler=self.scheduler,
 			logfile=self.settings.get('PORTAGE_LOG_FILE'))
 		self._writemsg_level(">>> Adjusting Prefix to %s\n" % self.settings["EPREFIX"])


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-12-29  7:45 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-12-29  7:45 UTC (permalink / raw
  To: gentoo-commits

commit:     d6bde84bd02aba99bbf7ee5a6a0e55d2be4216ff
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 29 07:44:39 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 29 07:44:39 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d6bde84b

Use run_main_scheduler where possible.

---
 bin/egencache          |   62 +++++------------------------------------------
 pym/_emerge/actions.py |   32 +++---------------------
 2 files changed, 11 insertions(+), 83 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 79a996d..110c47d 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -50,6 +50,7 @@ from portage.cache.cache_errors import CacheError, StatCollision
 from portage.manifest import guessManifestFileType
 from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler
 from portage.util import cmp_sort_key, writemsg_level
+from portage.util._async.run_main_scheduler import run_main_scheduler
 from portage.util._eventloop.global_event_loop import global_event_loop
 from portage import cpv_getkey
 from portage.dep import Atom, isjustname
@@ -357,34 +358,9 @@ class GenCache(object):
 					level=logging.ERROR, noiselevel=-1)
 
 	def run(self):
-
-		received_signal = []
-
-		def sighandler(signum, frame):
-			signal.signal(signal.SIGINT, signal.SIG_IGN)
-			signal.signal(signal.SIGTERM, signal.SIG_IGN)
-			self._regen.terminate()
-			received_signal.append(128 + signum)
-
-		earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
-		earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
-
-		try:
-			self._regen.start()
-			self._regen.wait()
-		finally:
-			# Restore previous handlers
-			if earlier_sigint_handler is not None:
-				signal.signal(signal.SIGINT, earlier_sigint_handler)
-			else:
-				signal.signal(signal.SIGINT, signal.SIG_DFL)
-			if earlier_sigterm_handler is not None:
-				signal.signal(signal.SIGTERM, earlier_sigterm_handler)
-			else:
-				signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
-		if received_signal:
-			sys.exit(received_signal[0])
+		signum = run_main_scheduler(self._regen)
+		if signum is not None:
+			sys.exit(128 + signum)
 
 		self.returncode |= self._regen.returncode
 
@@ -1058,33 +1034,9 @@ def egencache_main(args):
 			max_load=options.load_average,
 			event_loop=event_loop)
 
-		received_signal = []
-
-		def sighandler(signum, frame):
-			signal.signal(signal.SIGINT, signal.SIG_IGN)
-			signal.signal(signal.SIGTERM, signal.SIG_IGN)
-			received_signal.append(128 + signum)
-			scheduler.terminate()
-
-		earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
-		earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
-
-		try:
-			scheduler.start()
-			scheduler.wait()
-		finally:
-			# Restore previous handlers
-			if earlier_sigint_handler is not None:
-				signal.signal(signal.SIGINT, earlier_sigint_handler)
-			else:
-				signal.signal(signal.SIGINT, signal.SIG_DFL)
-			if earlier_sigterm_handler is not None:
-				signal.signal(signal.SIGTERM, earlier_sigterm_handler)
-			else:
-				signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
-		if received_signal:
-			sys.exit(received_signal[0])
+		signum = run_main_scheduler(scheduler)
+		if signum is not None:
+			sys.exit(128 + signum)
 
 		if options.tolerant:
 			ret.append(os.EX_OK)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 982197b..a498ae4 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -55,6 +55,7 @@ from portage._sets.base import InternalPackageSet
 from portage.util import cmp_sort_key, writemsg, varexpand, \
 	writemsg_level, writemsg_stdout
 from portage.util.digraph import digraph
+from portage.util._async.run_main_scheduler import run_main_scheduler
 from portage.util._async.SchedulerInterface import SchedulerInterface
 from portage.util._eventloop.global_event_loop import global_event_loop
 from portage._global_updates import _global_updates
@@ -1951,35 +1952,10 @@ def action_regen(settings, portdb, max_jobs, max_load):
 
 	regen = MetadataRegen(portdb, max_jobs=max_jobs,
 		max_load=max_load, main=True)
-	received_signal = []
 
-	def emergeexitsig(signum, frame):
-		signal.signal(signal.SIGINT, signal.SIG_IGN)
-		signal.signal(signal.SIGTERM, signal.SIG_IGN)
-		portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % \
-			{"signal":signum})
-		regen.terminate()
-		received_signal.append(128 + signum)
-
-	earlier_sigint_handler = signal.signal(signal.SIGINT, emergeexitsig)
-	earlier_sigterm_handler = signal.signal(signal.SIGTERM, emergeexitsig)
-
-	try:
-		regen.start()
-		regen.wait()
-	finally:
-		# Restore previous handlers
-		if earlier_sigint_handler is not None:
-			signal.signal(signal.SIGINT, earlier_sigint_handler)
-		else:
-			signal.signal(signal.SIGINT, signal.SIG_DFL)
-		if earlier_sigterm_handler is not None:
-			signal.signal(signal.SIGTERM, earlier_sigterm_handler)
-		else:
-			signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
-	if received_signal:
-		sys.exit(received_signal[0])
+	signum = run_main_scheduler(regen)
+	if signum is not None:
+		sys.exit(128 + signum)
 
 	portage.writemsg_stdout("done!\n")
 	return regen.returncode


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-10-14 21:59 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-10-14 21:59 UTC (permalink / raw
  To: gentoo-commits

commit:     8a8eda21d80099e74f38f5456f542611238f44a1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 14 21:59:33 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 14 21:59:33 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8a8eda21

emerge: handle KeyboardInterrupt, not SIGINT

We handle KeyboardInterrupt instead of installing a SIGINT handler,
since exiting from signal handlers intermittently causes python to
ignore the SystemExit exception with a message like this:

Exception SystemExit: 130 in <function remove at 0x7fd2146c1320> ignored

---
 bin/emerge          |   97 +++++++++++++++++++++++++++-----------------------
 pym/_emerge/main.py |    3 +-
 2 files changed, 53 insertions(+), 47 deletions(-)

diff --git a/bin/emerge b/bin/emerge
index f618068..b749b0a 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -7,64 +7,71 @@ from __future__ import print_function
 import platform
 import signal
 import sys
-# This block ensures that ^C interrupts are handled quietly.
+
+# This block ensures that ^C interrupts are handled quietly. We handle
+# KeyboardInterrupt instead of installing a SIGINT handler, since
+# exiting from signal handlers intermittently causes python to ignore
+# the SystemExit exception with a message like this:
+# Exception SystemExit: 130 in <function remove at 0x7fd2146c1320> ignored
 try:
 
 	def exithandler(signum,frame):
-		signal.signal(signal.SIGINT, signal.SIG_IGN)
 		signal.signal(signal.SIGTERM, signal.SIG_IGN)
 		sys.exit(128 + signum)
 
-	signal.signal(signal.SIGINT, exithandler)
 	signal.signal(signal.SIGTERM, exithandler)
 	# Prevent "[Errno 32] Broken pipe" exceptions when
 	# writing to a pipe.
 	signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 
-except KeyboardInterrupt:
-	sys.exit(128 + signal.SIGINT)
-
-def debug_signal(signum, frame):
-	import pdb
-	pdb.set_trace()
+	def debug_signal(signum, frame):
+		import pdb
+		pdb.set_trace()
 
-if platform.python_implementation() == 'Jython':
-	debug_signum = signal.SIGUSR2 # bug #424259
-else:
-	debug_signum = signal.SIGUSR1
+	if platform.python_implementation() == 'Jython':
+		debug_signum = signal.SIGUSR2 # bug #424259
+	else:
+		debug_signum = signal.SIGUSR1
 
-signal.signal(debug_signum, debug_signal)
+	signal.signal(debug_signum, debug_signal)
 
-from os import path as osp
-pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
-sys.path.insert(0, pym_path)
-from _emerge.main import emerge_main
+	from os import path as osp
+	pym_path = osp.join(osp.dirname(osp.dirname(
+		osp.realpath(__file__))), "pym")
+	sys.path.insert(0, pym_path)
+	from _emerge.main import emerge_main
 
-if __name__ == "__main__":
-	import sys
-	from portage.exception import ParseError, PermissionDenied
-	try:
-		retval = emerge_main()
-	except PermissionDenied as e:
-		sys.stderr.write("Permission denied: '%s'\n" % str(e))
-		sys.exit(e.errno)
-	except ParseError as e:
-		sys.stderr.write("%s\n" % str(e))
-		sys.exit(1)
-	except SystemExit:
-		raise
-	except Exception:
-		# If an unexpected exception occurs then we don't want the mod_echo
-		# output to obscure the traceback, so dump the mod_echo output before
-		# showing the traceback.
-		import traceback
-		tb_str = traceback.format_exc()
+	if __name__ == "__main__":
+		import sys
+		from portage.exception import ParseError, PermissionDenied
 		try:
-			from portage.elog import mod_echo
-		except ImportError:
-			pass
-		else:
-			mod_echo.finalize()
-		sys.stderr.write(tb_str)
-		sys.exit(1)
-	sys.exit(retval)
+			retval = emerge_main()
+		except PermissionDenied as e:
+			sys.stderr.write("Permission denied: '%s'\n" % str(e))
+			sys.exit(e.errno)
+		except ParseError as e:
+			sys.stderr.write("%s\n" % str(e))
+			sys.exit(1)
+		except (KeyboardInterrupt, SystemExit):
+			raise
+		except Exception:
+			# If an unexpected exception occurs then we don't want the
+			# mod_echo output to obscure the traceback, so dump the
+			# mod_echo output before showing the traceback.
+			import traceback
+			tb_str = traceback.format_exc()
+			try:
+				from portage.elog import mod_echo
+			except ImportError:
+				pass
+			else:
+				mod_echo.finalize()
+			sys.stderr.write(tb_str)
+			sys.exit(1)
+		sys.exit(retval)
+
+except KeyboardInterrupt:
+	sys.stderr.write("\n\nExiting on signal %(signal)s\n" %
+		{"signal": signal.SIGINT})
+	sys.stderr.flush()
+	sys.exit(128 + signal.SIGINT)

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index dad144c..adb6327 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1955,11 +1955,10 @@ def emerge_main(args=None):
 	del oldargs
 
 	def emergeexitsig(signum, frame):
-		signal.signal(signal.SIGINT, signal.SIG_IGN)
 		signal.signal(signal.SIGTERM, signal.SIG_IGN)
 		portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % {"signal":signum})
 		sys.exit(128 + signum)
-	signal.signal(signal.SIGINT, emergeexitsig)
+
 	signal.signal(signal.SIGTERM, emergeexitsig)
 
 	def emergeexit():


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-10-06 18:11 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-10-06 18:11 UTC (permalink / raw
  To: gentoo-commits

commit:     bb86a7b52641ad0b0b8e4150344865fec89eb4b3
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  6 18:05:37 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct  6 18:10:56 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bb86a7b5

MetadataRegen: inherit AsyncScheduler

---
 bin/egencache                |    5 ++-
 pym/_emerge/MetadataRegen.py |   65 ++++++++++-------------------------------
 pym/_emerge/actions.py       |    6 ++-
 3 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index a72fff7..15571cb 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -254,7 +254,7 @@ class GenCache(object):
 		self._regen = MetadataRegen(portdb, cp_iter=cp_iter,
 			consumer=self._metadata_callback,
 			max_jobs=max_jobs, max_load=max_load,
-			write_auxdb=write_auxdb)
+			write_auxdb=write_auxdb, main=True)
 		self.returncode = os.EX_OK
 		conf = portdb.repositories.get_repo_for_location(tree)
 		self._trg_caches = tuple(conf.iter_pregenerated_caches(
@@ -370,7 +370,8 @@ class GenCache(object):
 		earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
 
 		try:
-			self._regen.run()
+			self._regen.start()
+			self._regen.wait()
 		finally:
 			# Restore previous handlers
 			if earlier_sigint_handler is not None:

diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py
index 46b028a..80dbb5a 100644
--- a/pym/_emerge/MetadataRegen.py
+++ b/pym/_emerge/MetadataRegen.py
@@ -5,13 +5,14 @@ import portage
 from portage import os
 from portage.dep import _repo_separator
 from _emerge.EbuildMetadataPhase import EbuildMetadataPhase
-from _emerge.PollScheduler import PollScheduler
+from portage.cache.cache_errors import CacheError
+from portage.util._async.AsyncScheduler import AsyncScheduler
 
-class MetadataRegen(PollScheduler):
+class MetadataRegen(AsyncScheduler):
 
 	def __init__(self, portdb, cp_iter=None, consumer=None,
-		max_jobs=None, max_load=None, write_auxdb=True):
-		PollScheduler.__init__(self, main=True)
+		write_auxdb=True, **kwargs):
+		AsyncScheduler.__init__(self, **kwargs)
 		self._portdb = portdb
 		self._write_auxdb = write_auxdb
 		self._global_cleanse = False
@@ -23,23 +24,13 @@ class MetadataRegen(PollScheduler):
 		self._cp_iter = cp_iter
 		self._consumer = consumer
 
-		if max_jobs is None:
-			max_jobs = 1
-
-		self._max_jobs = max_jobs
-		self._max_load = max_load
-
 		self._valid_pkgs = set()
 		self._cp_set = set()
 		self._process_iter = self._iter_metadata_processes()
-		self.returncode = os.EX_OK
-		self._error_count = 0
 		self._running_tasks = set()
-		self._remaining_tasks = True
 
-	def _terminate_tasks(self):
-		for task in list(self._running_tasks):
-			task.cancel()
+	def _next_task(self):
+		return next(self._process_iter)
 
 	def _iter_every_cp(self):
 		portage.writemsg_stdout("Listing available packages...\n")
@@ -88,23 +79,16 @@ class MetadataRegen(PollScheduler):
 						settings=portdb.doebuild_settings,
 						write_auxdb=self._write_auxdb)
 
-	def _keep_scheduling(self):
-		return self._remaining_tasks and not self._terminated_tasks
+	def _wait(self):
 
-	def _running_job_count(self):
-		return len(self._running_tasks)
-
-	def run(self):
+		AsyncScheduler._wait(self)
 
 		portdb = self._portdb
-		from portage.cache.cache_errors import CacheError
 		dead_nodes = {}
 
-		self._main_loop()
-
 		if self._terminated_tasks:
-			self.returncode = 1
-			return
+			self.returncode = self._cancelled_returncode
+			return self.returncode
 
 		if self._global_cleanse:
 			for mytree in portdb.porttrees:
@@ -147,27 +131,11 @@ class MetadataRegen(PollScheduler):
 					except (KeyError, CacheError):
 						pass
 
-	def _schedule_tasks(self):
-		if self._terminated_tasks:
-			return
-
-		while self._can_add_job():
-			try:
-				metadata_process = next(self._process_iter)
-			except StopIteration:
-				self._remaining_tasks = False
-				return
-
-			self._running_tasks.add(metadata_process)
-			metadata_process.scheduler = self.sched_iface
-			metadata_process.addExitListener(self._metadata_exit)
-			metadata_process.start()
-
-	def _metadata_exit(self, metadata_process):
-		self._running_tasks.discard(metadata_process)
+		return self.returncode
+
+	def _task_exit(self, metadata_process):
+
 		if metadata_process.returncode != os.EX_OK:
-			self.returncode = 1
-			self._error_count += 1
 			self._valid_pkgs.discard(metadata_process.cpv)
 			if not self._terminated_tasks:
 				portage.writemsg("Error processing %s, continuing...\n" % \
@@ -182,5 +150,4 @@ class MetadataRegen(PollScheduler):
 				metadata_process.ebuild_hash,
 				metadata_process.eapi_supported)
 
-		self._schedule()
-
+		AsyncScheduler._task_exit(self, metadata_process)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index f7ec07a..c384dd4 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1866,7 +1866,8 @@ def action_regen(settings, portdb, max_jobs, max_load):
 	#regenerate cache entries
 	sys.stdout.flush()
 
-	regen = MetadataRegen(portdb, max_jobs=max_jobs, max_load=max_load)
+	regen = MetadataRegen(portdb, max_jobs=max_jobs,
+		max_load=max_load, main=True)
 	received_signal = []
 
 	def emergeexitsig(signum, frame):
@@ -1881,7 +1882,8 @@ def action_regen(settings, portdb, max_jobs, max_load):
 	earlier_sigterm_handler = signal.signal(signal.SIGTERM, emergeexitsig)
 
 	try:
-		regen.run()
+		regen.start()
+		regen.wait()
 	finally:
 		# Restore previous handlers
 		if earlier_sigint_handler is not None:


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-10-06 18:05 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-10-06 18:05 UTC (permalink / raw
  To: gentoo-commits

commit:     21e058f1675dc1b8afc986bc45eb291e2f505c9f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  6 18:05:37 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct  6 18:05:37 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=21e058f1

MetadataRegen: inherit AsyncScheduler

---
 bin/egencache                |    5 ++-
 pym/_emerge/MetadataRegen.py |   61 +++++++++++------------------------------
 pym/_emerge/actions.py       |    6 +++-
 3 files changed, 24 insertions(+), 48 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index a72fff7..15571cb 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -254,7 +254,7 @@ class GenCache(object):
 		self._regen = MetadataRegen(portdb, cp_iter=cp_iter,
 			consumer=self._metadata_callback,
 			max_jobs=max_jobs, max_load=max_load,
-			write_auxdb=write_auxdb)
+			write_auxdb=write_auxdb, main=True)
 		self.returncode = os.EX_OK
 		conf = portdb.repositories.get_repo_for_location(tree)
 		self._trg_caches = tuple(conf.iter_pregenerated_caches(
@@ -370,7 +370,8 @@ class GenCache(object):
 		earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
 
 		try:
-			self._regen.run()
+			self._regen.start()
+			self._regen.wait()
 		finally:
 			# Restore previous handlers
 			if earlier_sigint_handler is not None:

diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py
index 46b028a..6dbded1 100644
--- a/pym/_emerge/MetadataRegen.py
+++ b/pym/_emerge/MetadataRegen.py
@@ -5,13 +5,14 @@ import portage
 from portage import os
 from portage.dep import _repo_separator
 from _emerge.EbuildMetadataPhase import EbuildMetadataPhase
-from _emerge.PollScheduler import PollScheduler
+from portage.cache.cache_errors import CacheError
+from portage.util._async.AsyncScheduler import AsyncScheduler
 
-class MetadataRegen(PollScheduler):
+class MetadataRegen(AsyncScheduler):
 
 	def __init__(self, portdb, cp_iter=None, consumer=None,
-		max_jobs=None, max_load=None, write_auxdb=True):
-		PollScheduler.__init__(self, main=True)
+		write_auxdb=True, **kwargs):
+		AsyncScheduler.__init__(self, **kwargs)
 		self._portdb = portdb
 		self._write_auxdb = write_auxdb
 		self._global_cleanse = False
@@ -23,23 +24,13 @@ class MetadataRegen(PollScheduler):
 		self._cp_iter = cp_iter
 		self._consumer = consumer
 
-		if max_jobs is None:
-			max_jobs = 1
-
-		self._max_jobs = max_jobs
-		self._max_load = max_load
-
 		self._valid_pkgs = set()
 		self._cp_set = set()
 		self._process_iter = self._iter_metadata_processes()
-		self.returncode = os.EX_OK
-		self._error_count = 0
 		self._running_tasks = set()
-		self._remaining_tasks = True
 
-	def _terminate_tasks(self):
-		for task in list(self._running_tasks):
-			task.cancel()
+	def _next_task(self):
+		return next(self._process_iter)
 
 	def _iter_every_cp(self):
 		portage.writemsg_stdout("Listing available packages...\n")
@@ -94,17 +85,16 @@ class MetadataRegen(PollScheduler):
 	def _running_job_count(self):
 		return len(self._running_tasks)
 
-	def run(self):
+	def _wait(self):
+
+		AsyncScheduler._wait(self)
 
 		portdb = self._portdb
-		from portage.cache.cache_errors import CacheError
 		dead_nodes = {}
 
-		self._main_loop()
-
 		if self._terminated_tasks:
-			self.returncode = 1
-			return
+			self.returncode = self._cancelled_returncode
+			return self.returncode
 
 		if self._global_cleanse:
 			for mytree in portdb.porttrees:
@@ -147,27 +137,11 @@ class MetadataRegen(PollScheduler):
 					except (KeyError, CacheError):
 						pass
 
-	def _schedule_tasks(self):
-		if self._terminated_tasks:
-			return
-
-		while self._can_add_job():
-			try:
-				metadata_process = next(self._process_iter)
-			except StopIteration:
-				self._remaining_tasks = False
-				return
-
-			self._running_tasks.add(metadata_process)
-			metadata_process.scheduler = self.sched_iface
-			metadata_process.addExitListener(self._metadata_exit)
-			metadata_process.start()
-
-	def _metadata_exit(self, metadata_process):
-		self._running_tasks.discard(metadata_process)
+		return self.returncode
+
+	def _task_exit(self, metadata_process):
+
 		if metadata_process.returncode != os.EX_OK:
-			self.returncode = 1
-			self._error_count += 1
 			self._valid_pkgs.discard(metadata_process.cpv)
 			if not self._terminated_tasks:
 				portage.writemsg("Error processing %s, continuing...\n" % \
@@ -182,5 +156,4 @@ class MetadataRegen(PollScheduler):
 				metadata_process.ebuild_hash,
 				metadata_process.eapi_supported)
 
-		self._schedule()
-
+		AsyncScheduler._task_exit(self, metadata_process)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index f7ec07a..c384dd4 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1866,7 +1866,8 @@ def action_regen(settings, portdb, max_jobs, max_load):
 	#regenerate cache entries
 	sys.stdout.flush()
 
-	regen = MetadataRegen(portdb, max_jobs=max_jobs, max_load=max_load)
+	regen = MetadataRegen(portdb, max_jobs=max_jobs,
+		max_load=max_load, main=True)
 	received_signal = []
 
 	def emergeexitsig(signum, frame):
@@ -1881,7 +1882,8 @@ def action_regen(settings, portdb, max_jobs, max_load):
 	earlier_sigterm_handler = signal.signal(signal.SIGTERM, emergeexitsig)
 
 	try:
-		regen.run()
+		regen.start()
+		regen.wait()
 	finally:
 		# Restore previous handlers
 		if earlier_sigint_handler is not None:


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-09-15 16:53 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-09-15 16:53 UTC (permalink / raw
  To: gentoo-commits

commit:     50bea0375496f919fc40c586e8308b19f814ba66
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 15 16:53:42 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Sep 15 16:53:42 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=50bea037

egencache: skip auxdb write if not metadata-trans

---
 bin/egencache                      |    4 +++-
 pym/_emerge/EbuildMetadataPhase.py |    9 ++++++---
 pym/_emerge/MetadataRegen.py       |    6 ++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 0035674..ec62a8c 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -212,9 +212,11 @@ class GenCache(object):
 		else:
 			self._cp_set = None
 			self._cp_missing = set()
+		write_auxdb = "metadata-transfer" in portdb.settings.features
 		self._regen = MetadataRegen(portdb, cp_iter=cp_iter,
 			consumer=self._metadata_callback,
-			max_jobs=max_jobs, max_load=max_load)
+			max_jobs=max_jobs, max_load=max_load,
+			write_auxdb=write_auxdb)
 		self.returncode = os.EX_OK
 		conf = portdb.repositories.get_repo_for_location(tree)
 		self._trg_caches = tuple(conf.iter_pregenerated_caches(

diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py
index 669b4ae..1ffa1bb 100644
--- a/pym/_emerge/EbuildMetadataPhase.py
+++ b/pym/_emerge/EbuildMetadataPhase.py
@@ -25,7 +25,7 @@ class EbuildMetadataPhase(SubProcess):
 	"""
 
 	__slots__ = ("cpv", "eapi_supported", "ebuild_hash", "fd_pipes",
-		"metadata", "portdb", "repo_path", "settings") + \
+		"metadata", "portdb", "repo_path", "settings", "write_auxdb") + \
 		("_eapi", "_eapi_lineno", "_raw_metadata",)
 
 	_file_names = ("ebuild",)
@@ -180,8 +180,11 @@ class EbuildMetadataPhase(SubProcess):
 						metadata["_eclasses_"] = {}
 					metadata.pop("INHERITED", None)
 
-					self.portdb._write_cache(self.cpv,
-						self.repo_path, metadata, self.ebuild_hash)
+					# If called by egencache, this cache write is
+					# undesirable when metadata-transfer is disabled.
+					if self.write_auxdb is not False:
+						self.portdb._write_cache(self.cpv,
+							self.repo_path, metadata, self.ebuild_hash)
 				else:
 					metadata = {"EAPI": metadata["EAPI"]}
 				self.metadata = metadata

diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py
index e82015f..234298f 100644
--- a/pym/_emerge/MetadataRegen.py
+++ b/pym/_emerge/MetadataRegen.py
@@ -10,9 +10,10 @@ from _emerge.PollScheduler import PollScheduler
 class MetadataRegen(PollScheduler):
 
 	def __init__(self, portdb, cp_iter=None, consumer=None,
-		max_jobs=None, max_load=None):
+		max_jobs=None, max_load=None, write_auxdb=True):
 		PollScheduler.__init__(self, main=True)
 		self._portdb = portdb
+		self._write_auxdb = write_auxdb
 		self._global_cleanse = False
 		if cp_iter is None:
 			cp_iter = self._iter_every_cp()
@@ -84,7 +85,8 @@ class MetadataRegen(PollScheduler):
 					yield EbuildMetadataPhase(cpv=cpv,
 						ebuild_hash=ebuild_hash,
 						portdb=portdb, repo_path=repo_path,
-						settings=portdb.doebuild_settings)
+						settings=portdb.doebuild_settings,
+						write_auxdb=self._write_auxdb)
 
 	def _keep_scheduling(self):
 		return self._remaining_tasks and not self._terminated_tasks


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-07-18 21:38 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-07-18 21:38 UTC (permalink / raw
  To: gentoo-commits

commit:     30ec783c0fc64a02fda38980bded22dc0055a42d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 18 21:38:09 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jul 18 21:38:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=30ec783c

Fix extended atom match for =* operator.

---
 bin/portageq           |   12 +++++-------
 bin/quickpkg           |   13 ++++++-------
 pym/_emerge/actions.py |   28 +++++++++++++++++++++-------
 3 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index 280fe94..d9abb0b 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -583,17 +583,15 @@ def match(argv):
 			require_metadata = atom.slot or atom.repo
 			for cpv in vardb.cpv_all():
 
-				if not portage.dep.extended_cp_match(
-					atom.cp, portage.cpv_getkey(cpv)):
+				if not portage.match_from_list(atom, [cpv]):
 					continue
 
 				if require_metadata:
-					slot, repo = vardb.aux_get(cpv, ["SLOT", "repository"])
-
-					if atom.slot is not None and atom.slot != slot:
+					try:
+						cpv = vardb._pkg_str(cpv, atom.repo)
+					except (KeyError, portage.exception.InvalidData):
 						continue
-
-					if atom.repo is not None and atom.repo != repo:
+					if not portage.match_from_list(atom, [cpv]):
 						continue
 
 				results.append(cpv)

diff --git a/bin/quickpkg b/bin/quickpkg
index a6bd4d4..76259c5 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -21,7 +21,7 @@ except ImportError:
 from portage import os
 from portage import xpak
 from portage.dbapi.dep_expand import dep_expand
-from portage.dep import Atom, extended_cp_match, use_reduce
+from portage.dep import Atom, use_reduce
 from portage.exception import (AmbiguousPackageName, InvalidAtom, InvalidData,
 	InvalidDependString, PackageSetNotFound, PermissionDenied)
 from portage.util import ConfigProtect, ensure_dirs, shlex_split
@@ -204,16 +204,15 @@ def quickpkg_extended_atom(options, infos, atom, eout):
 			atoms.append(cpv_atom)
 			continue
 
-		if not extended_cp_match(atom.cp, cpv_atom.cp):
+		if not portage.match_from_list(atom, [cpv]):
 			continue
 
 		if require_metadata:
-			slot, repo = vardb.aux_get(cpv, ["SLOT", "repository"])
-
-			if atom.slot and atom.slot != slot:
+			try:
+				cpv = vardb._pkg_str(cpv, atom.repo)
+			except (KeyError, InvalidData):
 				continue
-
-			if atom.repo and atom.repo != repo:
+			if not portage.match_from_list(atom, [cpv]):
 				continue
 
 		atoms.append(cpv_atom)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index af42828..9a023a8 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -34,9 +34,9 @@ from portage.const import GLOBAL_CONFIG_PATH
 from portage.const import _ENABLE_DYN_LINK_MAP
 from portage.dbapi.dep_expand import dep_expand
 from portage.dbapi._expand_new_virt import expand_new_virt
-from portage.dep import Atom, extended_cp_match
+from portage.dep import Atom
 from portage.eclass_cache import hashed_path
-from portage.exception import InvalidAtom
+from portage.exception import InvalidAtom, InvalidData
 from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
 	red, yellow
 good = create_color_func("GOOD")
@@ -2594,16 +2594,30 @@ def action_uninstall(settings, trees, ldpath_mtimes,
 					level=logging.ERROR, noiselevel=-1)
 				return 1
 
-			for cp in vardb.cp_all():
-				if extended_cp_match(ext_atom.cp, cp):
-					atom = cp
+			for cpv in vardb.cpv_all():
+				if portage.match_from_list(ext_atom, [cpv]):
+					require_metadata = False
+					atom = portage.cpv_getkey(cpv)
+					if ext_atom.operator == '=*':
+						atom = "=" + atom + "-" + \
+							portage.versions.cpv_getversion(cpv)
 					if ext_atom.slot:
 						atom += ":" + ext_atom.slot
+						require_metadata = True
 					if ext_atom.repo:
 						atom += "::" + ext_atom.repo
+						require_metadata = True
+
+					atom = Atom(atom, allow_repo=True)
+					if require_metadata:
+						try:
+							cpv = vardb._pkg_str(cpv, ext_atom.repo)
+						except (KeyError, InvalidData):
+							continue
+						if not portage.match_from_list(atom, [cpv]):
+							continue
 
-					if vardb.match(atom):
-						valid_atoms.append(Atom(atom, allow_repo=True))
+					valid_atoms.append(atom)
 
 		else:
 			msg = []



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2012-03-25 23:20 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2012-03-25 23:20 UTC (permalink / raw
  To: gentoo-commits

commit:     ac13a18708d6223accb85d12ba895bc121df89c6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 25 23:20:19 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar 25 23:20:19 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ac13a187

Exit status 128 + SIGINT for --ask 'no' answer.

This will fix bug #409647.

---
 bin/repoman              |    2 +-
 pym/_emerge/actions.py   |   10 +++++-----
 pym/_emerge/main.py      |    2 +-
 pym/_emerge/userquery.py |    6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/bin/repoman b/bin/repoman
index d393df1..8e19a47 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -2622,7 +2622,7 @@ else:
 
 	if options.ask and userquery('Commit changes?', True) != 'Yes':
 		print("* aborting commit.")
-		sys.exit(1)
+		sys.exit(128 + signal.SIGINT)
 
 	# Handle the case where committed files have keywords which
 	# will change and need a priming commit before the Manifest

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index e9d6bd6..0fb4944 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -367,7 +367,7 @@ def action_build(settings, trees, mtimedb,
 			print()
 			print("Quitting.")
 			print()
-			return 1
+			return 128 + signal.SIGINT
 		# Don't ask again (e.g. when auto-cleaning packages after merge)
 		myopts.pop("--ask", None)
 
@@ -487,7 +487,7 @@ def action_config(settings, trees, myopts, myfiles):
 			options.append("X")
 			idx = userquery("Selection?", enter_invalid, responses=options)
 			if idx == "X":
-				sys.exit(0)
+				sys.exit(128 + signal.SIGINT)
 			pkg = pkgs[int(idx)-1]
 		else:
 			print("The following packages available:")
@@ -501,7 +501,7 @@ def action_config(settings, trees, myopts, myfiles):
 	print()
 	if "--ask" in myopts:
 		if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No":
-			sys.exit(0)
+			sys.exit(128 + signal.SIGINT)
 	else:
 		print("Configuring pkg...")
 	print()
@@ -1300,7 +1300,7 @@ def action_deselect(settings, trees, opts, atoms):
 				prompt = "Would you like to remove these " + \
 					"packages from your world favorites?"
 				if userquery(prompt, enter_invalid) == 'No':
-					return os.EX_OK
+					return 128 + signal.SIGINT
 
 			remaining = set(world_set)
 			remaining.difference_update(discard_atoms)
@@ -2226,7 +2226,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
 						print()
 						print("Quitting.")
 						print()
-						sys.exit(0)
+						sys.exit(128 + signal.SIGINT)
 				emergelog(xterm_titles, ">>> Starting rsync with " + dosyncuri)
 				if "--quiet" not in myopts:
 					print(">>> Starting rsync with "+dosyncuri+"...")

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index cf5f332..0fbc4b7 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1849,7 +1849,7 @@ def emerge_main(args=None):
 						portage_group_warning()
 					if userquery("Would you like to add --pretend to options?",
 						"--ask-enter-invalid" in myopts) == "No":
-						return 1
+						return 128 + signal.SIGINT
 					myopts["--pretend"] = True
 					del myopts["--ask"]
 				else:

diff --git a/pym/_emerge/userquery.py b/pym/_emerge/userquery.py
index e7ed400..efae80a 100644
--- a/pym/_emerge/userquery.py
+++ b/pym/_emerge/userquery.py
@@ -1,8 +1,9 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
+import signal
 import sys
 
 from portage.output import bold, create_color_func
@@ -51,5 +52,4 @@ def userquery(prompt, enter_invalid, responses=None, colours=None):
 			print("Sorry, response '%s' not understood." % response, end=' ')
 	except (EOFError, KeyboardInterrupt):
 		print("Interrupted.")
-		sys.exit(1)
-
+		sys.exit(128 + signal.SIGINT)



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2011-10-29  3:20 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2011-10-29  3:20 UTC (permalink / raw
  To: gentoo-commits

commit:     b30bb192825fbc4f35225aa2334655b4ba7329f5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 03:20:29 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 03:20:29 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b30bb192

Use EROOT to validate path arguments.

---
 bin/portageq            |    2 +-
 pym/_emerge/actions.py  |    2 +-
 pym/_emerge/depgraph.py |    8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index 40cc21d..66f6509 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -271,7 +271,7 @@ def owners(argv):
 				return 2
 			f = os.path.join(cwd, f)
 			f = portage.normalize_path(f)
-		if not is_basename and not f.startswith(root):
+		if not is_basename and not f.startswith(eroot):
 			sys.stderr.write("ERROR: file paths must begin with <root>!\n")
 			sys.stderr.flush()
 			return 2

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 88f5958..d482e0b 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2559,7 +2559,7 @@ def action_uninstall(settings, trees, ldpath_mtimes,
 		elif x.startswith(os.sep):
 			if not x.startswith(eroot):
 				writemsg_level(("!!! '%s' does not start with" + \
-					" $ROOT.\n") % x, level=logging.ERROR, noiselevel=-1)
+					" $EROOT.\n") % x, level=logging.ERROR, noiselevel=-1)
 				return 1
 			# Queue these up since it's most efficient to handle
 			# multiple files in a single iter_owners() call.

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index fc65f61..fcdcc6c 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2045,9 +2045,9 @@ class depgraph(object):
 				args.append(PackageArg(arg=x, package=pkg,
 					root_config=root_config))
 			elif x.startswith(os.path.sep):
-				if not x.startswith(root):
+				if not x.startswith(eroot):
 					portage.writemsg(("\n\n!!! '%s' does not start with" + \
-						" $ROOT.\n") % x, noiselevel=-1)
+						" $EROOT.\n") % x, noiselevel=-1)
 					self._dynamic_config._skip_restart = True
 					return 0, []
 				# Queue these up since it's most efficient to handle
@@ -2056,9 +2056,9 @@ class depgraph(object):
 			elif x.startswith("." + os.sep) or \
 				x.startswith(".." + os.sep):
 				f = os.path.abspath(x)
-				if not f.startswith(root):
+				if not f.startswith(eroot):
 					portage.writemsg(("\n\n!!! '%s' (resolved from '%s') does not start with" + \
-						" $ROOT.\n") % (f, x), noiselevel=-1)
+						" $EROOT.\n") % (f, x), noiselevel=-1)
 					self._dynamic_config._skip_restart = True
 					return 0, []
 				lookup_owners.append(f)



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2011-10-28 20:13 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2011-10-28 20:13 UTC (permalink / raw
  To: gentoo-commits

commit:     e8da78af846bac21363c85d4bee5d938844843be
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 28 20:13:07 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 28 20:13:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e8da78af

Check for bytes instead of unicode in args.

This simplifies the checks since the bytes type is available in all
supported python versions, while the unicode type is only available in
python2.

---
 bin/lock-helper.py  |    4 ++--
 bin/portageq        |    2 +-
 pym/_emerge/main.py |    3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/bin/lock-helper.py b/bin/lock-helper.py
index 5f3ea9f..065ddcb 100755
--- a/bin/lock-helper.py
+++ b/bin/lock-helper.py
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os
@@ -9,7 +9,7 @@ import portage
 
 def main(args):
 
-	if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
+	if args and isinstance(args[0], bytes):
 		for i, x in enumerate(args):
 			args[i] = portage._unicode_decode(x, errors='strict')
 

diff --git a/bin/portageq b/bin/portageq
index 02f1904..40cc21d 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -847,7 +847,7 @@ def main():
 		os.environ["ROOT"] = root
 
 	args = sys.argv[2:]
-	if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
+	if args and isinstance(args[0], bytes):
 		for i in range(len(args)):
 			args[i] = portage._unicode_decode(args[i])
 

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 0dfc5f9..162f70f 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1233,8 +1233,7 @@ def parse_opts(tmpcmdline, silent=False):
 	if myaction is None and myoptions.deselect is True:
 		myaction = 'deselect'
 
-	if myargs and sys.hexversion < 0x3000000 and \
-		not isinstance(myargs[0], unicode):
+	if myargs and isinstance(myargs[0], bytes):
 		for i in range(len(myargs)):
 			myargs[i] = portage._unicode_decode(myargs[i])
 



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
@ 2011-02-22  2:51 Zac Medico
  0 siblings, 0 replies; 16+ messages in thread
From: Zac Medico @ 2011-02-22  2:51 UTC (permalink / raw
  To: gentoo-commits

commit:     5e2d5b02d177497d01f4d13f7324056b092ca29f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 22 02:50:33 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb 22 02:50:33 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5e2d5b02

Update date headers in modified files.

---
 bin/isolated-functions.sh |    2 +-
 pym/_emerge/SubProcess.py |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index b5bb73a..2f144a0 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # We need this next line for "die" and "assert". It expands

diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py
index ef1346a..fc035d1 100644
--- a/pym/_emerge/SubProcess.py
+++ b/pym/_emerge/SubProcess.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage import os



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-04-30 19:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-10  3:23 [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2018-04-30 19:28 Zac Medico
2018-03-28  6:52 Zac Medico
2015-09-28 16:08 Zac Medico
2013-12-27 18:06 Arfrever Frehtes Taifersar Arahesis
2013-08-03  0:38 Zac Medico
2012-12-29  7:45 Zac Medico
2012-10-14 21:59 Zac Medico
2012-10-06 18:11 Zac Medico
2012-10-06 18:05 Zac Medico
2012-09-15 16:53 Zac Medico
2012-07-18 21:38 Zac Medico
2012-03-25 23:20 Zac Medico
2011-10-29  3:20 Zac Medico
2011-10-28 20:13 Zac Medico
2011-02-22  2:51 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox