* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/_emerge/
@ 2011-04-28 21:23 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2011-04-28 21:23 UTC (permalink / raw
To: gentoo-commits
commit: f86b547f1dbedb504de26e69ad66338258411a8f
Author: David James <davidjames <AT> google <DOT> com>
AuthorDate: Thu Apr 28 21:22:15 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Apr 28 21:22:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f86b547f
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
---
bin/misc-functions.sh | 16 -------------
pym/_emerge/EbuildPhase.py | 7 +++++-
pym/portage/package/ebuild/doebuild.py | 37 +++++++++++++++++++------------
3 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 4c5b61a..af0cc27 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 c9d1747..07fb69c 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 f353166..2a40791 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 = []
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/_emerge/
@ 2013-01-15 20:36 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2013-01-15 20:36 UTC (permalink / raw
To: gentoo-commits
commit: e9dc2b6753aa29eb776f15532fdda18f10af5d44
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 15 20:36:02 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 15 20:36:02 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e9dc2b67
EbuildMetadataPhase: use dynamic pipe fd
Also, remove deprecated code from doebuild (with hardcoded pipe fd).
---
bin/ebuild.sh | 4 +-
pym/_emerge/EbuildMetadataPhase.py | 5 ++-
pym/portage/package/ebuild/doebuild.py | 44 +++++--------------------------
3 files changed, 12 insertions(+), 41 deletions(-)
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index a4be7c0..2293938 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -696,9 +696,9 @@ if [[ $EBUILD_PHASE = depend ]] ; then
done
else
for f in ${auxdbkeys} ; do
- echo $(echo ${!f}) 1>&9 || exit $?
+ eval "echo \$(echo \${!f}) 1>&${PORTAGE_PIPE_FD}" || exit $?
done
- exec 9>&-
+ eval "exec ${PORTAGE_PIPE_FD}>&-"
fi
set +f
else
diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py
index 4806f5c..4c7d772 100644
--- a/pym/_emerge/EbuildMetadataPhase.py
+++ b/pym/_emerge/EbuildMetadataPhase.py
@@ -32,7 +32,6 @@ class EbuildMetadataPhase(SubProcess):
_file_names = ("ebuild",)
_files_dict = slot_dict_class(_file_names, prefix="")
- _metadata_fd = 9
def _start(self):
ebuild_path = self.ebuild_hash.location
@@ -103,7 +102,8 @@ class EbuildMetadataPhase(SubProcess):
fcntl.fcntl(master_fd, fcntl.F_SETFL,
fcntl.fcntl(master_fd, fcntl.F_GETFL) | fcntl_flags)
- fd_pipes[self._metadata_fd] = slave_fd
+ fd_pipes[slave_fd] = slave_fd
+ settings["PORTAGE_PIPE_FD"] = str(slave_fd)
self._raw_metadata = []
files.ebuild = master_fd
@@ -115,6 +115,7 @@ class EbuildMetadataPhase(SubProcess):
settings=settings, debug=debug,
mydbapi=self.portdb, tree="porttree",
fd_pipes=fd_pipes, returnpid=True)
+ settings.pop("PORTAGE_PIPE_FD", None)
os.close(slave_fd)
null_input.close()
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index e4d3ae4..a214c39 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -455,7 +455,7 @@ _doebuild_commands_without_builddir = (
)
def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
- fetchonly=0, cleanup=0, dbkey=None, use_cache=1, fetchall=0, tree=None,
+ fetchonly=0, cleanup=0, dbkey=DeprecationWarning, use_cache=1, fetchall=0, tree=None,
mydbapi=None, vartree=None, prev_mtimes=None,
fd_pipes=None, returnpid=False):
"""
@@ -524,6 +524,11 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
"settings['ROOT'] instead.",
DeprecationWarning, stacklevel=2)
+ if dbkey is not DeprecationWarning:
+ warnings.warn("portage.doebuild() called "
+ "with deprecated dbkey argument.",
+ DeprecationWarning, stacklevel=2)
+
if not tree:
writemsg("Warning: tree not specified to doebuild\n")
tree = "porttree"
@@ -720,42 +725,7 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
if returnpid:
return _spawn_phase(mydo, mysettings,
fd_pipes=fd_pipes, returnpid=returnpid)
- elif isinstance(dbkey, dict):
- warnings.warn("portage.doebuild() called " + \
- "with dict dbkey argument. This usage will " + \
- "not be supported in the future.",
- DeprecationWarning, stacklevel=2)
- mysettings["dbkey"] = ""
- pr, pw = os.pipe()
- fd_pipes = {
- 0:portage._get_stdin().fileno(),
- 1:sys.__stdout__.fileno(),
- 2:sys.__stderr__.fileno(),
- 9:pw}
- mypids = _spawn_phase(mydo, mysettings, returnpid=True,
- fd_pipes=fd_pipes)
- os.close(pw) # belongs exclusively to the child process now
- f = os.fdopen(pr, 'rb', 0)
- for k, v in zip(auxdbkeys,
- (_unicode_decode(line).rstrip('\n') for line in f)):
- dbkey[k] = v
- f.close()
- retval = os.waitpid(mypids[0], 0)[1]
- portage.process.spawned_pids.remove(mypids[0])
- # If it got a signal, return the signal that was sent, but
- # shift in order to distinguish it from a return value. (just
- # like portage.process.spawn() would do).
- if retval & 0xff:
- retval = (retval & 0xff) << 8
- else:
- # Otherwise, return its exit code.
- retval = retval >> 8
- if retval == os.EX_OK and len(dbkey) != len(auxdbkeys):
- # Don't trust bash's returncode if the
- # number of lines is incorrect.
- retval = 1
- return retval
- elif dbkey:
+ elif dbkey and dbkey is not DeprecationWarning:
mysettings["dbkey"] = dbkey
else:
mysettings["dbkey"] = \
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-15 20:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-15 20:36 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/_emerge/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-04-28 21:23 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox