From f37bac791acecf764df101f14c5692d2ff0a3b4f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 7 Dec 2008 00:20:43 +0000 Subject: [PATCH] =?utf8?q?If=20pkg=5Fnofetch=20needs=20to=20be=20spawned?= =?utf8?q?=20inside=20fetch()=20and=20it=20happens=20that=20PORTAGE=5FBUIL?= =?utf8?q?DDIR=20doesn't=20exist,=20like=20when=20called=20by=20digestgen(?= =?utf8?q?),=20use=20mkdtemp=20to=20create=20a=20private=20temporary=20dir?= =?utf8?q?ectory=20so=20that=20pkg=5Fnofetch=20can=20be=20spawned=20(direc?= =?utf8?q?tory=20needed=20to=20satisfy=20safe=20$PWD=20requirement=20of=20?= =?utf8?q?bug=20#239560).=20This=20is=20more=20user=20friendly=20since=20b?= =?utf8?q?efore=20the=20pkg=5Fnofetch=20phase=20would=20simply=20be=20skip?= =?utf8?q?ped=20in=20this=20case.=20Thanks=20to=20Petteri=20R=C3=A4ty=20=20for=20reporting.=20(trunk=20r12174)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/main/branches/2.1.6/; revision=12175 --- pym/portage/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 70f4423dd..9c2b13f0a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -4121,6 +4121,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 @@ -4145,6 +4172,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 -- 2.26.2