From ba15970518da61624538b648d0cd85dc164d4874 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Tue, 16 Dec 2008 18:29:15 +0000 Subject: [PATCH] Merged from trunk -r12200:12248 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit | 12201 | Make BinpkgFetcher synchronize the local timestamp of the | | zmedico | downloaded file with the remote file, if the fetcher hasn't | | | done it automatically. | | 12202 | Fix exit code to return non-zero when an error occurs. | | zmedico | Thanks to Christoph Mende for reporting. | | 12204 | Remove stray part about 'link level dependency awareness' in | | zmedico | the 2.1.6 section and remove extraneous line 8. Thanks to | | | Arun Raghavan for reporting. | | 12205 | Add --sync support for `git pull`, and also add a failsafe | | zmedico | to prevent rsync from being called if $PORTDIR appears to be | | | under revision control. Thanks to Daniel Robbins for the | | | initial patch. | | 12206 | Don't warn about missing repo_name for $PORTDIR when it | | zmedico | happens to be empty. | | 12207 | Fix --getbinpkgonly behavior so that binaries from the | | zmedico | remote server are preferred over local packages if they are | | | not identical. Thanks to Lance Albertson for | | | reporting. | | 12208 | Fix old-style binhost code binarytree.digestCheck() will use | | zmedico | local digests when a local package overrides a remote one. | | 12209 | When using the old binhost protocol, comparison with the | | zmedico | remote package isn't supported, so the local package is | | | always preferred even if --getbinpkgonly is enabled. | | | Simplify bintree.isremote() so it works the same way | | | regardless of which protocol is used. | | 12210 | Fix incorrect usage of trap (only remove on signal at a | | zmedico | time). | | 12211 | Fix breakage in stale metadata logic inside | | zmedico | binarytree._poplulate(). | | 12212 | Fix --getbinpkg to behave as expected with --pretend and | | zmedico | --fetchonly. | | 12213 | Fix --pretend logic in Binpkg some more. | | zmedico | | | 12214 | Add a new FEATURES=test-fail-continue value which causes | | zmedico | ebuild execution to continue after the test phase has | | | failed. Thanks to Diego Pettenò for the | | | suggestion. | | 12246 | Update comment about resume opts stored as dict starting | | zmedico | with 2.1.6_rc1. | | 12248 | Detect problems with arguments and return non-zero when | | zmedico | appropriate. | svn path=/main/branches/prefix/; revision=12255 --- NEWS | 3 - bin/dosed | 22 +++++++- bin/etc-update | 3 +- man/emerge.1 | 6 +- man/make.conf.5 | 6 ++ pym/_emerge/__init__.py | 104 +++++++++++++++++++++++++++++++---- pym/portage/__init__.py | 5 ++ pym/portage/dbapi/bintree.py | 61 ++++++++++++++++---- 8 files changed, 176 insertions(+), 34 deletions(-) diff --git a/NEWS b/NEWS index 2affc7f49..2e8942a37 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,6 @@ portage-2.2 * Add link level dependency awareness to emerge --depclean and --prune actions in order to protect against uninstallation of required libraries. - packages in the same way, and also drops any masked packages. * Add license visibility filtering (GLEP 23) * Add support for generic package sets (also see RELEASE-NOTES) @@ -17,8 +16,6 @@ portage-2.1.6 installed with portage. * Add PORTAGE_IONICE_COMMAND setting for make.conf which is called to adjust IO priority on portage and it's subprocesses. -* Add link level dependency awareness to emerge --depclean and --prune actions - in order to protect against uninstallation of required libraries. * Add emerge --jobs and --load-average options which specify behavior for building packages in parallel or for generating metadata in parallel with emerge --regen. diff --git a/bin/dosed b/bin/dosed index 951f581d7..e7686f97b 100755 --- a/bin/dosed +++ b/bin/dosed @@ -3,18 +3,34 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +if [[ $# -lt 1 ]] ; then + echo "!!! ${0##*/}: at least one argument needed" >&2 + exit 1 +fi + +ret=0 +file_found=0 mysed="s:${ED}::g" for x in "$@" ; do - y="${ED}${x}" + y=$ED${x#/} if [ -e "${y}" ] ; then if [ -f "${y}" ] ; then + file_found=1 sed -i -e "${mysed}" "${y}" else - echo "${y} is not a regular file!" - exit 1 + echo "${y} is not a regular file!" >&2 + false fi + ((ret+=$?)) else mysed="${x}" fi done + +if [ $file_found = 0 ] ; then + echo "!!! ${0##*/}: $y does not exist" 1>&2 + ((ret+=1)) +fi + +exit $ret diff --git a/bin/etc-update b/bin/etc-update index 0a0f829c3..4a8166b98 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -446,7 +446,8 @@ Please select from the menu above (-1 to exit, losing this merge): " } die() { - trap SIGTERM SIGINT + trap SIGTERM + trap SIGINT if [ "$2" -eq 0 ]; then echo "Exiting: ${1}" diff --git a/man/emerge.1 b/man/emerge.1 index 391ec0395..50c525f72 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -320,10 +320,8 @@ list. This option implies \fB\-k\fR. (Use \fB\-gK\fR for binary\-only merging.) .TP .BR "\-\-getbinpkgonly " (\fB\-G\fR) -This option is identical to \fB\-g\fR, as above, except it will not use ANY -information from the local machine. All binaries will be downloaded from the -remote server without consulting packages existing in the local packages -directory. +This option is identical to \fB\-g\fR, as above, except binaries from the +remote server are preferred over local packages if they are not identical. .TP .BR "\-\-ignore-default-opts" Causes \fIEMERGE_DEFAULT_OPTS\fR (see \fBmake.conf\fR(5)) to be ignored. diff --git a/man/make.conf.5 b/man/make.conf.5 index 159217f54..2f71dac1a 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -338,6 +338,12 @@ the package compiled properly. See \fItest\fR in \fBebuild\fR(1) and \fIsrc_test()\fR in \fBebuild\fR(5). This feature implies the "test" \fBUSE\fR flag. .TP +.B test\-fail\-continue +If "test" is enabled \fBFEATURES\fR and the test phase of an ebuild fails, +continue to execute the remaining phases as if the failure had not occurred. +Note that the test phase for a specific package may be disabled by masking +the "test" \fBUSE\fR flag in \fBpackage.use.mask\fR (see \fBportage\fR(5)). +.TP .B unmerge\-orphans If a file is not claimed by another package in the same slot and it is not protected by \fICONFIG_PROTECT\fR, unmerge it even if the modification time or diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index ba82bbd9f..815643d0a 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -2954,6 +2954,10 @@ class EbuildProcess(SpawnProcess): self.returncode = portage._doebuild_exit_status_check_and_log( self.settings, self.phase, self.returncode) + if self.phase == "test" and self.returncode != os.EX_OK and \ + "test-fail-continue" in self.settings.features: + self.returncode = os.EX_OK + portage._post_phase_userpriv_perms(self.settings) class EbuildPhase(CompositeTask): @@ -3211,7 +3215,7 @@ class Binpkg(CompositeTask): pkg = self.pkg pkg_count = self.pkg_count - if not self.opts.fetchonly: + if not (self.opts.pretend or self.opts.fetchonly): self._build_dir.lock() try: shutil.rmtree(self._build_dir.dir_path) @@ -3222,7 +3226,7 @@ class Binpkg(CompositeTask): portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1) fetcher = BinpkgFetcher(background=self.background, logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=self.pkg, - scheduler=self.scheduler) + pretend=self.opts.pretend, scheduler=self.scheduler) pkg_path = fetcher.pkg_path self._pkg_path = pkg_path @@ -3249,6 +3253,12 @@ class Binpkg(CompositeTask): self.wait() return + if self.opts.pretend: + self._current_task = None + self.returncode = os.EX_OK + self.wait() + return + verifier = None if self._verify: logfile = None @@ -3390,7 +3400,7 @@ class Binpkg(CompositeTask): self.wait() def _unlock_builddir(self): - if self.opts.fetchonly: + if self.opts.pretend or self.opts.fetchonly: return portage.elog.elog_process(self.pkg.cpv, self.settings) self._build_dir.unlock() @@ -3418,7 +3428,7 @@ class Binpkg(CompositeTask): class BinpkgFetcher(SpawnProcess): - __slots__ = ("pkg", + __slots__ = ("pkg", "pretend", "locked", "pkg_path", "_lock_obj") def __init__(self, **kwargs): @@ -3432,11 +3442,24 @@ class BinpkgFetcher(SpawnProcess): return pkg = self.pkg + pretend = self.pretend bintree = pkg.root_config.trees["bintree"] settings = bintree.settings use_locks = "distlocks" in settings.features pkg_path = self.pkg_path - resume = os.path.exists(pkg_path) + + if not pretend: + portage.util.ensure_dirs(os.path.dirname(pkg_path)) + if use_locks: + self.lock() + exists = os.path.exists(pkg_path) + resume = exists and os.path.basename(pkg_path) in bintree.invalids + if not (pretend or resume): + # Remove existing file or broken symlink. + try: + os.unlink(pkg_path) + except OSError: + pass # urljoin doesn't work correctly with # unrecognized protocols like sftp @@ -3450,6 +3473,12 @@ class BinpkgFetcher(SpawnProcess): uri = settings["PORTAGE_BINHOST"].rstrip("/") + \ "/" + pkg.pf + ".tbz2" + if pretend: + portage.writemsg_stdout("\n%s\n" % uri, noiselevel=-1) + self.returncode = os.EX_OK + self.wait() + return + protocol = urlparse.urlparse(uri)[0] fcmd_prefix = "FETCHCOMMAND" if resume: @@ -3468,10 +3497,6 @@ class BinpkgFetcher(SpawnProcess): fetch_args = [portage.util.varexpand(x, mydict=fcmd_vars) \ for x in shlex.split(fcmd)] - portage.util.ensure_dirs(os.path.dirname(pkg_path)) - if use_locks: - self.lock() - if self.fd_pipes is None: self.fd_pipes = {} fd_pipes = self.fd_pipes @@ -3489,6 +3514,30 @@ class BinpkgFetcher(SpawnProcess): def _set_returncode(self, wait_retval): SpawnProcess._set_returncode(self, wait_retval) + if self.returncode == os.EX_OK: + # If possible, update the mtime to match the remote package if + # the fetcher didn't already do it automatically. + bintree = self.pkg.root_config.trees["bintree"] + if bintree._remote_has_index: + remote_mtime = bintree._remotepkgs[self.pkg.cpv].get("MTIME") + if remote_mtime is not None: + try: + remote_mtime = float(remote_mtime) + except ValueError: + pass + else: + try: + local_mtime = os.stat(self.pkg_path).st_mtime + except OSError: + pass + else: + if remote_mtime != local_mtime: + try: + os.utime(self.pkg_path, + (remote_mtime, remote_mtime)) + except OSError: + pass + if self.locked: self.unlock() @@ -11754,14 +11803,41 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): noiselevel=-1, level=logging.ERROR) return 1 + vcs_dirs = frozenset([".git", ".svn", "CVS", ".hg"]) + vcs_dirs = vcs_dirs.intersection(os.listdir(myportdir)) + os.umask(0022) updatecache_flg = False if myaction == "metadata": print "skipping sync" updatecache_flg = True + elif ".git" in vcs_dirs: + # Update existing git repository, and ignore the syncuri. We are + # going to trust the user and assume that the user is in the branch + # that he/she wants updated. We'll let the user manage branches with + # git directly. + msg = ">>> Starting git pull in %s..." % myportdir + emergelog(xterm_titles, msg ) + writemsg_level(msg + "\n") + exitcode = portage.spawn("cd %s ; git pull" % \ + (portage._shell_quote(myportdir),), settings, free=1) + if exitcode != os.EX_OK: + msg = "!!! git pull error in %s." % myportdir + emergelog(xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return exitcode + msg = ">>> Git pull in %s successful" % myportdir + emergelog(xterm_titles, msg) + writemsg_level(msg + "\n") + return exitcode elif syncuri[:8]=="rsync://": + for vcs_dir in vcs_dirs: + writemsg_level(("!!! %s appears to be under revision " + \ + "control (contains %s).\n!!! Aborting rsync sync.\n") % \ + (myportdir, vcs_dir), level=logging.ERROR, noiselevel=-1) + return 1 if not os.path.exists(EPREFIX+"/usr/bin/rsync"): - print "!!! rsync does not exist, so rsync support is disabled." + print "!!! /usr/bin/rsync does not exist, so rsync support is disabled." print "!!! Type \"emerge net-misc/rsync\" to enable rsync support." sys.exit(1) mytimeout=180 @@ -13639,7 +13715,7 @@ def action_build(settings, trees, mtimedb, del mtimedb["resume"] mtimedb.commit() mtimedb["resume"]={} - # Stored as a dict starting with portage-2.2_rc7, and supported + # Stored as a dict starting with portage-2.1.6_rc1, and supported # by >=portage-2.1.3_rc8. Versions