summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-28 10:37:47 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-28 10:37:47 +0000
commit9d32ae401ea25227bd8bcfe7dfaad6c06e349a6b (patch)
tree5885d796649904e5c7bda8ed241b1f51f4a81552
parent8ac4cf5ef0e4ea62e3c28985134206b44ff93889 (diff)
downloadportage-9d32ae401ea25227bd8bcfe7dfaad6c06e349a6b.tar.gz
portage-9d32ae401ea25227bd8bcfe7dfaad6c06e349a6b.tar.bz2
portage-9d32ae401ea25227bd8bcfe7dfaad6c06e349a6b.zip
Use mtree to save/restore bsd file flags before/after prepall and installation. Thanks to Diego Pettenò for this patch (related to bug #153109).
svn path=/main/trunk/; revision=4863
-rwxr-xr-xbin/misc-functions.sh18
-rwxr-xr-xbin/prepall13
-rw-r--r--pym/portage.py53
3 files changed, 55 insertions, 29 deletions
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 9ae010e4d..3a1826e66 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -243,6 +243,24 @@ install_mask() {
set -${shopts}
}
+preinst_bsdflags() {
+ type -p chflags &>/dev/null || return 0
+ type -p mtree &>/dev/null || return 1
+ # 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() {
+ type -p chflags &>/dev/null || return 0
+ type -p mtree &>/dev/null || return 1
+ # 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 "$IMAGE" ]; then
eerror "${FUNCNAME}: IMAGE is unset"
diff --git a/bin/prepall b/bin/prepall
index 118b85d8b..68af880dc 100755
--- a/bin/prepall
+++ b/bin/prepall
@@ -5,6 +5,14 @@
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+if type -p chflags &>/dev/null && type -p mtree &>/dev/null; then
+ # Save all the file flags for restoration at the end of prepall.
+ mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree"
+ # Remove all the file flags so that prepall can do anything necessary.
+ chflags -R noschg,nouchg,nosappnd,nouappnd "${D}"
+ chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null
+fi
+
prepallman
prepallinfo
prepallstrip
@@ -88,3 +96,8 @@ for d in "${D}"lib* "${D}"usr/lib* ; do
done
fi
+
+if type -p chflags &>/dev/null && type -p mtree &>/dev/null; then
+ # Restore all the file flags that were saved at the beginning of prepall.
+ mtree -U -e -p "${D}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
+fi
diff --git a/pym/portage.py b/pym/portage.py
index 2862db7cc..81de2e182 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -3010,8 +3010,9 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
if phase_retval == os.EX_OK:
# Post phase logic and tasks that have been factored out of
# ebuild.sh.
- myargs = [MISC_SH_BINARY, "preinst_mask", "preinst_sfperms",
- "preinst_selinux_labels", "preinst_suid_scan"]
+ myargs = [MISC_SH_BINARY, "preinst_bsdflags", "preinst_mask",
+ "preinst_sfperms", "preinst_selinux_labels",
+ "preinst_suid_scan"]
phase_retval = spawn(" ".join(myargs),
mysettings, debug=debug, free=1, logfile=logfile)
if phase_retval != os.EX_OK:
@@ -3019,7 +3020,21 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
noiselevel=-1)
del mysettings["IMAGE"]
return phase_retval
- elif mydo in ["prerm","postrm","postinst","config"]:
+ elif mydo == "postinst":
+ mysettings.load_infodir(mysettings["O"])
+ phase_retval = spawn(" ".join((EBUILD_SH_BINARY, mydo)),
+ mysettings, debug=debug, free=1, logfile=logfile)
+ if phase_retval == os.EX_OK:
+ # Post phase logic and tasks that have been factored out of
+ # ebuild.sh.
+ myargs = [MISC_SH_BINARY, "postinst_bsdflags"]
+ phase_retval = spawn(" ".join(myargs),
+ mysettings, debug=debug, free=1, logfile=logfile)
+ if phase_retval != os.EX_OK:
+ writemsg("!!! post postinst failed; exiting.\n",
+ noiselevel=-1)
+ return phase_retval
+ elif mydo in ["prerm","postrm","config"]:
mysettings.load_infodir(mysettings["O"])
return spawn(EBUILD_SH_BINARY + " " + mydo,
mysettings, debug=debug, free=1, logfile=logfile)
@@ -3238,13 +3253,6 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
try:
if not sstat:
sstat=os.lstat(src)
- if bsd_chflags:
- sflags=bsd_chflags.lgetflags(src)
- if sflags < 0:
- # Problem getting flags...
- writemsg("!!! Couldn't get flags for "+dest+"\n",
- noiselevel=-1)
- return None
except SystemExit, e:
raise
@@ -3265,7 +3273,7 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
if bsd_chflags:
# Check that we can actually unset schg etc flags...
# Clear the flags on source and destination; we'll reinstate them after merging
- if destexists and sflags != 0:
+ if destexists and dstat.st_flags != 0:
if bsd_chflags.lchflags(dest, 0) < 0:
writemsg("!!! Couldn't clear flags on file being merged: \n ",
noiselevel=-1)
@@ -3274,10 +3282,8 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
if pflags != 0:
bsd_chflags.lchflags(os.path.dirname(dest), 0)
- # Don't bother checking the return value here; if it fails then the next line will catch it.
- bsd_chflags.lchflags(src, 0)
-
- if bsd_chflags.lhasproblems(src)>0 or (destexists and bsd_chflags.lhasproblems(dest)>0) or bsd_chflags.lhasproblems(os.path.dirname(dest))>0:
+ if (destexists and bsd_chflags.lhasproblems(dest) > 0) or \
+ bsd_chflags.lhasproblems(os.path.dirname(dest)) > 0:
# This is bad: we can't merge the file with these flags set.
writemsg("!!! Can't merge file "+dest+" because of flags set\n",
noiselevel=-1)
@@ -3307,14 +3313,6 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
else:
os.symlink(target,dest)
lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
- if bsd_chflags:
- # Restore the flags we saved before moving
- if (sflags != 0 and bsd_chflags.lchflags(dest, sflags) < 0) or \
- (pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0):
- writemsg("!!! Couldn't restore flags ("+str(flags)+") on " + dest+":\n",
- noiselevel=-1)
- writemsg("!!! %s\n" % str(e), noiselevel=-1)
- return None
return os.lstat(dest)[stat.ST_MTIME]
except SystemExit, e:
raise
@@ -3393,10 +3391,9 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
if bsd_chflags:
# Restore the flags we saved before moving
- if (sflags != 0 and bsd_chflags.lchflags(dest, sflags) < 0) or \
- (pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0):
- writemsg("!!! Couldn't restore flags ("+str(sflags)+") on " + dest+":\n",
- noiselevel=-1)
+ if pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
+ writemsg("!!! Couldn't restore flags (%s) on '%s'\n" % \
+ (str(pflags), os.path.dirname(dest)), noiselevel=-1)
return None
return newmtime
@@ -6729,8 +6726,6 @@ class dblink:
else:
os.mkdir(mydest)
os.chmod(mydest,mystat[0])
- if bsd_chflags:
- bsd_chflags.lchflags(mydest, bsd_chflags.lgetflags(mysrc))
os.chown(mydest,mystat[4],mystat[5])
writemsg_stdout(">>> %s/\n" % mydest)
outfile.write("dir "+myrealdest+"\n")