]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/mac/makedmg
Inital fill in background, removed tabs, -1->wxID_ANY, TRUE->true, FALSE->false
[wxWidgets.git] / wxPython / distrib / mac / makedmg
1 #!/usr/bin/perl -w
2 #
3 # make disk image from folder
4 #
5 # usage: makedmg src dst name
6 #
7 # (C)opyright 2002 Frank Vercruesse
8
9
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";
15
16 if ( $#ARGV != 2 ) {
17 die "Wrong number of arguments.\nUsage: makedmg src dst name\n";
18 }
19
20 &make_dmg( $ARGV[0], $ARGV[1], $ARGV[2]);
21
22
23 sub make_dmg
24 {
25 my $src = $_[0];
26 my $dst = $_[1];
27 my $name = $_[2];
28
29 # check dirs
30 if( not -d $dst && -d $src ) {
31 die "src and dst must be directories\n";
32 }
33
34 # calc disk image size
35 if( not open( MYPIPE, "$duExec -sk \"${src}\" |") ) {
36 die "couldn't open pipe\n";
37 }
38 (my $dmgsize) = split( /\s+/, <MYPIPE>);
39 close( MYPIPE);
40 $dmgsize /= 1024;
41 $dmgsize = int($dmgsize + 4);
42 if( $dmgsize < 5 ) {
43 $dmgsize = 5
44 }
45
46 # create disk image
47 system "cd \"$dst\"; $hdiUtilExec create -megabytes $dmgsize -ov \"_${name}\"";
48 if( $? ) { die "couldn't create disk image\n"; }
49
50 # format disk image
51 if( not open( MYPIPE, "cd \"$dst\"; $hdiDrvExec -nomount \"_${name}.dmg\" |") ) {
52 die "couldn't open pipe\n";
53 }
54 (my $dev) = split( /\t/, <MYPIPE>);
55 $dev =~ s/^(.*\S)\s*$/$1/;
56 my( $part, $raw, $pname);
57 while( <MYPIPE> ) {
58 ($part,$pname) = split /\t/;
59 if( $pname =~ m/^Apple_HFS/ ) {
60 $part =~ s/^\s*(.*\S)\s*$/$1/;
61 $raw = $part;
62 $raw =~ s/^(\/dev\/)(.+)/$1r$2/;
63 last;
64 }
65 }
66 close( MYPIPE);
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"; }
71
72 # copy files
73 if( not open( MYPIPE, "cd \"$dst\"; $hdiDrvExec \"_${name}.dmg\" |") ) {
74 die "couldn't open pipe\n";
75 }
76 ($dev) = split( /\t/, <MYPIPE>);
77 $dev =~ s/^(.*\S)\s*$/$1/;
78 my $vname;
79 while( <MYPIPE> ) {
80 ($part,$pname,$vname) = split /\t/;
81 if( $pname =~ m/^Apple_HFS/ ) {
82 $vname =~ s/^(.*\S)\s*$/$1/;
83 last;
84 }
85 }
86 close( MYPIPE);
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"; }
91
92 # convert disk image
93 system "cd \"$dst\"; $hdiUtilExec convert \"_${name}.dmg\" -format UDCO -o \"${name}\"";
94 if( $? ) { die "couldn't convert disk image\n"; }
95 }