7133915 pkg update leaves out some needed packages
7152298 pkg verify -v should indicate when preserved files have been modified or overlaid
7161790 zoneadm installs adds package with only global zone variant
--- a/src/modules/actions/file.py Mon Apr 16 14:50:29 2012 -0700
+++ b/src/modules/actions/file.py Tue May 01 08:41:22 2012 -0700
@@ -305,7 +305,8 @@
"expected": int(self.attrs["pkg.size"]) })
if "preserve" in self.attrs:
- return errors, warnings, info
+ if args["verbose"] == False or lstat is None:
+ return errors, warnings, info
if args["forever"] != True:
return errors, warnings, info
@@ -350,7 +351,11 @@
hashvalue, data = misc.get_data_digest(path)
if hashvalue != self.hash:
# Prefer the content hash error message.
- if elferror:
+ if "preserve" in self.attrs:
+ info.append(_(
+ "editable file has"
+ " been changed"))
+ elif elferror:
errors.append(elferror)
else:
errors.append(_("Hash: "
--- a/src/modules/client/pkg_solver.py Mon Apr 16 14:50:29 2012 -0700
+++ b/src/modules/client/pkg_solver.py Tue May 01 08:41:22 2012 -0700
@@ -296,10 +296,19 @@
self.__publisher[name] = \
proposed_dict[name][0].publisher
+
+ # figure out fmris to be removed from image
+ # we may have installed wrong variants by
+ # mistake due to dependencies; remove them quietly
+
self.__removal_fmris |= set([
self.__installed_dict[name]
for name in reject_set
if name in self.__installed_dict
+ ] + [
+ f
+ for f in self.__installed_fmris
+ if not self.__trim_nonmatching_variants(f)
])
# remove packages to be installed from avoid_set
@@ -437,14 +446,15 @@
possible_set.update(self.__generate_dependency_closure(
possible_set, excludes=excludes))
- # remove any possibles that must be excluded because of
- # origin and parent dependencies
- for f in possible_set.copy():
- if not self.__trim_nonmatching_origins(f, excludes):
- possible_set.remove(f)
- elif not self.__trim_nonmatching_parents(f, excludes):
- possible_set.remove(f)
+ # trim any non-matching variants, origins or parents
+ for f in possible_set:
+ if self.__trim_nonmatching_parents(f, excludes):
+ if self.__trim_nonmatching_variants(f):
+ self.__trim_nonmatching_origins(f,
+ excludes)
+ # remove all trimmed fmris from consideration
+ possible_set.difference_update(self.__trim_dict.iterkeys())
# remove any versions from proposed_dict that are in trim_dict
# as trim dict has been updated w/ missing dependencies
self.__timeit("phase 8")
@@ -649,10 +659,18 @@
self.__progtrack.evaluate_progress()
self.__timeit()
+ # figure out fmris to be removed from image
+ # we may have installed wrong variants by
+ # mistake due to dependencies; remove them quietly
+
self.__removal_fmris = frozenset([
self.__installed_dict[name]
for name in reject_set
if name in self.__installed_dict
+ ] + [
+ f
+ for f in self.__installed_fmris
+ if not self.__trim_nonmatching_variants(f)
])
self.__reject_set = reject_set
@@ -698,13 +716,15 @@
possible_set.update(self.__generate_dependency_closure(
possible_set, excludes=excludes))
- # remove any possibles that must be excluded because of
- # origin and parent dependencies
- for f in possible_set.copy():
- if not self.__trim_nonmatching_origins(f, excludes):
- possible_set.remove(f)
- elif not self.__trim_nonmatching_parents(f, excludes):
- possible_set.remove(f)
+ # trim any non-matching origins or parents
+ for f in possible_set:
+ if self.__trim_nonmatching_parents(f, excludes):
+ if self.__trim_nonmatching_variants(f):
+ self.__trim_nonmatching_origins(f,
+ excludes)
+
+ # remove all trimmed fmris from consideration
+ possible_set.difference_update(self.__trim_dict.iterkeys())
self.__timeit("phase 3")
@@ -1982,6 +2002,7 @@
def __trim_nonmatching_variants(self, fmri):
vd = self.__get_variant_dict(fmri)
+ reason = ""
for v in self.__variants.keys():
if v in vd and self.__variants[v] not in vd[v]:
@@ -1991,6 +2012,7 @@
reason = (N_("Package doesn't support image variant {0}"), (v,))
self.__trim(fmri, reason)
+ return reason == ""
def __trim_nonmatching_parents1(self, pkg_fmri, fmri):
if fmri in self.__parent_pkgs:
--- a/src/tests/cli/t_pkg_verify.py Mon Apr 16 14:50:29 2012 -0700
+++ b/src/tests/cli/t_pkg_verify.py Tue May 01 08:41:22 2012 -0700
@@ -179,6 +179,20 @@
self.pkg("install foo")
self.pkg("verify _not_valid no/such/package foo", exit=1)
+ def test_03_editable(self):
+ """When editable files are changed, verify should treat these specially"""
+ # check that verify is silent on about modified editable files
+ self.image_create(self.rurl)
+ self.pkg("install foo")
+ fd = file(os.path.join(self.get_img_path(), "etc", "preserved"), "w+")
+ fd.write("Bobcats are here")
+ fd.close()
+ self.pkg("verify foo")
+ assert(self.output == "")
+ # find out about it via -v
+ self.pkg("verify -v foo")
+ self.output.index("etc/preserved")
+ self.output.index("editable file has been changed")
if __name__ == "__main__":
unittest.main()
--- a/src/tests/cli/t_variants.py Mon Apr 16 14:50:29 2012 -0700
+++ b/src/tests/cli/t_variants.py Tue May 01 08:41:22 2012 -0700
@@ -48,7 +48,7 @@
add file tmp/bronze_zone/etc/sparc_global mode=0555 owner=root group=bin path=etc/zone_arch variant.arch=sparc variant.opensolaris.zone=global
add file tmp/bronze_zone/etc/i386_global mode=0555 owner=root group=bin path=etc/zone_arch variant.arch=i386 variant.opensolaris.zone=global
add file tmp/bronze_zone/etc/zos_global mode=0555 owner=root group=bin path=etc/zone_arch variant.arch=zos variant.opensolaris.zone=global
- add file tmp/bronze_zone/false mode=0555 owner=root group=bin path=etc/isdebug variant.debug.kernel=false
+ add file tmp/bronze_zone/false mode=0555 owner=root group=bin path=etc/isdebug variant.debug.kernel=false
add file tmp/bronze_zone/true mode=0555 owner=root group=bin path=etc/isdebug variant.debug.kernel=true
close"""
@@ -75,7 +75,17 @@
add set name=variant.mumble value=false
close"""
- misc_files = [
+ i386_pkg = """
+ open [email protected],5.11-0
+ add set name=variant.arch value=i386
+ close"""
+
+ i386_pkg_indirect = """
+ open [email protected],5.11-0
+ add depend type=require fmri=pkg:/[email protected],5.11-0
+ close"""
+
+ misc_files = [
"tmp/bronze_sparc/etc/motd",
"tmp/bronze_i386/etc/motd",
"tmp/bronze_zos/etc/motd",
@@ -126,6 +136,23 @@
self.pkg("info [email protected]", exit=1)
self.pkg("info [email protected]")
+ def test_variant_4_indirect(self):
+ """Verify that we can't indirectly install a package tagged
+ with a variant that doesn't match ours."""
+
+ self.pkgsend_bulk(self.rurl, self.i386_pkg)
+ self.pkgsend_bulk(self.rurl, self.i386_pkg_indirect)
+
+ self.image_create(self.rurl,
+ variants={ "variant.arch": "sparc" })
+
+ # we should not be able to install an i386 package directly
+ self.pkg("install i386_pkg", exit=1)
+
+ # we should not be able to install an i386 package indirectly
+ self.pkg("install i386_pkg_indirect", exit=1)
+
+
def test_old_zones_pkgs(self):
self.__test_common("variant.opensolaris.zone",
"opensolaris.zone")
@@ -141,7 +168,7 @@
self.__vtest(self.rurl, "i386", "nonglobal", "false")
self.__vtest(self.rurl, "zos", "nonglobal", "false")
- self.pkg_image_create(self.rurl,
+ self.pkg_image_create(self.rurl,
additional_args="--variant variant.arch=%s" % "sparc")
self.pkg("install silver", exit=1)
@@ -154,7 +181,7 @@
do_isdebug = ""
is_debug = "false"
- self.pkg_image_create(depot,
+ self.pkg_image_create(depot,
additional_args="--variant variant.arch=%s --variant variant.opensolaris.zone=%s %s" % (
arch, zone, do_isdebug))
self.pkg("install bronze")