Add a --rebuilt-binaries[=n] option, causing automatic replacement of
authorZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 20:26:08 +0000 (20:26 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 20:26:08 +0000 (20:26 -0000)
installed packages with binary packages that have been rebuilt. Rebuilds
are detected by comparison of BUILD_TIME package metadata. This option is
enabled automatically when using binary packages, so rebuilt binaries are
installed with a user's typical update command. This isn't possible with
the existing @rebuild-binaries package set since that only works with
--selective=n and therefore can't be used with a typical world update.
The package set framework should support this type of behavior sometime
in the future. (trunk r15364)

svn path=/main/branches/2.1.7/; revision=15591

man/emerge.1
pym/_emerge/depgraph.py
pym/_emerge/help.py
pym/_emerge/main.py

index c8fcfa7bd7e770cb9e70b758979a49805036a468..b0ea2d8d38d1833292de376731f2d7f94364c997 100644 (file)
@@ -470,6 +470,13 @@ output from portage's displays.
 Redirect all build output to logs alone, and do not
 display it on stdout.
 .TP
+.BR "\-\-rebuilt\-binaries[=n]"
+Replace installed packages with binary packages that have
+been rebuilt. Rebuilds are detected by comparison of
+BUILD_TIME package metadata. This option is enabled
+automatically when using binary packages (see
+\fB\-\-usepkg\fR and \fB\-\-getbinpkg\fR).
+.TP
 .BR "\-\-reinstall changed\-use"
 Tells emerge to include installed packages where USE flags have
 changed since installation.  Unlike \fB\-\-newuse\fR, this option does
index c53abb87a89d179a50f5f566404582cff8f29a52..d297986ab30cfe0a298da3b949e15f134d07ec1e 100644 (file)
@@ -2396,6 +2396,9 @@ class depgraph(object):
                atom_set = InternalPackageSet(initial_atoms=(atom,))
                existing_node = None
                myeb = None
+               usepkg = "--usepkg" in self._frozen_config.myopts
+               rebuilt_binaries = usepkg and \
+                       self._frozen_config.myopts.get('--rebuilt-binaries') != 'n'
                usepkgonly = "--usepkgonly" in self._frozen_config.myopts
                empty = "empty" in self._dynamic_config.myparams
                selective = "selective" in self._dynamic_config.myparams
@@ -2615,10 +2618,26 @@ class depgraph(object):
                                        if pkg.cp == cp]
                                break
 
+               if existing_node is not None and \
+                       existing_node in matched_packages:
+                       return existing_node, existing_node
+
                if len(matched_packages) > 1:
+                       if rebuilt_binaries:
+                               inst_pkg = None
+                               built_pkg = None
+                               for pkg in matched_packages:
+                                       if pkg.installed:
+                                               inst_pkg = pkg
+                                       elif pkg.built:
+                                               built_pkg = pkg
+                               if built_pkg is not None and inst_pkg is not None:
+                                       if built_pkg >= inst_pkg and \
+                                               built_pkg.metadata['BUILD_TIME'] != \
+                                               inst_pkg.metadata['BUILD_TIME']:
+                                               return built_pkg, built_pkg
+
                        if avoid_update:
-                               if existing_node is not None:
-                                       return existing_node, existing_node
                                for pkg in matched_packages:
                                        if pkg.installed:
                                                return pkg, existing_node
index d61f090bec7a8b771d73ddbd05002dc5e4537fe3..64f3e1d523c0ed13a40fde60c461f8bddd596e1e 100644 (file)
@@ -503,6 +503,15 @@ def help(myopts, havecolor=1):
                for line in wrap(desc, desc_width):
                        print(desc_indent + line)
                print()
+               print("       "+green("--rebuilt-binaries[=n]"))
+               desc = "Replace installed packages with binary packages that have " + \
+                       "been rebuilt. Rebuilds are detected by comparison of " + \
+                       "BUILD_TIME package metadata. This option is enabled " + \
+                       "automatically when using binary packages (see " + \
+                       "--usepkg and --getbinpkg)."
+               for line in wrap(desc, desc_width):
+                       print(desc_indent + line)
+               print()
                print("       "+green("--reinstall ") + turquoise("changed-use"))
                print("              Tells emerge to include installed packages where USE flags have")
                print("              changed since installation.  Unlike --newuse, this option does")
index b7cc8f7cc8d3f81f6fd409cde0bbb7191edd740c..7d1c2c7e223e2e0ea9c823dc541719c1d17697f7 100644 (file)
@@ -317,6 +317,7 @@ def insert_optional_args(args):
                '--getbinpkgonly'        : ('n',),
                '--jobs'       : valid_integers,
                '--keep-going'           : ('n',),
+               '--rebuilt-binaries'     : ('n',),
                '--root-deps'  : ('rdeps',),
                '--select'               : ('n',),
                '--selective'            : ('n',),
@@ -542,6 +543,13 @@ def parse_opts(tmpcmdline, silent=False):
                        "choices"  : ("True", "n")
                },
 
+               "--rebuilt-binaries": {
+                       "help"     : "replace installed packages with binary " + \
+                                    "packages that have been rebuilt",
+                       "type"     : "choice",
+                       "choices"  : ("True", "n")
+               },
+
                "--root": {
                 "help"   : "specify the target root filesystem for merging packages",
                 "action" : "store"
@@ -654,6 +662,10 @@ def parse_opts(tmpcmdline, silent=False):
        else:
                myoptions.keep_going = None
 
+       if myoptions.rebuilt_binaries in ("True",):
+               # The depgraph will enable this by default unless 'n' is specified.
+               myoptions.rebuilt_binaries = None
+
        if myoptions.root_deps == "True":
                myoptions.root_deps = True