From 85e3299b684ca9e25c7e0e7c25981a7e255c42f0 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Mon, 26 Dec 2005 06:29:50 +0000 Subject: 'DISTFILES indirection; access $BUILDDIR/distdir instead of $DISTFILES , thus blocking unstated access. svn path=/main/trunk/; revision=2474 --- NEWS | 3 ++- bin/ebuild.sh | 3 +++ pym/portage.py | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fe6a4073f..ef6ad80da 100644 --- a/NEWS +++ b/NEWS @@ -24,4 +24,5 @@ portage-2.1 (ongoing via pre releases) * Allow packages to be upgraded that are only depended on via a "|| ( =cat/pkg-1* =cat/pkg-2* )" construct. * Ebuild output is no longer cut off early when using PORT_LOGDIR. - +* Distfiles indirection- $DISTFILES access goes through a tmp dir to fail + access to files not listed in SRC_URI. diff --git a/bin/ebuild.sh b/bin/ebuild.sh index bf785ae7a..5ea8f92a6 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -702,6 +702,9 @@ dyn_clean() { if [ -z "$(find "${BUILDDIR}" -mindepth 1 -maxdepth 1)" ]; then rmdir "${BUILDDIR}" fi + # do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll + # result in it wiping the users distfiles directory (bad). + rm -rf "${BUILDDIR}/distdir" true } diff --git a/pym/portage.py b/pym/portage.py index 9129aa494..0711a9472 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2570,6 +2570,7 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea os.chmod(mysettings["BUILD_PREFIX"],00775) # Should be ok again to set $T, as sandbox does not depend on it + # XXX Bug. no way in hell this is valid for clean handling. mysettings["T"]=mysettings["BUILDDIR"]+"/temp" if cleanup or mydo=="clean": if os.path.exists(mysettings["T"]): @@ -2791,6 +2792,31 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea not fetch(fetchme, mysettings, listonly=listonly, fetchonly=fetchonly): return 1 + # inefficient. improve this logic via making actionmap easily searchable to see if we're in the chain of what + # will be executed, either that or forced N doebuild calls instead of a single set of phase calls. + if (mydo not in ("setup", "clean", "postinst", "preinst", "prerm") and "noauto" not in features) or \ + mydo == "unpack": + orig_distdir = mysettings["DISTDIR"] + edpath = mysettings["DISTDIR"] = os.path.join(mysettings["BUILDDIR"], "distdir") + if os.path.exists(edpath): + try: + if os.path.isdir(edpath) and not os.path.islink(edpath): + shutil.rmtree(edpath) + else: + os.unlink(edpath) + except OSError: + print "!!! Failed reseting ebuild distdir path, " + edpath + raise + os.mkdir(edpath) + os.chown(edpath, -1, portage_gid) + os.chmod(edpath, 0775) + try: + for file in aalist: + os.symlink(os.path.join(orig_distdir, file), os.path.join(edpath, file)) + except OSError: + print "!!! Failed symlinking in '%s' to ebuild distdir" % file + raise + if mydo=="fetch" and listonly: return 0 -- cgit v1.2.3-1-g7c22