]> git.saurik.com Git - wxWidgets.git/blame - wxPython/distrib/mac/makedmg
added missing button state
[wxWidgets.git] / wxPython / distrib / mac / makedmg
CommitLineData
8721cada 1#!/usr/bin/perl -w
9c6b4824 2#
8721cada 3# make disk image from folder
9c6b4824 4#
8721cada 5# usage: makedmg src dst name
9c6b4824 6#
8721cada
RD
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
16if ( $#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
23sub make_dmg
24{
25 my $src = $_[0];
26 my $dst = $_[1];
27 my $name = $_[2];
9c6b4824 28
8721cada
RD
29 # check dirs
30 if( not -d $dst && -d $src ) {
31 die "src and dst must be directories\n";
32 }
9c6b4824 33
8721cada
RD
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;
9c6b4824 41 $dmgsize = int($dmgsize + 4);
8721cada
RD
42 if( $dmgsize < 5 ) {
43 $dmgsize = 5
44 }
9c6b4824 45
8721cada
RD
46 # create disk image
47 system "cd \"$dst\"; $hdiUtilExec create -megabytes $dmgsize -ov \"_${name}\"";
48 if( $? ) { die "couldn't create disk image\n"; }
9c6b4824 49
8721cada
RD
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"; }
9c6b4824 71
8721cada
RD
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"; }
9c6b4824 91
8721cada
RD
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}