I can’t find any good list for questions about hdiutil,
so this is going to xcode-users because my use is related to project building.
I use hdiutil to create a disk image of my installer package. Because I
want to set the icon of the image, I create it writable (UDRW) so I can call
SetFile –a C on it.
After this, I use hdiutil to convert it to a compressed read
only image.
Before the conversion to read only compressed, everything in the image is
fine. After the conversion, I wind up in the odd situation that my
Welcome.txt file has been wiped out and replaced with 16 bytes of zeros.
No other file is touched.
I have now reproduced this problem with an image containing nothing but the Welcome.txt
file, on both a PPC and Intel machine. The source image (UDRW) is fine,
the dest image (UDZO, zlib-level=9) is corrupted.
Has anyone seen anything like this? It’s completely baffling.
If I can’t trust my disk image making tool, how can I put my code out
with any confidence?
David Litwin
BigFix, Inc.
P.S. If anyone is curious, here is a script (included
in my radar report #4662414) that demonstrates the bug on my PPC and Intel
machine. I’m curious if anyone else sees it:
#!/bin/sh
echo "Create the source
ImageDir"
mkdir ImageDir
echo "This welcome text
will get wiped out" > ImageDir/Welcome.txt
echo
echo "Create the
writable image"
echo hdiutil create
-srcfolder "ImageDir" -volname "hdiutil-bug" -format UDRW
-layout NONE -fs 'HFS+' -ov "Writable.dmg"
hdiutil create -srcfolder
"ImageDir" -volname "hdiutil-bug" -format UDRW -layout NONE
-fs 'HFS+' -ov "Writable.dmg"
echo
echo "Create the
compressed read only image from the writable image"
echo hdiutil convert
"Writable.dmg" -format UDZO -o "Compressed.dmg" -ov
-imagekey zlib-level=9
hdiutil convert
"Writable.dmg" -format UDZO -o "Compressed.dmg" -ov
-imagekey zlib-level=9
echo
echo "Mount and check
the contents of the Writable image"
mountLine=`hdiutil attach
"Writable.dmg" | tail -n 1`
disk=`expr
"$mountLine" : '\([^ ]*\).*$'`
volLoc=`expr
"$mountLine" : '[^ ]*[^\/]*\(.*\)$'`
hexdump -C
"$volLoc/Welcome.txt"
hdiutil detach -force
"$disk"
echo
echo "Mount and check
the contents of the compressed read only image"
mountLine=`hdiutil attach
"Compressed.dmg" | tail -n 1`
disk=`expr
"$mountLine" : '\([^ ]*\).*$'`
volLoc=`expr
"$mountLine" : '[^ ]*[^\/]*\(.*\)$'`
hexdump -C
"$volLoc/Welcome.txt"
hdiutil detach -force
"$disk"
echo