Replace --rebuild option with --rebuild-if-* options.
--rebuild-if-new-rev [ y | n ]
Rebuild packages when dependencies that are used at both build-time and
run-time are built, if the dependency is not already installed with the
same version and revision.
--rebuild-if-new-ver [ y | n ]
Rebuild packages when dependencies that are used at both build-time and
run-time are built, if the dependency is not already installed with the
same version. Revision numbers are ignored.
--rebuild-if-unbuilt [ y | n ]
Rebuild packages when dependencies that are used at both build-time and
run-time are built.
Change-Id: Ia50c1702bfe1b98a8d1891740e7bbb045921a905
Review URL: http://gerrit.chromium.org/gerrit/280
to be set in the \fBmake.conf\fR(5)
\fBEMERGE_DEFAULT_OPTS\fR variable.
.TP
-.BR "\-\-rebuild [ y | n ]"
+.BR "\-\-rebuild\-if\-new\-rev [ y | n ]"
Rebuild packages when dependencies that are used at both build\-time and
-run\-time are upgraded.
+run\-time are built, if the dependency is not already installed with the
+same version and revision.
+.TP
+.BR "\-\-rebuild\-if\-new\-ver [ y | n ]"
+Rebuild packages when dependencies that are used at both build\-time and
+run\-time are built, if the dependency is not already installed with the
+same version. Revision numbers are ignored.
+.TP
+.BR "\-\-rebuild\-if\-unbuilt [ y | n ]"
+Rebuild packages when dependencies that are used at both build\-time and
+run\-time are built.
.TP
.BR "\-\-rebuilt\-binaries [ y | n ]"
Replace installed packages with binary packages that have
deep = myopts.get("--deep")
if deep is not None and deep != 0:
myparams["deep"] = deep
- if "--complete-graph" in myopts or "--rebuild" in myopts:
+ if ("--complete-graph" in myopts or "--rebuild-if-new-rev" in myopts or
+ "--rebuild-if-new-ver" in myopts or "--rebuild-if-unbuilt" in myopts):
myparams["complete"] = True
if "--emptytree" in myopts:
myparams["empty"] = True
from portage.util import cmp_sort_key, writemsg, writemsg_stdout
from portage.util import writemsg_level
from portage.util.digraph import digraph
+from portage.versions import catpkgsplit
from _emerge.AtomArg import AtomArg
from _emerge.Blocker import Blocker
atoms = ' '.join(myopts.get("--rebuild-ignore", [])).split()
self.rebuild_ignore = _wildcard_set(atoms)
- self.rebuild = "--rebuild" in myopts
+ self.rebuild_if_new_rev = "--rebuild-if-new-rev" in myopts
+ self.rebuild_if_new_ver = "--rebuild-if-new-ver" in myopts
+ self.rebuild_if_unbuilt = "--rebuild-if-unbuilt" in myopts
class _depgraph_sets(object):
def __init__(self):
self.rebuild_list = backtrack_parameters.rebuild_list.copy()
self.orig_rebuild_list = self.rebuild_list.copy()
self.reinstall_list = backtrack_parameters.reinstall_list.copy()
+ self.rebuild_if_new_rev = frozen_config.rebuild_if_new_rev
+ self.rebuild_if_new_ver = frozen_config.rebuild_if_new_ver
+ self.rebuild_if_unbuilt = frozen_config.rebuild_if_unbuilt
+ self.rebuild = (self.rebuild_if_new_rev or self.rebuild_if_new_ver or
+ self.rebuild_if_unbuilt)
def add(self, dep_pkg, dep):
parent = dep.collapsed_parent
priority = dep.collapsed_priority
rebuild_exclude = self._frozen_config.rebuild_exclude
rebuild_ignore = self._frozen_config.rebuild_ignore
- if (self._frozen_config.rebuild and isinstance(parent, Package) and
+ if (self.rebuild and isinstance(parent, Package) and
parent.built and (priority.buildtime or priority.runtime) and
isinstance(dep_pkg, Package) and
not rebuild_exclude.findAtomForPackage(parent) and
not rebuild_ignore.findAtomForPackage(dep_pkg)):
self._graph.add(dep_pkg, parent, priority)
+ def _needs_rebuild(self, dep_pkg):
+ """Check whether packages that depend on dep_pkg need to be rebuilt."""
+ dep_root_slot = (dep_pkg.root, dep_pkg.slot_atom)
+ if dep_pkg.built or dep_root_slot in self.orig_rebuild_list:
+ return False
+
+ if self.rebuild_if_unbuilt:
+ # dep_pkg is being installed from source, so binary
+ # packages for parents are invalid. Force rebuild
+ return True
+
+ trees = self._frozen_config.trees
+ vardb = trees[dep_pkg.root]["vartree"].dbapi
+ if self.rebuild_if_new_rev:
+ # Parent packages are valid if a package with the same
+ # cpv is already installed.
+ return dep_pkg.cpv not in vardb.match(dep_pkg.slot_atom)
+
+ # Otherwise, parent packages are valid if a package with the same
+ # version (excluding revision) is already installed.
+ assert self.rebuild_if_new_ver
+ cpv_norev = catpkgsplit(dep_pkg.cpv)[:-1]
+ for inst_cpv in vardb.match(dep_pkg.slot_atom):
+ inst_cpv_norev = catpkgsplit(inst_cpv)[:-1]
+ if inst_cpv_norev == cpv_norev:
+ return False
+
+ return True
+
def _trigger_rebuild(self, parent, build_deps, runtime_deps):
root_slot = (parent.root, parent.slot_atom)
if root_slot in self.rebuild_list:
kids = set([build_deps[slot_atom], runtime_deps[slot_atom]])
for dep_pkg in kids:
dep_root_slot = (dep_pkg.root, slot_atom)
- if (not dep_pkg.built and
- dep_root_slot not in self.orig_rebuild_list):
- # There's no binary package for dep_pkg, so any binary
- # package for this parent would be invalid. Force rebuild.
+ if self._needs_rebuild(dep_pkg):
self.rebuild_list.add(root_slot)
return True
elif ("--usepkg" in self._frozen_config.myopts and
uri = bintree.get_pkgindex_uri(parent.cpv)
dep_uri = bintree.get_pkgindex_uri(dep_pkg.cpv)
bindb = bintree.dbapi
-
+ if self.rebuild_if_new_ver and uri and uri != dep_uri:
+ cpv_norev = catpkgsplit(dep_pkg.cpv)[:-1]
+ for cpv in bindb.match(dep_pkg.slot_atom):
+ if cpv_norev == catpkgsplit(cpv)[:-1]:
+ dep_uri = bintree.get_pkgindex_uri(cpv)
+ if uri == dep_uri:
+ break
if uri and uri != dep_uri:
# 1) Remote binary package is invalid because it was
# built without dep_pkg. Force rebuild.
for line in wrap(desc, desc_width):
print(desc_indent + line)
print()
- print(" " + green("--rebuild") + " [ %s | %s ]" % \
+ print(" " + green("--rebuild-if-new-rev") + " [ %s | %s ]" % \
(turquoise("y"), turquoise("n")))
- desc = "Rebuild packages when dependencies that are used " + \
- "at both build-time and run-time are upgraded."
+ desc = "Rebuild packages when dependencies that are " + \
+ "used at both build-time and run-time are built, " + \
+ "if the dependency is not already installed with the " + \
+ "same version and revision."
+ for line in wrap(desc, desc_width):
+ print(desc_indent + line)
+ print()
+ print(" " + green("--rebuild-if-new-ver") + " [ %s | %s ]" % \
+ (turquoise("y"), turquoise("n")))
+ desc = "Rebuild packages when dependencies that are " + \
+ "used at both build-time and run-time are built, " + \
+ "if the dependency is not already installed with the " + \
+ "same version. Revision numbers are ignored."
+ for line in wrap(desc, desc_width):
+ print(desc_indent + line)
+ print()
+ print(" " + green("--rebuild-if-unbuilt") + " [ %s | %s ]" % \
+ (turquoise("y"), turquoise("n")))
+ desc = "Rebuild packages when dependencies that are " + \
+ "used at both build-time and run-time are built."
for line in wrap(desc, desc_width):
print(desc_indent + line)
print()
'--package-moves' : y_or_n,
'--quiet' : y_or_n,
'--quiet-build' : y_or_n,
- '--rebuild' : y_or_n,
+ '--rebuild-if-new-rev' : y_or_n,
+ '--rebuild-if-new-ver' : y_or_n,
+ '--rebuild-if-unbuilt' : y_or_n,
'--rebuilt-binaries' : y_or_n,
'--root-deps' : ('rdeps',),
'--select' : y_or_n,
"choices" : true_y_or_n
},
- "--rebuild": {
+ "--rebuild-if-new-rev": {
"help" : "Rebuild packages when dependencies that are " + \
- "used at both build-time and run-time are upgraded.",
+ "used at both build-time and run-time are built, " + \
+ "if the dependency is not already installed with the " + \
+ "same version and revision.",
+ "type" : "choice",
+ "choices" : true_y_or_n
+ },
+
+ "--rebuild-if-new-ver": {
+ "help" : "Rebuild packages when dependencies that are " + \
+ "used at both build-time and run-time are built, " + \
+ "if the dependency is not already installed with the " + \
+ "same version. Revision numbers are ignored.",
+ "type" : "choice",
+ "choices" : true_y_or_n
+ },
+
+ "--rebuild-if-unbuilt": {
+ "help" : "Rebuild packages when dependencies that are " + \
+ "used at both build-time and run-time are built.",
"type" : "choice",
"choices" : true_y_or_n
},
else:
myoptions.binpkg_respect_use = None
- if myoptions.complete_graph in true_y or myoptions.rebuild in true_y:
+ if myoptions.complete_graph in true_y:
myoptions.complete_graph = True
else:
myoptions.complete_graph = None
else:
myoptions.quiet_build = None
- if myoptions.rebuild in true_y:
- myoptions.rebuild = True
+ if myoptions.rebuild_if_new_ver in true_y:
+ myoptions.rebuild_if_new_ver = True
+ else:
+ myoptions.rebuild_if_new_ver = None
+
+ if myoptions.rebuild_if_new_rev in true_y:
+ myoptions.rebuild_if_new_rev = True
+ myoptions.rebuild_if_new_ver = None
+ else:
+ myoptions.rebuild_if_new_rev = None
+
+ if myoptions.rebuild_if_unbuilt in true_y:
+ myoptions.rebuild_if_unbuilt = True
+ myoptions.rebuild_if_new_rev = None
+ myoptions.rebuild_if_new_ver = None
else:
- myoptions.rebuild = None
+ myoptions.rebuild_if_unbuilt = None
if myoptions.rebuilt_binaries in true_y:
myoptions.rebuilt_binaries = True
ebuilds = {
"sys-libs/x-1": { },
+ "sys-libs/x-1-r1": { },
"sys-libs/x-2": { },
"sys-apps/a-1": { "DEPEND" : "sys-libs/x", "RDEPEND" : "sys-libs/x"},
"sys-apps/a-2": { "DEPEND" : "sys-libs/x", "RDEPEND" : "sys-libs/x"},
test_cases = (
ResolverPlaygroundTestCase(
["sys-libs/x"],
- options = {"--rebuild" : True,
+ options = {"--rebuild-if-unbuilt" : True,
"--rebuild-exclude" : ["sys-apps/b"]},
mergelist = ['sys-libs/x-2', 'sys-apps/a-2', 'sys-apps/e-2'],
ignore_mergelist_order = True,
ResolverPlaygroundTestCase(
["sys-libs/x"],
- options = {"--rebuild" : True},
+ options = {"--rebuild-if-unbuilt" : True},
mergelist = ['sys-libs/x-2', 'sys-apps/a-2', 'sys-apps/b-2',
'sys-apps/e-2', 'sys-apps/g-2'],
ignore_mergelist_order = True,
ResolverPlaygroundTestCase(
["sys-libs/x"],
- options = {"--rebuild" : True,
+ options = {"--rebuild-if-unbuilt" : True,
"--rebuild-ignore" : ["sys-libs/x"]},
mergelist = ['sys-libs/x-2'],
ignore_mergelist_order = True,
ResolverPlaygroundTestCase(
["sys-libs/x"],
- options = {"--rebuild" : True,
+ options = {"--rebuild-if-unbuilt" : True,
"--rebuild-ignore" : ["sys-apps/b"]},
mergelist = ['sys-libs/x-2', 'sys-apps/a-2', 'sys-apps/b-2',
'sys-apps/e-2'],
ignore_mergelist_order = True,
success = True),
+ ResolverPlaygroundTestCase(
+ ["=sys-libs/x-1-r1"],
+ options = {"--rebuild-if-unbuilt" : True},
+ mergelist = ['sys-libs/x-1-r1', 'sys-apps/a-2',
+ 'sys-apps/b-2', 'sys-apps/e-2', 'sys-apps/g-2'],
+ ignore_mergelist_order = True,
+ success = True),
+
+ ResolverPlaygroundTestCase(
+ ["=sys-libs/x-1-r1"],
+ options = {"--rebuild-if-new-rev" : True},
+ mergelist = ['sys-libs/x-1-r1', 'sys-apps/a-2',
+ 'sys-apps/b-2', 'sys-apps/e-2', 'sys-apps/g-2'],
+ ignore_mergelist_order = True,
+ success = True),
+
+ ResolverPlaygroundTestCase(
+ ["=sys-libs/x-1-r1"],
+ options = {"--rebuild-if-new-ver" : True},
+ mergelist = ['sys-libs/x-1-r1'],
+ ignore_mergelist_order = True,
+ success = True),
+
+ ResolverPlaygroundTestCase(
+ ["sys-libs/x"],
+ options = {"--rebuild-if-new-ver" : True},
+ mergelist = ['sys-libs/x-2', 'sys-apps/a-2',
+ 'sys-apps/b-2', 'sys-apps/e-2', 'sys-apps/g-2'],
+ ignore_mergelist_order = True,
+ success = True),
)
playground = ResolverPlayground(ebuilds=ebuilds,