summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-07 00:19:15 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-07 00:19:15 +0000
commit3da8bd8d5fda0cf2c89aab8e2dc1203fd25f08d4 (patch)
tree54209ae0cf4892379c375291d7ba76904ce12479
parent705edaea05e96aa54d3c0a9bb68ae881b6bfc53c (diff)
downloadportage-3da8bd8d5fda0cf2c89aab8e2dc1203fd25f08d4.tar.gz
portage-3da8bd8d5fda0cf2c89aab8e2dc1203fd25f08d4.tar.bz2
portage-3da8bd8d5fda0cf2c89aab8e2dc1203fd25f08d4.zip
If pkg_nofetch needs to be spawned inside fetch() and it happens that
PORTAGE_BUILDDIR doesn't exist, like when called by digestgen(), use mkdtemp to create a private temporary directory so that pkg_nofetch can be spawned (directory needed to satisfy safe $PWD requirement of bug #239560). This is more user friendly since before the pkg_nofetch phase would simply be skipped in this case. Thanks to Petteri Räty <betelgeuse@g.o> for reporting. svn path=/main/trunk/; revision=12174
-rw-r--r--pym/portage/__init__.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index c101635dc..aabed8283 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -4131,6 +4131,33 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
level=logging.ERROR, noiselevel=-1)
have_builddir = "PORTAGE_BUILDDIR" in mysettings and \
os.path.isdir(mysettings["PORTAGE_BUILDDIR"])
+
+ global_tmpdir = mysettings["PORTAGE_TMPDIR"]
+ private_tmpdir = None
+ if not parallel_fetchonly and not have_builddir:
+ # When called by digestgen(), it's normal that
+ # PORTAGE_BUILDDIR doesn't exist. It's helpful
+ # to show the pkg_nofetch output though, so go
+ # ahead and create a temporary PORTAGE_BUILDDIR.
+ # Use a temporary config instance to avoid altering
+ # the state of the one that's been passed in.
+ mysettings = config(clone=mysettings)
+ from tempfile import mkdtemp
+ try:
+ private_tmpdir = mkdtemp("", "._portage_fetch_.",
+ global_tmpdir)
+ except OSError, e:
+ if e.errno != portage.exception.PermissionDenied.errno:
+ raise
+ raise portage.exception.PermissionDenied(global_tmpdir)
+ mysettings["PORTAGE_TMPDIR"] = private_tmpdir
+ mysettings.backup_changes("PORTAGE_TMPDIR")
+ debug = mysettings.get("PORTAGE_DEBUG") == "1"
+ portage.doebuild_environment(mysettings["EBUILD"], "fetch",
+ mysettings["ROOT"], mysettings, debug, 1, None)
+ prepare_build_dirs(mysettings["ROOT"], mysettings, 0)
+ have_builddir = True
+
if not parallel_fetchonly and have_builddir:
# To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
# ensuring sane $PWD (bug #239560) and storing elog
@@ -4155,6 +4182,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
mysettings.pop("EBUILD_PHASE", None)
else:
mysettings["EBUILD_PHASE"] = ebuild_phase
+ if private_tmpdir is not None:
+ shutil.rmtree(private_tmpdir)
elif restrict_fetch:
pass