]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/mac/makedmg
3 # make disk image from folder
5 # usage: makedmg src dst name
7 # (C)opyright 2002 Frank Vercruesse
10 $hdiUtilExec = "/usr/bin/hdiutil";
11 $hdiDrvExec = "/usr/bin/hdid";
12 $newfsExec = "/sbin/newfs_hfs";
13 $duExec = "/usr/bin/du";
14 $dittoExec = "/usr/bin/ditto";
17 die "Wrong number of arguments.\nUsage: makedmg src dst name\n";
20 &make_dmg
( $ARGV[0], $ARGV[1], $ARGV[2]);
30 if( not -d
$dst && -d
$src ) {
31 die "src and dst must be directories\n";
34 # calc disk image size
35 if( not open( MYPIPE
, "$duExec -sk \"${src}\" |") ) {
36 die "couldn't open pipe\n";
38 (my $dmgsize) = split( /\s+/, <MYPIPE
>);
41 $dmgsize = int($dmgsize + 4);
47 system "cd \"$dst\"; $hdiUtilExec create -megabytes $dmgsize -ov \"_${name}\"";
48 if( $? ) { die "couldn't create disk image\n"; }
51 if( not open( MYPIPE
, "cd \"$dst\"; $hdiDrvExec -nomount \"_${name}.dmg\" |") ) {
52 die "couldn't open pipe\n";
54 (my $dev) = split( /\t/, <MYPIPE
>);
55 $dev =~ s/^(.*\S)\s*$/$1/;
56 my( $part, $raw, $pname);
58 ($part,$pname) = split /\t/;
59 if( $pname =~ m/^Apple_HFS/ ) {
60 $part =~ s/^\s*(.*\S)\s*$/$1/;
62 $raw =~ s/^(\/dev\/)(.+)/$1r$2/;
67 system "cd \"$dst\" ; $newfsExec -v \"$name\" $raw";
68 if( $? ) { system "$hdiUtilExec eject $dev"; die "couldn't format disk image\n"; }
69 system "$hdiUtilExec eject $dev";
70 if( $? ) { die "couldn't eject disk image\n"; }
73 if( not open( MYPIPE
, "cd \"$dst\"; $hdiDrvExec \"_${name}.dmg\" |") ) {
74 die "couldn't open pipe\n";
76 ($dev) = split( /\t/, <MYPIPE
>);
77 $dev =~ s/^(.*\S)\s*$/$1/;
80 ($part,$pname,$vname) = split /\t/;
81 if( $pname =~ m/^Apple_HFS/ ) {
82 $vname =~ s/^(.*\S)\s*$/$1/;
87 system "$dittoExec \"${src}\" \"${vname}\"";
88 if( $? ) { system "$hdiUtilExec eject $dev"; die "couldn't copy files\n"; }
89 system "$hdiUtilExec eject $dev";
90 if( $? ) { die "couldn't eject disk image\n"; }
93 system "cd \"$dst\"; $hdiUtilExec convert \"_${name}.dmg\" -format UDCO -o \"${name}\"";
94 if( $? ) { die "couldn't convert disk image\n"; }