__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"
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):
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")
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
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
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
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)
# 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