17653 zone install fails with pkg.oracle.com/solaris/support set oi_151a
authorTim Foster <tim.s.foster@oracle.com>
Wed, 12 Jan 2011 12:15:37 +1300
branchoi_151a
changeset 2543 b1a6b0e4c685
parent 2542 db209abace67
child 2544 de7a6cc1db78
17653 zone install fails with pkg.oracle.com/solaris/support set 17680 image creation should preserve ssl directory if it already exists 17681 image-create warning about -f not specific enough 17683 pkgcreatezone does a chown/chmod on the wrong path
src/brand/pkgcreatezone
src/client.py
src/man/pkg.1.txt
src/modules/client/image.py
src/pkg/manifests/package%2Fpkg.p5m
src/tests/cli/t_pkg_image_create.py
--- a/src/brand/pkgcreatezone	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/brand/pkgcreatezone	Wed Jan 12 12:15:37 2011 +1300
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 
 #
@@ -344,8 +344,8 @@
 	printf "$m_cert_prop\n" $(basename $certfile)
 	mkdir -p -m 755 $ZONEROOT/$KEYDIR || fail_fatal "$f_cert_prop"
 	cp $certfile $ZONEROOT/$newcertlocation || fail_fatal "$f_cert_prop"
-	chmod 644 $ZONEROOT/$newkeylocation
-	chown -h root:root $ZONEROOT/$newkeylocation
+	chmod 644 $ZONEROOT/$newcertlocation
+	chown -h root:root $ZONEROOT/$newcertlocation
 fi
 
 #
--- a/src/client.py	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/client.py	Wed Jan 12 12:15:37 2011 +1300
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 
 #
@@ -3838,7 +3838,7 @@
                 progtrack = get_tracker()
                 api_inst = api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION,
                     image_dir, imgtype, is_zone, facets=facets, force=force,
-                    mirrors=add_mirrors, origins=add_origins, prefix=pub_name,
+                    mirrors=list(add_mirrors), origins=list(add_origins), prefix=pub_name,
                     progtrack=progtrack, refresh_allowed=refresh_allowed,
                     ssl_cert=ssl_cert, ssl_key=ssl_key, repo_uri=repo_uri,
                     variants=variants, props=set_props)
--- a/src/man/pkg.1.txt	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/man/pkg.1.txt	Wed Jan 12 12:15:37 2011 +1300
@@ -162,7 +162,9 @@
           the -z (--zone) option can be used to set an appropriate filter.
 
           With -f (--force), force the creation of an image over an existing
-          image.  This option should be used with care.
+          image.  This option should be used with care; any existing image
+          metadata found will be lost (such as cached packages) except for
+          SSL certificates and keys used by the client.
 
           With --no-refresh, do not attempt to contact the repositories for
           the image's publishers to retrieve publisher metadata (e.g.
--- a/src/modules/client/image.py	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/modules/client/image.py	Wed Jan 12 12:15:37 2011 +1300
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 
 import atexit
@@ -568,6 +568,10 @@
                 # one, any old data is removed first.
                 if purge and os.path.exists(self.imgdir):
                         for entry in os.listdir(self.imgdir):
+                                if entry == "ssl":
+                                        # Preserve certs and keys directory
+                                        # as a special exception.
+                                        continue
                                 epath = os.path.join(self.imgdir, entry)
                                 try:
                                         if os.path.isdir(epath):
--- a/src/pkg/manifests/package%2Fpkg.p5m	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/pkg/manifests/package%2Fpkg.p5m	Wed Jan 12 12:15:37 2011 +1300
@@ -18,13 +18,16 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 
 set name=pkg.fmri value=pkg:/package/pkg@$(PKGVERS)
 set name=pkg.summary value="Image Packaging System"
 set name=pkg.description value="The Image Packaging System (IPS), or pkg(5), is the software delivery system used on OpenSolaris systems.  This package contains the core command-line components and depot server."
 set name=info.classification value=org.opensolaris.category.2008:System/Packaging
+set name=com.oracle.service.bugid \
+    last-fmri=package/[email protected],5.11-0.151.0.1:20101104T233545Z \
+    value=7011132 value=7011649 value=7011650 value=7011651
 set name=opensolaris.smf.fmri value=svc:/application/pkg/server:default value=svc:/application/pkg/dynamic-mirror:default
 set name=variant.arch value=$(ARCH)
 
--- a/src/tests/cli/t_pkg_image_create.py	Fri Feb 10 16:47:15 2012 +0000
+++ b/src/tests/cli/t_pkg_image_create.py	Wed Jan 12 12:15:37 2011 +1300
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 
 import testutils
@@ -33,6 +33,7 @@
 import pkg.portable
 import pkg.catalog
 import pkg.client.image as image
+import pkg.misc as misc
 import shutil
 import unittest
 
@@ -114,7 +115,7 @@
                         f.write("V pkg:/%s@%s\n" % (stem, ver))
                 f.close()
 
-        def test_3588(self):
+        def test_force(self):
                 """Ensure that image creation works as expected when an image
                 already exists."""
 
@@ -144,6 +145,22 @@
                     exit=1)
                 self.pkg("image-create -f -p test1=%s %s" % (self.rurl1, p))
 
+                # Bug 17680: Ensure ssl directory is preserved if it
+                # already exists when creating an image where one
+                # might already exist with the -f (force) flag.
+                shutil.rmtree(self.get_img_path())
+                self.pkg("image-create -p test1=%s %s" % (self.rurl1,
+                    self.get_img_path()))
+
+                img = self.get_img_api_obj().img
+                cert_path = os.path.join(img.imgdir, "ssl", "cert.file")
+                misc.makedirs(os.path.dirname(cert_path))
+                open(cert_path, "wb").close()
+                assert os.path.exists(cert_path)
+                self.pkg("image-create -f -p test1=%s %s" % (self.rurl1,
+                    self.get_img_path()))
+                assert os.path.exists(cert_path)
+
         def __verify_pub_cfg(self, img_path, prefix, pub_cfg):
                 """Private helper method to verify publisher configuration."""