Merged from trunk -r13854:13857
authorFabian Groffen <grobian@gentoo.org>
Fri, 31 Jul 2009 07:38:05 +0000 (07:38 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 31 Jul 2009 07:38:05 +0000 (07:38 -0000)
   | 13855   | Fix depgraph._show_missed_update() to keep each $ROOT        |
   | zmedico | separate.                                                    |

   | 13856   | Bug #278895 - Make ebuild.sh clean up orphaned processes     |
   | zmedico | that may have been left behind by ebuild phases. This works  |
   |         | by using setsid to create a new login session for the        |
   |         | ebuild.sh process, and `kill -s SIGHUP 0` to send a SIGHUP   |
   |         | signal to all processes in the session. The setsid is        |
   |         | currently not done on the python side since that would cause |
   |         | the sandbox process in the session, and sandbox produces a   |
   |         | warning message if it catches a SIGHUP signal.               |

   | 13857   | Inside die(), only send the signal for subshell die support  |
   | zmedico | when we are actually in a subshell.                          |

svn path=/main/branches/prefix/; revision=13868

bin/ebuild.sh
bin/isolated-functions.sh
pym/_emerge/depgraph.py
pym/portage/__init__.py

index fc43d7f5ac725139eb600b07f57c644af2e448e8..6ee31456493c5162e1a9ef980c57dca7c6756411 100755 (executable)
@@ -73,6 +73,17 @@ PREROOTPATH=${PREROOTPATH%%:}
 PATH="$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}${DEFAULT_PATH}:${ROOTPATH:+:}$ROOTPATH"
 export PATH
 
+if [[ -z $PORTAGE_SETSID && \
+       -n $EBUILD_SH_ARGS && $EBUILD_SH_ARGS != depend ]] ; then
+       if type -P setsid >/dev/null ; then
+               # Use setsid to create a new login session so that we can use SIGHUP
+               # to ensure that no orphaned subprocesses are left running.
+               export PORTAGE_SETSID=1
+               exec setsid "$PORTAGE_BIN_PATH/ebuild.sh" $EBUILD_SH_ARGS
+       fi
+fi
+trap '[[ $PORTAGE_SETSID = 1 ]] && { trap : SIGHUP ; kill -s SIGHUP 0 ; }' EXIT
+
 source "${PORTAGE_BIN_PATH}/isolated-functions.sh"  &>/dev/null
 
 # Set IMAGE for minimal backward compatibility with
index b6044b26bf5c51ca89cab0049833a595ba34e54a..947da3946ec6b40ecb614c592842bb5ddb67d4a7 100755 (executable)
@@ -144,7 +144,7 @@ die() {
        [ -n "$EBUILD_EXIT_STATUS_FILE" ] && > "$EBUILD_EXIT_STATUS_FILE"
 
        # subshell die support
-       kill -s SIGTERM ${EBUILD_MASTER_PID}
+       [[ $BASHPID = $EBUILD_MASTER_PID ]] || kill -s SIGTERM $EBUILD_MASTER_PID
        exit 1
 }
 
@@ -538,7 +538,8 @@ save_ebuild_env() {
                        PORTAGE_DEPCACHEDIR PORTAGE_GID PORTAGE_INST_GID \
                        PORTAGE_INST_UID PORTAGE_LOG_FILE PORTAGE_MASTER_PID \
                        PORTAGE_QUIET \
-                       PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_UPDATE_ENV \
+                       PORTAGE_REPO_NAME PORTAGE_RESTRICT \
+                       PORTAGE_SETSID PORTAGE_UPDATE_ENV \
                        PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR \
                        PORTDIR_OVERLAY ${!PORTAGE_SANDBOX_*} PREROOTPATH \
                        PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \
index afa976f023778575a73fae94ce3f05586e2fba05..8feef733ad82e0d31145161a8d1589e9f88121fe 100644 (file)
@@ -287,15 +287,15 @@ class depgraph(object):
                                # Exclude installed here since we only
                                # want to show available updates.
                                continue
-                       if pkg.slot_atom in missed_updates:
-                               other_pkg, mask_type, parent_atoms = \
-                                       missed_updates[pkg.slot_atom]
+                       k = (pkg.root, pkg.slot_atom)
+                       if k in missed_updates:
+                               other_pkg, mask_type, parent_atoms = missed_updates[k]
                                if other_pkg > pkg:
                                        continue
                        for mask_type, parent_atoms in mask_reasons.iteritems():
                                if not parent_atoms:
                                        continue
-                               missed_updates[pkg.slot_atom] = (pkg, mask_type, parent_atoms)
+                               missed_updates[k] = (pkg, mask_type, parent_atoms)
                                break
 
                if not missed_updates:
@@ -325,6 +325,8 @@ class depgraph(object):
                                "due to unsatisfied dependencies:\n\n")
 
                        write(str(pkg.slot_atom))
+                       if pkg.root != '/':
+                               write(" for %s" % (pkg.root,))
                        write("\n")
 
                        for parent, root, atom in parent_atoms:
@@ -345,6 +347,8 @@ class depgraph(object):
                indent = "  "
                for pkg, parent_atoms in missed_updates:
                        msg.append(str(pkg.slot_atom))
+                       if pkg.root != '/':
+                               msg.append(" for %s" % (pkg.root,))
                        msg.append("\n\n")
 
                        for parent, atom in parent_atoms:
index f65197cfb8ab4d63458690132059c077c2a629ba..57b491d719cb6cc84573a243f328ec81785ccf47 100644 (file)
@@ -1049,6 +1049,7 @@ class config(object):
                "EBUILD_PHASE", "EMERGE_FROM", "HOMEPAGE", "INHERITED", "IUSE",
                "KEYWORDS", "LICENSE", "PDEPEND", "PF", "PKGUSE",
                "PORTAGE_CONFIGROOT", "PORTAGE_IUSE", "PORTAGE_REPO_NAME",
+               "PORTAGE_SETSID",
                "PORTAGE_USE", "PROPERTIES", "PROVIDE", "RDEPEND", "RESTRICT",
                "ROOT", "SLOT", "SRC_URI", "EPREFIX", "EROOT"
        ]