Use cp -pR when copying from a disk image to preserve creation and modification times, etc. If user, group or mode are not specified, default to "root", "admin", and "o-w" respectively.

git-svn-id: http://munki.googlecode.com/svn/trunk@893 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2010-11-08 17:36:54 +00:00
parent 6334f35c6f
commit 486af91aa5
+17 -10
View File
@@ -342,7 +342,7 @@ def copyFromDMG(dmgpath, itemlist):
if retcode == 0:
munkicommon.display_status(
"Copying %s to %s" % (itemname, destpath))
retcode = subprocess.call(["/bin/cp", "-R",
retcode = subprocess.call(["/bin/cp", "-pR",
itempath, destpath])
if retcode:
munkicommon.display_error(
@@ -350,31 +350,38 @@ def copyFromDMG(dmgpath, itemlist):
(itempath, destpath))
destitem = os.path.join(destpath, itemname)
if (retcode == 0) and ('user' in item):
if retcode == 0:
# set owner
user = item.get('user', 'root')
munkicommon.display_detail(
"Setting owner for '%s' to '%s'" %
(destitem, item['user']))
cmd = ['/usr/sbin/chown', '-R', item['user'], destitem]
(destitem, user))
cmd = ['/usr/sbin/chown', '-R', user, destitem]
retcode = subprocess.call(cmd)
if retcode:
munkicommon.display_error("Error setting owner for %s" %
(destitem))
if (retcode == 0) and ('group' in item):
if retcode == 0:
# set group
group = item.get('group', 'admin')
munkicommon.display_detail(
"Setting group for '%s' to '%s'" %
(destitem, item['group']))
cmd = ['/usr/bin/chgrp', '-R', item['group'], destitem]
(destitem, group))
cmd = ['/usr/bin/chgrp', '-R', group, destitem]
retcode = subprocess.call(cmd)
if retcode:
munkicommon.display_error("Error setting group for %s" %
(destitem))
if (retcode == 0) and ('mode' in item):
if retcode == 0:
# set mode
mode = item.get('mode', 'o-w')
munkicommon.display_detail(
"Setting mode for '%s' to '%s'" %
(destitem, item['mode']))
cmd = ['/bin/chmod', '-R', item['mode'], destitem]
(destitem, mode))
cmd = ['/bin/chmod', '-R', mode, destitem]
retcode = subprocess.call(cmd)
if retcode:
munkicommon.display_error("Error setting mode for %s" %