1 |
commit: f86b547f1dbedb504de26e69ad66338258411a8f |
2 |
Author: David James <davidjames <AT> google <DOT> com> |
3 |
AuthorDate: Thu Apr 28 21:22:15 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 28 21:22:15 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f86b547f |
7 |
|
8 |
Move preinst/postinst_bsdflags from bash to py |
9 |
|
10 |
Moving these commands from shell to Python helps avoid an unnecessary |
11 |
call to misc-functions.sh for the postinst_bsdflags. This improves |
12 |
performance. |
13 |
|
14 |
BUG=none |
15 |
TEST=Run emerge-x86-generic -eg --jobs=16 libchrome |
16 |
|
17 |
Change-Id: I0c2af50b4d2f7644cabac84fde7fe4d682010c69 |
18 |
|
19 |
Review URL: http://codereview.chromium.org/6676107 |
20 |
|
21 |
--- |
22 |
bin/misc-functions.sh | 16 ------------- |
23 |
pym/_emerge/EbuildPhase.py | 7 +++++- |
24 |
pym/portage/package/ebuild/doebuild.py | 37 +++++++++++++++++++------------ |
25 |
3 files changed, 29 insertions(+), 31 deletions(-) |
26 |
|
27 |
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh |
28 |
index 4c5b61a..af0cc27 100755 |
29 |
--- a/bin/misc-functions.sh |
30 |
+++ b/bin/misc-functions.sh |
31 |
@@ -723,22 +723,6 @@ install_mask() { |
32 |
set -${shopts} |
33 |
} |
34 |
|
35 |
-preinst_bsdflags() { |
36 |
- hasq chflags $FEATURES || return |
37 |
- # Save all the file flags for restoration after installation. |
38 |
- mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree" |
39 |
- # Remove all the file flags so that the merge phase can do anything |
40 |
- # necessary. |
41 |
- chflags -R noschg,nouchg,nosappnd,nouappnd "${D}" |
42 |
- chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null |
43 |
-} |
44 |
- |
45 |
-postinst_bsdflags() { |
46 |
- hasq chflags $FEATURES || return |
47 |
- # Restore all the file flags that were saved before installation. |
48 |
- mtree -e -p "${ROOT}" -U -k flags < "${T}/bsdflags.mtree" &> /dev/null |
49 |
-} |
50 |
- |
51 |
preinst_mask() { |
52 |
if [ -z "${D}" ]; then |
53 |
eerror "${FUNCNAME}: D is unset" |
54 |
|
55 |
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py |
56 |
index c9d1747..07fb69c 100644 |
57 |
--- a/pym/_emerge/EbuildPhase.py |
58 |
+++ b/pym/_emerge/EbuildPhase.py |
59 |
@@ -17,7 +17,8 @@ portage.proxy.lazyimport.lazyimport(globals(), |
60 |
'portage.package.ebuild.doebuild:_check_build_log,' + \ |
61 |
'_post_phase_cmds,_post_phase_userpriv_perms,' + \ |
62 |
'_post_src_install_chost_fix,' + \ |
63 |
- '_post_src_install_uid_fix' |
64 |
+ '_post_src_install_uid_fix,_postinst_bsdflags,' + \ |
65 |
+ '_preinst_bsdflags' |
66 |
) |
67 |
from portage import os |
68 |
from portage import StringIO |
69 |
@@ -178,6 +179,10 @@ class EbuildPhase(CompositeTask): |
70 |
encoding=_encodings['content'], errors='replace') |
71 |
if msg: |
72 |
self.scheduler.output(msg, log_path=logfile) |
73 |
+ elif self.phase == "preinst": |
74 |
+ _preinst_bsdflags(settings) |
75 |
+ elif self.phase == "postinst": |
76 |
+ _postinst_bsdflags(settings) |
77 |
|
78 |
post_phase_cmds = _post_phase_cmds.get(self.phase) |
79 |
if post_phase_cmds is not None: |
80 |
|
81 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
82 |
index f353166..2a40791 100644 |
83 |
--- a/pym/portage/package/ebuild/doebuild.py |
84 |
+++ b/pym/portage/package/ebuild/doebuild.py |
85 |
@@ -1233,14 +1233,10 @@ _post_phase_cmds = { |
86 |
"install_symlink_html_docs"], |
87 |
|
88 |
"preinst" : [ |
89 |
- "preinst_bsdflags", |
90 |
"preinst_sfperms", |
91 |
"preinst_selinux_labels", |
92 |
"preinst_suid_scan", |
93 |
- "preinst_mask"], |
94 |
- |
95 |
- "postinst" : [ |
96 |
- "postinst_bsdflags"] |
97 |
+ "preinst_mask"] |
98 |
} |
99 |
|
100 |
def _post_phase_userpriv_perms(mysettings): |
101 |
@@ -1392,6 +1388,27 @@ _vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND', |
102 |
'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',) |
103 |
_vdb_use_conditional_atoms = frozenset(['DEPEND', 'PDEPEND', 'RDEPEND']) |
104 |
|
105 |
+def _preinst_bsdflags(mysettings): |
106 |
+ if bsd_chflags: |
107 |
+ # Save all the file flags for restoration later. |
108 |
+ os.system("mtree -c -p %s -k flags > %s" % \ |
109 |
+ (_shell_quote(mysettings["D"]), |
110 |
+ _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree")))) |
111 |
+ |
112 |
+ # Remove all the file flags to avoid EPERM errors. |
113 |
+ os.system("chflags -R noschg,nouchg,nosappnd,nouappnd %s" % \ |
114 |
+ (_shell_quote(mysettings["D"]),)) |
115 |
+ os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \ |
116 |
+ (_shell_quote(mysettings["D"]),)) |
117 |
+ |
118 |
+ |
119 |
+def _postinst_bsdflags(mysettings): |
120 |
+ if bsd_chflags: |
121 |
+ # Restore all of the flags saved above. |
122 |
+ os.system("mtree -e -p %s -U -k flags < %s > /dev/null" % \ |
123 |
+ (_shell_quote(mysettings["D"]), |
124 |
+ _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree")))) |
125 |
+ |
126 |
def _post_src_install_uid_fix(mysettings, out): |
127 |
""" |
128 |
Files in $D with user and group bits that match the "portage" |
129 |
@@ -1406,15 +1423,7 @@ def _post_src_install_uid_fix(mysettings, out): |
130 |
inst_uid = int(mysettings["PORTAGE_INST_UID"]) |
131 |
inst_gid = int(mysettings["PORTAGE_INST_GID"]) |
132 |
|
133 |
- if bsd_chflags: |
134 |
- # Temporarily remove all of the flags in order to avoid EPERM errors. |
135 |
- os.system("mtree -c -p %s -k flags > %s" % \ |
136 |
- (_shell_quote(mysettings["D"]), |
137 |
- _shell_quote(os.path.join(mysettings["T"], "bsdflags.mtree")))) |
138 |
- os.system("chflags -R noschg,nouchg,nosappnd,nouappnd %s" % \ |
139 |
- (_shell_quote(mysettings["D"]),)) |
140 |
- os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \ |
141 |
- (_shell_quote(mysettings["D"]),)) |
142 |
+ _preinst_bsdflags(mysettings) |
143 |
|
144 |
destdir = mysettings["D"] |
145 |
unicode_errors = [] |