405704 Support "--format UDBZ" in pkg-dmg. r=mnyromyr a/1.9=dsicore

This commit is contained in:
mark@moxienet.com 2007-12-11 11:03:11 -08:00
Родитель fbf5db5dc1
Коммит 1975174417
1 изменённых файлов: 31 добавлений и 13 удалений

Просмотреть файл

@ -92,6 +92,8 @@ See B<--format>.
The format to create the disk image in. Valid values for I<format> are: The format to create the disk image in. Valid values for I<format> are:
- UDZO - zlib-compressed, read-only; extension I<.dmg> - UDZO - zlib-compressed, read-only; extension I<.dmg>
- UDBZ - bzip2-compressed, read-only; extension I<.dmg>;
create and use on 10.4 ("Tiger") and later only
- UDRW - read-write; extension I<.dmg> - UDRW - read-write; extension I<.dmg>
- UDSP - read-write, sparse; extension I<.sparseimage> - UDSP - read-write, sparse; extension I<.sparseimage>
@ -141,8 +143,8 @@ or to use formatted text, prepare a resource and use L<--resource>.
=item B<--resource> I<file> =item B<--resource> I<file>
A resource file to merge into I<target-image>. If I<format> is UDZO, A resource file to merge into I<target-image>. If I<format> is UDZO or
the disk image will be flattened to a single-fork file that contains UDBZ, the disk image will be flattened to a single-fork file that contains
the resource but may be freely transferred without any special encodings. the resource but may be freely transferred without any special encodings.
I<file> must be in a format suitable for L<Rez(1)>. See L<Rez(1)> for a I<file> must be in a format suitable for L<Rez(1)>. See L<Rez(1)> for a
description of the format, and L<hdiutil(1)> for a discussion on flattened description of the format, and L<hdiutil(1)> for a discussion on flattened
@ -273,6 +275,7 @@ sub commandVerbosity($@);
sub diskImageMaker($$$$$$$$); sub diskImageMaker($$$$$$$$);
sub giveExtension($$); sub giveExtension($$);
sub hdidMountImage($@); sub hdidMountImage($@);
sub isFormatCompressed($);
sub licenseMaker($$); sub licenseMaker($$);
sub pathSplit($); sub pathSplit($);
sub setAttributes($@); sub setAttributes($@);
@ -605,7 +608,7 @@ if(defined($iconFile)) {
# It's pointless to set the attributes of the root when diskutil create # It's pointless to set the attributes of the root when diskutil create
# -srcfolder is being used. In that case, the attributes will be set # -srcfolder is being used. In that case, the attributes will be set
# later, after the image is already created. # later, after the image is already created.
if($outputFormat eq 'UDZO' && if(isFormatCompressed($outputFormat) &&
(command($gConfig{'cmd_SetFile'}, '-a', 'C', $tempRoot) != 0)) { (command($gConfig{'cmd_SetFile'}, '-a', 'C', $tempRoot) != 0)) {
cleanupDie('SetFile failed'); cleanupDie('SetFile failed');
} }
@ -617,7 +620,7 @@ if(command($gConfig{'cmd_chmod'}, '-R', 'a+rX,a-st,u+w,go-w',
} }
my($unflattenable); my($unflattenable);
if($outputFormat eq 'UDZO') { if(isFormatCompressed($outputFormat)) {
$unflattenable = 1; $unflattenable = 1;
} }
else { else {
@ -865,7 +868,7 @@ sub diskImageMaker($$$$$$$$) {
$tempDir, $tempMount); $tempDir, $tempMount);
($source, $destination, $format, $name, $tempDir, $tempMount, ($source, $destination, $format, $name, $tempDir, $tempMount,
$baseName, $setRootIcon) = @_; $baseName, $setRootIcon) = @_;
if($format eq 'UDZO') { if(isFormatCompressed($format)) {
my($uncompressedImage); my($uncompressedImage);
if($gConfig{'makehybrid'}) { if($gConfig{'makehybrid'}) {
@ -942,10 +945,11 @@ sub diskImageMaker($$$$$$$$) {
} }
else { else {
# makehybrid is not available, fall back to making a UDRW and # makehybrid is not available, fall back to making a UDRW and
# converting to UDZO. It ought to be possible to do a UDZO directly, # converting to a compressed image. It ought to be possible to
# but those come out far too large (journaling?) and need to be # create a compressed image directly, but those come out far too
# read-write to fix up the volume icon anyway. Luckily, we can # large (journaling?) and need to be read-write to fix up the
# take advantage of a single call back into this function. # volume icon anyway. Luckily, we can take advantage of a single
# call back into this function.
my($udrwImage); my($udrwImage);
$udrwImage = giveExtension($tempDir.'/udrw', '.dmg'); $udrwImage = giveExtension($tempDir.'/udrw', '.dmg');
@ -960,8 +964,12 @@ sub diskImageMaker($$$$$$$$) {
# The uncompressed disk image is now in its final form. Compress it. # The uncompressed disk image is now in its final form. Compress it.
# Jaguar doesn't support hdiutil convert -ov, but it always allows # Jaguar doesn't support hdiutil convert -ov, but it always allows
# overwriting. # overwriting.
if(command($gConfig{'cmd_hdiutil'}, 'convert', '-format', 'UDZO', # bzip2-compressed UDBZ images can only be created and mounted on 10.4
'-imagekey', 'zlib-level=9', # and later. The bzip2-level imagekey is only effective when creating
# images in 10.5. In 10.4, bzip2-level is harmlessly ignored, and the
# default value of 1 is always used.
if(command($gConfig{'cmd_hdiutil'}, 'convert', '-format', $format,
'-imagekey', ($format eq 'UDBZ' ? 'bzip2-level=9' : 'zlib-level=9'),
(defined($gDarwinMajor) && $gDarwinMajor <= 6 ? () : ('-ov')), (defined($gDarwinMajor) && $gDarwinMajor <= 6 ? () : ('-ov')),
$uncompressedImage, '-o', $destination) != 0) { $uncompressedImage, '-o', $destination) != 0) {
cleanupDie('hdiutil convert failed'); cleanupDie('hdiutil convert failed');
@ -976,8 +984,8 @@ sub diskImageMaker($$$$$$$$) {
cleanupDie('unlink uncompressedImage failed: '.$!); cleanupDie('unlink uncompressedImage failed: '.$!);
} }
# At this point, the only thing that the UDZO block has added to the # At this point, the only thing that the compressed block has added to
# cleanup stack is the removal of $destination. $source has already # the cleanup stack is the removal of $destination. $source has already
# been removed, and its cleanup entry has been removed as well. # been removed, and its cleanup entry has been removed as well.
} }
elsif($format eq 'UDRW' || $format eq 'UDSP') { elsif($format eq 'UDRW' || $format eq 'UDSP') {
@ -1247,6 +1255,16 @@ sub hdidMountImage($@) {
return undef; return undef;
} }
# isFormatCompressed($format)
#
# Returns true if $format corresponds to a compressed disk image format.
# Returns false otherwise.
sub isFormatCompressed($) {
my($format);
($format) = @_;
return $format eq 'UDZO' || $format eq 'UDBZ';
}
# licenseMaker($text, $resource) # licenseMaker($text, $resource)
# #
# Takes a plain text file at path $text and creates a license agreement # Takes a plain text file at path $text and creates a license agreement