• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Problems with hdiutil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Problems with hdiutil


  • Subject: RE: Problems with hdiutil
  • From: "David Litwin" <email@hidden>
  • Date: Fri, 4 Aug 2006 12:05:53 -0700
  • Thread-topic: Problems with hdiutil

Thanks for the pointer on the workaround.  Creating as a sized sparse image instead of UDRW allows it to work correctly.  It’s a bit more work, but as long as it works I’ll be satisfied.

 

In case anyone is interested, here is how I would edit the script I sent out previously (to demonstrate the UDRW conversion bug) to work.  Note that creating a sparse image will append .sparseimage to the name unless it already has that extension, and the –size field can be a minimum of 512k.

 

David Litwin

BigFix, Inc.

 

#!/bin/sh

 

echo "Create the source ImageDir"

mkdir ImageDir

echo "This welcome text will *not* get wiped out when we use a sparse image" > ImageDir/Flim.txt

echo

 

echo "Calculate the size of the source dir in kilobytes"

usageLine=`du -s ImageDir`

imageSize=`expr "$usageLine" : '\([0123456789]*\)[ ]*[^ ]*$'`

# sparse images have a minimum size of 512k

if [ `expr $imageSize \< 512` ]; then

    echo "ImageDir size is ${imageSize}k, using minimum of 512k"

    imageSize=512

else

    echo "ImageDir size is ${imageSize}k"

fi

echo

 

echo "Create the sparse image"

echo hdiutil create -volname "hdiutil-bug" -layout NONE -fs 'HFS+' -type "SPARSE" -size ${imageSize}k -ov "Writable.dmg.sparseimage"

hdiutil create -volname "hdiutil-bug" -layout NONE -fs 'HFS+' -type "SPARSE" -size ${imageSize}k -ov "Writable.dmg.sparseimage"

echo

 

echo "Mount the sparse image and copy in files"

mountLine=`hdiutil attach "Writable.dmg.sparseimage" | tail -n 1`

disk=`expr "$mountLine" : '\([^ ]*\).*$'`

volLoc=`expr "$mountLine" : '[^ ]*[^\/]*\(.*\)$'`

cd ImageDir

tar cf - * | (cd "$volLoc" ; tar xfBp -)

cd ..

hdiutil detach -force "$disk"

echo

 

echo "Create the compressed read only image from the writable sparse image"

echo hdiutil convert "Writable.dmg.sparseimage" -format UDZO -o "Compressed.dmg" -ov -imagekey zlib-level=9

hdiutil convert "Writable.dmg.sparseimage" -format UDZO -o "Compressed.dmg" -ov -imagekey zlib-level=9

echo

 

echo "Mount and check the contents of the sparse image"

mountLine=`hdiutil attach "Writable.dmg.sparseimage" | tail -n 1`

disk=`expr "$mountLine" : '\([^ ]*\).*$'`

volLoc=`expr "$mountLine" : '[^ ]*[^\/]*\(.*\)$'`

hexdump -C "$volLoc/Flim.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/Flim.txt"

hdiutil detach -force "$disk"

echo

 

 

 


From: Michael Nickerson [mailto:email@hidden]
Sent: Tuesday, August 01, 2006 4:28 PM
To: David Litwin
Cc: email@hidden Users
Subject: Re: Problems with hdiutil

 

 

On Aug 1, 2006, at 3:01 PM, David Litwin wrote:



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.

 

Hey David, I tried out your script.  It looks like a bug with hdiutil.  If you add -size with a value to the create line, it'll work out correctly.  I guess it's not correctly setting the size and creating an invalid dmg file.  I wasn't able to mount the Writable.dmg file created by your script by double-clicking on it - it comes up with an error dialog when I try.

 

If you're just using that script on the command line, I suppose you could add in a portion to ask for the size.  Otherwise, I'm not entirely sure how you'd get the correct size value to use with it.

 

 

Darkshadow

(aka Michael Nickerson)

 

 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Problems with hdiutil (From: Michael Nickerson <email@hidden>)

  • Prev by Date: Re: adding new group
  • Next by Date: Xcode operations aren't synchronous (was: Re: crashes after changing signatures of virtual functions / virtual inherited classes)
  • Previous by thread: Re: Problems with hdiutil
  • Next by thread: Re: Problems with hdiutil
  • Index(es):
    • Date
    • Thread