aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid James <davidjames@google.com>2011-04-28 14:22:15 -0700
committerZac Medico <zmedico@gentoo.org>2011-04-28 14:22:15 -0700
commitf86b547f1dbedb504de26e69ad66338258411a8f (patch)
tree04788238e50d32187c62d3c2e5d4c65a19da67e9
parentdisplay_preserved_libs: load plib_registry (diff)
downloadportage-f86b547f1dbedb504de26e69ad66338258411a8f.tar.gz
portage-f86b547f1dbedb504de26e69ad66338258411a8f.tar.bz2
portage-f86b547f1dbedb504de26e69ad66338258411a8f.zip
Move preinst/postinst_bsdflags from bash to py
Moving these commands from shell to Python helps avoid an unnecessary call to misc-functions.sh for the postinst_bsdflags. This improves performance. BUG=none TEST=Run emerge-x86-generic -eg --jobs=16 libchrome Change-Id: I0c2af50b4d2f7644cabac84fde7fe4d682010c69 Review URL: http://codereview.chromium.org/6676107
-rwxr-xr-xbin/misc-functions.sh16
-rw-r--r--pym/_emerge/EbuildPhase.py7
-rw-r--r--pym/portage/package/ebuild/doebuild.py37
3 files changed, 29 insertions, 31 deletions
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 4c5b61a18..af0cc2760 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -723,22 +723,6 @@ install_mask() {
set -${shopts}
}
-preinst_bsdflags() {
- hasq chflags $FEATURES || return
- # Save all the file flags for restoration after installation.
- mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree"
- # Remove all the file flags so that the merge phase can do anything
- # necessary.
- chflags -R noschg,nouchg,nosappnd,nouappnd "${D}"
- chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null
-}
-
-postinst_bsdflags() {
- hasq chflags $FEATURES || return
- # Restore all the file flags that were saved before installation.
- mtree -e -p "${ROOT}" -U -k flags < "${T}/bsdflags.mtree" &> /dev/null
-}
-
preinst_mask() {
if [ -z "${D}" ]; then
eerror "${FUNCNAME}: D is unset"
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py
index c9d17474e..07fb69ca7 100644
--- a/pym/_emerge/EbuildPhase.py
+++ b/pym/_emerge/EbuildPhase.py
@@ -17,7 +17,8 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.package.ebuild.doebuild:_check_build_log,' + \
'_post_phase_cmds,_post_phase_userpriv_perms,' + \
'_post_src_install_chost_fix,' + \
- '_post_src_install_uid_fix'
+ '_post_src_install_uid_fix,_postinst_bsdflags,' + \
+ '_preinst_bsdflags'
)
from portage import os
from portage import StringIO
@@ -178,6 +179,10 @@ class EbuildPhase(CompositeTask):
encoding=_encodings['content'], errors='replace')
if msg:
self.scheduler.output(msg, log_path=logfile)
+ elif self.phase == "preinst":
+ _preinst_bsdflags(settings)
+ elif self.phase == "postinst":
+ _postinst_bsdflags(settings)
post_phase_cmds = _post_phase_cmds.get(self.phase)
if post_phase_cmds is not None:
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index f353166d7..2a4079109 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -1233,14 +1233,10 @@ _post_phase_cmds = {
"install_symlink_html_docs"],
"preinst" : [
- "preinst_bsdflags",
"preinst_sfperms",
"preinst_selinux_labels",
"preinst_suid_scan",
- "preinst_mask"],
-
- "postinst" : [
- "postinst_bsdflags"]
+ "preinst_mask"]
}
def _post_phase_userpriv_perms(mysettings):
@@ -1392,6 +1388,27 @@ _vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND',
'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',)
_vdb_use_conditional_atoms = frozenset(['DEPEND', 'PDEPEND', 'RDEPEND'])
+def _preinst_bsdflags(mysettings):
+ if bsd_chflags:
+ # Save all the file flags for restoration later.
+ os.system("mtree -c -p %s -k flags > %s" % \
+ (_shell_quote(mysettings["D"]),
+ _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree"))))
+
+ # Remove all the file flags to avoid EPERM errors.
+ os.system("chflags -R noschg,nouchg,nosappnd,nouappnd %s" % \
+ (_shell_quote(mysettings["D"]),))
+ os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \
+ (_shell_quote(mysettings["D"]),))
+
+
+def _postinst_bsdflags(mysettings):
+ if bsd_chflags:
+ # Restore all of the flags saved above.
+ os.system("mtree -e -p %s -U -k flags < %s > /dev/null" % \
+ (_shell_quote(mysettings["D"]),
+ _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree"))))
+
def _post_src_install_uid_fix(mysettings, out):
"""
Files in $D with user and group bits that match the "portage"
@@ -1406,15 +1423,7 @@ def _post_src_install_uid_fix(mysettings, out):
inst_uid = int(mysettings["PORTAGE_INST_UID"])
inst_gid = int(mysettings["PORTAGE_INST_GID"])
- if bsd_chflags:
- # Temporarily remove all of the flags in order to avoid EPERM errors.
- os.system("mtree -c -p %s -k flags > %s" % \
- (_shell_quote(mysettings["D"]),
- _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree"))))
- os.system("chflags -R noschg,nouchg,nosappnd,nouappnd %s" % \
- (_shell_quote(mysettings["D"]),))
- os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \
- (_shell_quote(mysettings["D"]),))
+ _preinst_bsdflags(mysettings)
destdir = mysettings["D"]
unicode_errors = []