* [gentoo-commits] proj/portage:master commit in: man/, pym/portage/, pym/_emerge/
@ 2011-02-15 17:22 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-02-15 17:22 UTC (permalink / raw
To: gentoo-commits
commit: 7ec33483cb06eeb7887b2e78215c04eaaae0eada
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 15 17:22:31 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb 15 17:22:31 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7ec33483
Update date headers for modified files.
---
man/ebuild.1 | 2 +-
pym/_emerge/EbuildExecuter.py | 2 +-
pym/_emerge/create_depgraph_params.py | 2 +-
pym/_emerge/help.py | 2 +-
pym/portage/getbinpkg.py | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/man/ebuild.1 b/man/ebuild.1
index cb6ebc2..e74779a 100644
--- a/man/ebuild.1
+++ b/man/ebuild.1
@@ -1,4 +1,4 @@
-.TH "EBUILD" "1" "Oct 2009" "Portage VERSION" "Portage"
+.TH "EBUILD" "1" "Feb 2011" "Portage VERSION" "Portage"
.SH "NAME"
ebuild \- a low level interface to the Portage system
.SH "SYNOPSIS"
diff --git a/pym/_emerge/EbuildExecuter.py b/pym/_emerge/EbuildExecuter.py
index 95614de..b28c737 100644
--- a/pym/_emerge/EbuildExecuter.py
+++ b/pym/_emerge/EbuildExecuter.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.EbuildPhase import EbuildPhase
diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py
index 735f12c..d60259e 100644
--- a/pym/_emerge/create_depgraph_params.py
+++ b/pym/_emerge/create_depgraph_params.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
import logging
diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py
index 6a1bae4..bd6c0f2 100644
--- a/pym/_emerge/help.py
+++ b/pym/_emerge/help.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 __future__ import print_function
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 43a6bf5..68e4543 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -1,5 +1,5 @@
# getbinpkg.py -- Portage binary-package helper functions
-# Copyright 2003-2004 Gentoo Foundation
+# Copyright 2003-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.output import colorize
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/portage/, pym/_emerge/
@ 2013-07-30 5:24 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2013-07-30 5:24 UTC (permalink / raw
To: gentoo-commits
commit: 73a972e0cac5d7e5f59a58c11e998793fe2b1a2d
Author: Tomáš Čech <sleep_walker <AT> suse <DOT> cz>
AuthorDate: Sat Jul 27 23:09:39 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 30 05:23:55 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=73a972e0
emerge: accept --pkg-format option
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 <AT> suse.cz>
---
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 fd48089..ac4651f 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 ddacf56..451dba9 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 75d906f..e13b1cf 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 03074fe..4c53c25 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 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 c05b1c0..1f660a1 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
# ===========================================================================
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: man/, pym/portage/, pym/_emerge/
@ 2013-08-19 9:21 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2013-08-19 9:21 UTC (permalink / raw
To: gentoo-commits
commit: b01a1b90d8c5c9ebc9b2c956520f3096cc07342d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 19 08:45:52 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 19 09:15:55 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b01a1b90
Add FEATURES=cgroup to isolate phase processes.
We create a cgroup for each ebuild. The ebuild processes are put in that
cgroup, therefore allowing us to keep track of their replication. Once
ebuild phase is over, we can happily kill all orphans.
---
man/make.conf.5 | 4 ++++
pym/_emerge/AbstractEbuildProcess.py | 39 ++++++++++++++++++++++++++++++++++++
pym/_emerge/SpawnProcess.py | 37 +++++++++++++++++++++++++++++++++-
pym/portage/const.py | 2 +-
pym/portage/process.py | 17 +++++++++++++---
5 files changed, 94 insertions(+), 5 deletions(-)
diff --git a/man/make.conf.5 b/man/make.conf.5
index 91817ae..ab9b44e 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -276,6 +276,10 @@ like "File not recognized: File truncated"), try recompiling the application
with ccache disabled before reporting a bug. Unless you are doing development
work, do not enable ccache.
.TP
+.B cgroup
+Use Linux control group to control processes spawned by ebuilds. This allows
+emerge to safely kill all subprocesses when ebuild phase exits.
+.TP
.B clean\-logs
Enable automatic execution of the command specified by the
PORT_LOGDIR_CLEAN variable. The default PORT_LOGDIR_CLEAN setting will
diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
index 6d12cd9..31127f4 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -2,7 +2,9 @@
# Distributed under the terms of the GNU General Public License v2
import io
+import platform
import stat
+import subprocess
import textwrap
from _emerge.SpawnProcess import SpawnProcess
from _emerge.EbuildBuildDir import EbuildBuildDir
@@ -20,8 +22,10 @@ class AbstractEbuildProcess(SpawnProcess):
__slots__ = ('phase', 'settings',) + \
('_build_dir', '_ipc_daemon', '_exit_command', '_exit_timeout_id')
+
_phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',)
_phases_interactive_whitelist = ('config',)
+ _phases_without_cgroup = ('preinst', 'postinst', 'prerm', 'postrm', 'config')
# Number of milliseconds to allow natural exit of the ebuild
# process after it has called the exit command via IPC. It
@@ -59,6 +63,41 @@ class AbstractEbuildProcess(SpawnProcess):
self._async_wait()
return
+ # Check if the cgroup hierarchy is in place. If it's not, mount it.
+ if (os.geteuid() == 0 and platform.system() == 'Linux'
+ and 'cgroup' in self.settings.features
+ and self.phase not in self._phases_without_cgroup):
+ cgroup_root = '/sys/fs/cgroup'
+ cgroup_portage = os.path.join(cgroup_root, 'portage')
+ cgroup_path = os.path.join(cgroup_portage,
+ '%s:%s' % (self.settings["CATEGORY"],
+ self.settings["PF"]))
+ try:
+ # cgroup tmpfs
+ if not os.path.ismount(cgroup_root):
+ # we expect /sys/fs to be there already
+ if not os.path.isdir(cgroup_root):
+ os.mkdir(cgroup_root, 0o755)
+ subprocess.check_call(['mount', '-t', 'tmpfs',
+ '-o', 'rw,nosuid,nodev,noexec,mode=0755',
+ 'tmpfs', cgroup_root])
+
+ # portage subsystem
+ if not os.path.ismount(cgroup_portage):
+ if not os.path.isdir(cgroup_portage):
+ os.mkdir(cgroup_portage, 0o755)
+ subprocess.check_call(['mount', '-t', 'cgroup',
+ '-o', 'rw,nosuid,nodev,noexec,none,name=portage',
+ 'tmpfs', cgroup_portage])
+
+ # the ebuild cgroup
+ if not os.path.isdir(cgroup_path):
+ os.mkdir(cgroup_path)
+ except (subprocess.CalledProcessError, OSError):
+ pass
+ else:
+ self.cgroup = cgroup_path
+
if self.background:
# Automatically prevent color codes from showing up in logs,
# since we're not displaying to a terminal anyway.
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index 3b363a2..60bd3f1 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -7,7 +7,9 @@ except ImportError:
# http://bugs.jython.org/issue1074
fcntl = None
+import errno
import platform
+import signal
import sys
from _emerge.SubProcess import SubProcess
@@ -29,7 +31,7 @@ class SpawnProcess(SubProcess):
_spawn_kwarg_names = ("env", "opt_name", "fd_pipes",
"uid", "gid", "groups", "umask", "logfile",
- "path_lookup", "pre_exec", "close_fds")
+ "path_lookup", "pre_exec", "close_fds", "cgroup")
__slots__ = ("args",) + \
_spawn_kwarg_names + ("_pipe_logger", "_selinux_type",)
@@ -179,3 +181,36 @@ class SpawnProcess(SubProcess):
pipe_logger.removeExitListener(self._pipe_logger_exit)
pipe_logger.cancel()
pipe_logger.wait()
+
+ def _set_returncode(self, wait_retval):
+ SubProcess._set_returncode(self, wait_retval)
+
+ if self.cgroup:
+ def get_pids(cgroup):
+ try:
+ with open(os.path.join(cgroup, 'cgroup.procs'), 'r') as f:
+ return f.read().split()
+ except OSError:
+ # cgroup removed already?
+ return []
+
+ def kill_all(pids, sig):
+ for p in pids:
+ try:
+ os.kill(int(p), sig)
+ except OSError as e:
+ if e.errno != errno.ESRCH:
+ raise
+
+ # step 1: kill all orphans
+ pids = get_pids(self.cgroup)
+ if pids:
+ kill_all(pids, signal.SIGTERM)
+
+ # step 2: remove the cgroup
+ try:
+ os.rmdir(self.cgroup)
+ except OSError:
+ # it may be removed already, or busy
+ # we can't do anything good about it
+ pass
diff --git a/pym/portage/const.py b/pym/portage/const.py
index 88c199b..214ede4 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -96,7 +96,7 @@ EBUILD_PHASES = ("pretend", "setup", "unpack", "prepare", "configure"
"nofetch", "config", "info", "other")
SUPPORTED_FEATURES = frozenset([
"assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
- "ccache", "chflags", "clean-logs",
+ "ccache", "cgroup", "chflags", "clean-logs",
"collision-protect", "compress-build-logs", "compressdebug",
"compress-index", "config-protect-if-modified",
"digest", "distcc", "distcc-pump", "distlocks",
diff --git a/pym/portage/process.py b/pym/portage/process.py
index 22c6a88..20ef97d 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -185,7 +185,7 @@ def cleanup():
def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
uid=None, gid=None, groups=None, umask=None, logfile=None,
path_lookup=True, pre_exec=None, close_fds=True, unshare_net=False,
- unshare_ipc=False):
+ unshare_ipc=False, cgroup=None):
"""
Spawns a given command.
@@ -222,6 +222,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
@type unshare_net: Boolean
@param unshare_ipc: If True, IPC will be unshared from the spawned process
@type unshare_ipc: Boolean
+ @param cgroup: CGroup path to bind the process to
+ @type cgroup: String
logfile requires stdout and stderr to be assigned to this process (ie not pointed
somewhere else.)
@@ -300,7 +302,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
try:
_exec(binary, mycommand, opt_name, fd_pipes,
env, gid, groups, uid, umask, pre_exec, close_fds,
- unshare_net, unshare_ipc)
+ unshare_net, unshare_ipc, cgroup)
except SystemExit:
raise
except Exception as e:
@@ -370,7 +372,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
return 0
def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
- pre_exec, close_fds, unshare_net, unshare_ipc):
+ pre_exec, close_fds, unshare_net, unshare_ipc, cgroup):
"""
Execute a given binary with options
@@ -399,6 +401,8 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
@type unshare_net: Boolean
@param unshare_ipc: If True, IPC will be unshared from the spawned process
@type unshare_ipc: Boolean
+ @param cgroup: CGroup path to bind the process to
+ @type cgroup: String
@rtype: None
@return: Never returns (calls os.execve)
"""
@@ -435,6 +439,13 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
_setup_pipes(fd_pipes, close_fds=close_fds)
+ # Add to cgroup
+ # it's better to do it from the child since we can guarantee
+ # it is done before we start forking children
+ if cgroup:
+ with open(os.path.join(cgroup, 'cgroup.procs'), 'a') as f:
+ f.write('%d\n' % os.getpid())
+
# Unshare (while still uid==0)
if unshare_net or unshare_ipc:
filename = find_library("c")
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-19 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 9:21 [gentoo-commits] proj/portage:master commit in: man/, pym/portage/, pym/_emerge/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2013-07-30 5:24 Zac Medico
2011-02-15 17:22 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox