updated git and svn scripts
[xrzperl.git] / qemu-ghost
blobd8705a1ee026eb1db19fe36d5313c6ff7debf79d
1 #!/usr/bin/perl -w
2 ###APPNAME: qemu-ghost
3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Thu Apr 17 03:54:33 2008
5 ###APPVER: 0.1
6 ###APPDESC: qemu-ghost
7 ###APPUSAGE: (GhostImage) (DiskImages,...)
8 ###APPEXAMPLE: qemu-ghost win2k win2k.gho
9 use strict;
11 #ENV variable MUST be defined somewhere,
12 #FOR perl to search modules from,
13 #OR nothing will work
14 use lib $ENV{XR_PERL_MODULE_DIR};
15 use MyPlace::Script::Usage qw/help_required help_even_empty/;
16 exit 0 if(help_even_empty($0,@ARGV));
18 my $ghostimg=shift;
21 die("File not exists:$ghostimg\n") unless(-f $ghostimg);
22 foreach my $diskimg (@ARGV) {
23 die("File not exists:$diskimg\n") unless(-f $diskimg);
26 my $ghostd="/tmp/qemu-ghost.xiaoranzzz";
27 if(! -d $ghostd) {
28 mkdir $ghostd or die("$!\n");
31 if($ghostimg !~ /^\//) {
32 $ghostimg =~ s/\.\///;
33 $ghostimg = $ENV{PWD} . "/$ghostimg";
35 my $lname=$ghostd . "/ghost.gho";
37 print STDERR "Link \"$ghostimg\" to \"$lname\"\n";
38 system("ln","-sf",$ghostimg,$lname);
40 my $hda="/myplace/emuos/ghostbox.raw";
41 my $hdb="fat:$ghostd";
43 #print STDERR join(" ",("myqemu","-hda",$hda,"-hdb",$hdb,"-hdc",$diskimg)),"\n";
45 my @arg;
46 push @arg,"-hdc",$ARGV[0] if($ARGV[0]);
47 push @arg,"-hdd",$ARGV[1] if($ARGV[1]);
49 exec "qemudos","-hda",$hda,"-hdb",$hdb,@arg;