--- a/src/modules/actions/directory.py Tue Mar 10 15:29:46 2015 -0700
+++ b/src/modules/actions/directory.py Thu Mar 12 11:17:36 2015 -0700
@@ -71,12 +71,12 @@
def directory_references(self):
return [os.path.normpath(self.attrs["path"])]
- def __create_directory(self, pkgplan, path, mode):
+ def __create_directory(self, pkgplan, path, mode, **kwargs):
"""Create a directory."""
try:
self.makedirs(path, mode=mode,
- fmri=pkgplan.destination_fmri)
+ fmri=pkgplan.destination_fmri, **kwargs)
except OSError as e:
if e.filename != path:
# makedirs failed for some component
@@ -201,7 +201,10 @@
except OSError as e:
if e.errno != errno.EPERM and \
e.errno != errno.ENOSYS:
- raise
+ # Assume chown failed due to a
+ # recoverable error.
+ self.__create_directory(pkgplan, path,
+ mode, uid=owner, gid=group)
def verify(self, img, **args):
"""Returns a tuple of lists of the form (errors, warnings,
@@ -231,7 +234,7 @@
elif e.errno == errno.EBUSY and os.path.ismount(path):
# User has replaced directory with mountpoint,
# or a package has been poorly implemented.
- if not self.attrs.get("implicit"):
+ if not self.attrs.get("implicit"):
err_txt = _("Unable to remove {0}; it is "
"in use as a mountpoint. To "
"continue, please unmount the "
@@ -245,7 +248,7 @@
# os.path.ismount() is broken for lofs
# filesystems, so give a more generic
# error.
- if not self.attrs.get("implicit"):
+ if not self.attrs.get("implicit"):
err_txt = _("Unable to remove {0}; it "
"is in use by the system, another "
"process, or as a "
--- a/src/tests/cli/t_pkg_install.py Tue Mar 10 15:29:46 2015 -0700
+++ b/src/tests/cli/t_pkg_install.py Thu Mar 12 11:17:36 2015 -0700
@@ -2702,6 +2702,13 @@
close
"""
+ dumdir30 = """
+ open [email protected]
+ add dir path=etc mode=0700 owner=bin group=bin
+ add file tmp/amber1 mode=0400 owner=root group=bin path=etc/amber1
+ close
+ """
+
misc_files1 = [
"tmp/amber1", "tmp/amber2", "tmp/bronzeA1", "tmp/bronzeA2",
"tmp/bronze1", "tmp/bronze2",
@@ -3086,7 +3093,8 @@
"""Test manually removed directory and files will be restored
during update, if mode are different."""
- self.pkgsend_bulk(self.rurl, (self.dumdir10, self.dumdir20))
+ self.pkgsend_bulk(self.rurl, (self.dumdir10, self.dumdir20,
+ self.dumdir30))
self.image_create(self.rurl)
self.pkg("install -vvv [email protected]")
@@ -3096,6 +3104,10 @@
self.pkg("update -vvv [email protected]")
self.pkg("verify -v")
+ shutil.rmtree(dirpath)
+
+ self.pkg("update -vvv [email protected]")
+ self.pkg("verify -v")
def test_upgrade_liveroot(self):
"""Test to make sure upgrade of package fails if on live root