Merged from trunk 6590:6592
authorFabian Groffen <grobian@gentoo.org>
Wed, 23 May 2007 17:25:08 +0000 (17:25 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 23 May 2007 17:25:08 +0000 (17:25 -0000)
   +------------------------------------------------------------------------+
   | 6590    | Save memory by not holding a reference to the PackageIndex   |
   | zmedico | when it's not being used.                                    |
   |---------+--------------------------------------------------------------|
   | 6591    | Pass a temporary file name to the package phase in the       |
   | zmedico | environment variable PORTAGE_BINPKG_TMPFILE and move the     |
   |         | temporary file into place inside binarytree.inject(). This   |
   |         | allows binarytree.inject() to perform the move while holding |
   |         | a lock.                                                      |
   |---------+--------------------------------------------------------------|
   | 6592    | Add a 'ignore-previously-merged' config option which gives   |
   | zmedico | similar behavior to the --noconfmem emerge option.           |
   +------------------------------------------------------------------------+

svn path=/main/branches/prefix/; revision=6598

bin/dispatch-conf
bin/misc-functions.sh
cnf/dispatch-conf.conf
pym/emerge/__init__.py
pym/portage/dbapi/bintree.py

index ea4c0ecd2cdc4bafa8cf0f1d3953829b8de45db0..c0b5c0138deb11953d9a6daf75443d3f99cc2cfa 100755 (executable)
@@ -140,18 +140,26 @@ class dispatch:
                        else:
                                newconf = conf['new']
 
-                       mystatus, myoutput = commands.getstatusoutput(
-                               DIFF_CONTENTS  % (conf ['current'], newconf))
-                       same_file = 0 == len(myoutput)
-                       if mystatus >> 8 == 2:
-                               # Binary files differ
-                               same_cvs = False
-                               same_wsc = False
-                       else:
-                               same_cvs = 0 == len(commands.getoutput(
-                                       DIFF_CVS_INTERP % (conf ['current'], newconf)))
-                               same_wsc = 0 == len(commands.getoutput(
-                                       DIFF_WSCOMMENTS % (conf ['current'], newconf)))
+            if newconf == mrgconf and \
+                self.options.get('ignore-previously-merged') != 'yes' and \
+                len(commands.getoutput(DIFF_CONTENTS % (conf['current'], mrgconf))) == 0:
+                # The current update is identical to the archived .dist
+                # version that has previously been merged.
+                os.unlink(mrgconf)
+                newconf = conf['new']
+
+            mystatus, myoutput = commands.getstatusoutput(
+                DIFF_CONTENTS  % (conf ['current'], newconf))
+            same_file = 0 == len(myoutput)
+            if mystatus >> 8 == 2:
+                # Binary files differ
+                same_cvs = False
+                same_wsc = False
+            else:
+                same_cvs = 0 == len(commands.getoutput(
+                    DIFF_CVS_INTERP % (conf ['current'], newconf)))
+                same_wsc = 0 == len(commands.getoutput(
+                    DIFF_WSCOMMENTS % (conf ['current'], newconf)))
 
                        # Do options permit?
                        same_cvs = same_cvs and self.options['replace-cvs'] == 'yes'
index 84ee893605e5c0681a25e5877b2107669d364554..6d1865c75e69cb505d7652f4698042acc126d139 100644 (file)
@@ -549,32 +549,21 @@ preinst_selinux_labels() {
 dyn_package() {
        cd "${PORTAGE_BUILDDIR}/image"
        install_mask "${PORTAGE_BUILDDIR}/image" ${PKG_INSTALL_MASK}
-       if [ -d "${PKGDIR}/All" ] ; then
-               local pkg_dest="${PKGDIR}/All/${PF}.tbz2"
-       else
-               local pkg_dest="${PKGDIR}/${CATEGORY}/${PF}.tbz2"
-       fi
-       local pkg_tmp="${pkg_dest}.$$"
        local tar_options=""
        [ "${PORTAGE_QUIET}" == "1" ] ||  tar_options="${tar_options} -v"
        # Sandbox is disabled in case the user wants to use a symlink
        # for $PKGDIR and/or $PKGDIR/All.
        export SANDBOX_ON="0"
-       mkdir -p "${pkg_tmp%/*}" || die "mkdir failed"
-       tar ${tar_options} -cf - . | bzip2 -f > "${pkg_tmp}" || \
+       mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed"
+       tar ${tar_options} -cf - . | bzip2 -f > "${PORTAGE_BINPKG_TMPFILE}" || \
                die "Failed to create tarball"
        cd ..
        export PYTHONPATH=${PORTAGE_PYM_PATH:-${EPREFIX}/usr/lib/portage/pym}
-       python -c "from portage import xpak; t=xpak.tbz2('${pkg_tmp}'); t.recompose('${PORTAGE_BUILDDIR}/build-info')"
+       python -c "from portage import xpak; t=xpak.tbz2('${PORTAGE_BINPKG_TMPFILE}'); t.recompose('${PORTAGE_BUILDDIR}/build-info')"
        if [ $? -ne 0 ]; then
-               rm -f "${pkg_tmp}"
+               rm -f "${PORTAGE_BINPKG_TMPFILE}"
                die "Failed to append metadata to the tbz2 file"
        fi
-       mv -f "${pkg_tmp}" "${pkg_dest}" || die "Failed to move tbz2 to ${pkg_dest}"
-       if [ -d "${PKGDIR}/All" ] ; then
-               ln -sf "../All/${PF}.tbz2" "${PKGDIR}/${CATEGORY}/${PF}.tbz2" || \
-                       die "Failed to create symlink in ${PKGDIR}/${CATEGORY}"
-       fi
        vecho ">>> Done."
        cd "${PORTAGE_BUILDDIR}"
        touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}"
index 4b9ec2c7bd54c971602a0e5605b6838340bdf73d..5a1a39a722a0fd6be7b4d7e6d7239af25e39015c 100644 (file)
@@ -32,6 +32,11 @@ replace-wscomments=no
 # (yes or no)
 replace-unmodified=no
 
+# Ignore a version that is identical to the previously merged version,
+# even though it is different from the current user modified version
+# (yes or no)
+ignore-previously-merged=yes
+
 # Per-session log file of changes made to configuration files
 #log-file=/var/log/dispatch-conf.log
 
index e1cfac2e8bb404d6b7eb386f5879a3d79c2c7a39..8466135b15867ca46ef0d354fad2cef923cb6873 100644 (file)
@@ -3158,13 +3158,18 @@ class MergeTask(object):
                                                        (mergecount, len(mymergelist), pkg_key)
                                                emergelog(xterm_titles, msg, short_msg=short_msg)
                                                self.trees[myroot]["bintree"].prevent_collision(pkg_key)
+                                               binpkg_tmpfile = os.path.join(pkgsettings["PKGDIR"],
+                                                       pkg_key + ".tbz2." + str(os.getpid()))
+                                               pkgsettings["PORTAGE_BINPKG_TMPFILE"] = binpkg_tmpfile
+                                               pkgsettings.backup_changes("PORTAGE_BINPKG_TMPFILE")
                                                retval = portage.doebuild(y, "package", myroot,
                                                        pkgsettings, self.edebug, mydbapi=portdb,
                                                        tree="porttree")
+                                               del pkgsettings["PORTAGE_BINPKG_TMPFILE"]
                                                if retval != os.EX_OK:
                                                        return retval
                                                bintree = self.trees[myroot]["bintree"]
-                                               bintree.inject(pkg_key)
+                                               bintree.inject(pkg_key, filename=binpkg_tmpfile)
                                                if "--buildpkgonly" not in self.myopts:
                                                        msg = " === (%s of %s) Merging (%s::%s)" % \
                                                                (mergecount, len(mymergelist), pkg_key, y)
index dda35ce652c557fee91aa7bf79c2ad9adc6b2ea5..fcceb5e0ddbf0d6f5ff05a21e339ef1f696fdeb3 100644 (file)
@@ -557,16 +557,32 @@ class binarytree(object):
                                        continue
                self.populated=1
 
-       def inject(self, cpv):
+       def inject(self, cpv, filename=None):
                """Add a freshly built package to the database.  This updates
-               $PKGDIR/Packages with the new package metadata (including MD5)."""
+               $PKGDIR/Packages with the new package metadata (including MD5).
+               @param cpv: The cpv of the new package to inject
+               @type cpv: string
+               @param filename: File path of the package to inject, or None if it's
+                       already in the location returned by getname()
+               @type filename: string
+               @rtype: None
+               """
+               mycat, mypkg = catsplit(cpv)
                if not self.populated and self._all_directory:
+                       if filename is not None:
+                               # In order to avoid population, don't call getname() here.
+                               os.rename(filename, os.path.join(
+                                       self.pkgdir, "All", mypkg + ".tbz2"))
+                       self._create_symlink(cpv)
                        # There's nothing to update in this case, since the Packages
                        # index is not created when $PKGDIR/All/ exists.
                        return
                if not self.populated:
                        self.populate()
-               full_path = self.getname(cpv)
+               if filename is None:
+                       full_path = self.getname(cpv)
+               else:
+                       full_path = filename
                try:
                        s = os.stat(full_path)
                except OSError, e:
@@ -589,6 +605,9 @@ class binarytree(object):
                self.dbapi._aux_cache.pop(cpv, None)
 
                if self._all_directory:
+                       if filename is not None:
+                               os.rename(filename, self.getname(cpv))
+                       self._create_symlink(cpv)
                        return
 
                # Reread the Packages index (in case it's been changed by another
@@ -598,6 +617,8 @@ class binarytree(object):
                try:
                        pkgindex_lock = lockfile(self._pkgindex_file,
                                wantnewlockfile=1)
+                       if filename is not None:
+                               os.rename(filename, self.getname(cpv))
                        pkgindex = portage.getbinpkg.PackageIndex()
                        try:
                                f = open(self._pkgindex_file)