summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py40
-rw-r--r--pym/portage/__init__.py33
2 files changed, 49 insertions, 24 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index adcd71509..49e94dbea 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1588,6 +1588,13 @@ class EbuildFetchPretend(SlotObject):
__slots__ = ("fetch_all", "pkg", "settings")
def execute(self):
+ # To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
+ # ensuring sane $PWD (bug #239560) and storing elog
+ # messages.
+ build_dir = EbuildBuildDir(pkg=self.pkg, settings=self.settings)
+ build_dir.lock()
+ build_dir.clean()
+ portage.prepare_build_dirs(self.pkg.root, self.settings, 0)
portdb = self.pkg.root_config.trees["porttree"].dbapi
ebuild_path = portdb.findname(self.pkg.cpv)
debug = self.settings.get("PORTAGE_DEBUG") == "1"
@@ -1596,6 +1603,10 @@ class EbuildFetchPretend(SlotObject):
self.settings["ROOT"], self.settings, debug=debug,
listonly=1, fetchonly=1, fetchall=self.fetch_all,
mydbapi=portdb, tree="porttree")
+
+ portage.elog.elog_process(self.pkg.cpv, self.settings)
+ build_dir.clean()
+ build_dir.unlock()
return retval
class AsynchronousTask(SlotObject):
@@ -2248,7 +2259,7 @@ class EbuildFetcher(SpawnProcess):
settings = self.config_pool.allocate()
self._build_dir = EbuildBuildDir(pkg=self.pkg, settings=settings)
self._build_dir.lock()
- self._clean_builddir()
+ self._build_dir.clean()
portage.prepare_build_dirs(self.pkg.root, self._build_dir.settings, 0)
if self.logfile is None:
self.logfile = settings.get("PORTAGE_LOG_FILE")
@@ -2291,18 +2302,6 @@ class EbuildFetcher(SpawnProcess):
portage._create_pty_or_pipe(copy_term_size=stdout_pipe)
return (master_fd, slave_fd)
- def _clean_builddir(self):
- """Uses shutil.rmtree() rather than spawning a 'clean' phase. Disabled
- by keepwork or keeptemp in FEATURES."""
- features = self._build_dir.settings.features
- if not ("keepwork" in features or "keeptemp" in features):
- try:
- shutil.rmtree(self._build_dir.settings["PORTAGE_BUILDDIR"])
- except EnvironmentError, e:
- if e.errno != errno.ENOENT:
- raise
- del e
-
def _set_returncode(self, wait_retval):
SpawnProcess._set_returncode(self, wait_retval)
# Collect elog messages that might have been
@@ -2322,7 +2321,7 @@ class EbuildFetcher(SpawnProcess):
portage.elog.elog_process(self.pkg.cpv, self._build_dir.settings)
features = self._build_dir.settings.features
if self.fetchonly or self.returncode == os.EX_OK:
- self._clean_builddir()
+ self._build_dir.clean()
self._build_dir.unlock()
self.config_pool.deallocate(self._build_dir.settings)
self._build_dir = None
@@ -2377,6 +2376,19 @@ class EbuildBuildDir(SlotObject):
if catdir_lock is not None:
portage.locks.unlockdir(catdir_lock)
+ def clean(self):
+ """Uses shutil.rmtree() rather than spawning a 'clean' phase. Disabled
+ by keepwork or keeptemp in FEATURES."""
+ settings = self.settings
+ features = settings.features
+ if not ("keepwork" in features or "keeptemp" in features):
+ try:
+ shutil.rmtree(settings["PORTAGE_BUILDDIR"])
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+
def unlock(self):
if self._lock_obj is None:
return
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index c171c1ce9..b44f8fa86 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -4060,29 +4060,43 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if listonly:
writemsg_stdout("\n", noiselevel=-1)
- elif fetched != 2:
+ if fetched != 2:
if restrict_fetch:
- print "\n!!!", mysettings["CATEGORY"] + "/" + \
- mysettings["PF"], "has fetch restriction turned on."
- print "!!! This probably means that this " + \
- "ebuild's files must be downloaded"
- print "!!! manually. See the comments in" + \
- " the ebuild for more information.\n"
+ msg = ("\n!!! %s/%s" + \
+ " has fetch restriction turned on.\n" + \
+ "!!! This probably means that this " + \
+ "ebuild's files must be downloaded\n" + \
+ "!!! manually. See the comments in" + \
+ " the ebuild for more information.\n\n") % \
+ (mysettings["CATEGORY"], mysettings["PF"])
+ portage.util.writemsg_level(msg,
+ level=logging.ERROR, noiselevel=-1)
if not parallel_fetchonly:
# To spawn pkg_nofetch requires PORTAGE_BUILDDIR for
# ensuring sane $PWD (bug #239560) and storing elog
# messages. Therefore, calling code needs to ensure that
# PORTAGE_BUILDDIR is already clean and locked here.
+
+ # All the pkg_nofetch goes to stderr since it's considered
+ # to be an error message.
+ fd_pipes = {
+ 0 : sys.stdin.fileno(),
+ 1 : sys.stderr.fileno(),
+ 2 : sys.stderr.fileno(),
+ }
+
ebuild_phase = mysettings.get("EBUILD_PHASE")
try:
mysettings["EBUILD_PHASE"] = "nofetch"
spawn(_shell_quote(EBUILD_SH_BINARY) + \
- " nofetch", mysettings)
+ " nofetch", mysettings, fd_pipes=fd_pipes)
finally:
if ebuild_phase is None:
mysettings.pop("EBUILD_PHASE", None)
else:
mysettings["EBUILD_PHASE"] = ebuild_phase
+ elif listonly:
+ continue
elif not filedict[myfile]:
writemsg("Warning: No mirrors available for file" + \
" '%s'\n" % (myfile), noiselevel=-1)
@@ -5436,8 +5450,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
# Build directory creation isn't required for any of these.
have_build_dirs = False
- if not (mydo in ("digest", "help", "manifest") or \
- (mydo == "fetch" and listonly)):
+ if not mydo in ("digest", "help", "manifest"):
mystatus = prepare_build_dirs(myroot, mysettings, cleanup)
if mystatus:
return mystatus