4 use vars qw(@ISA @EXPORT);
9 sub parse_gengrub_args()
11 my %a = ( timeout => undef,
14 my @opts = ("timeout=i", \$a{timeout},
15 "serial", \$a{serial});
17 if (!GetOptions(@opts))
19 print "Command line parsing failed.\n";
25 print "timeout: $a{timeout}\n" if defined $a{timeout};
26 print "serial : $a{serial}\n" if defined $a{serial};
32 sub prepare_grub1_dir($)
36 return if -e "$dir/boot/grub/stage2_eltorito";
39 my @grub_path = ("/usr/lib/grub/i386-pc", "/usr/share/grub/i386-pc",
40 "/boot/grub", "/usr/local/lib/grub/i386-pc",
41 "/usr/lib/grub/x86_64-pc");
42 unshift @grub_path, $ENV{GRUB_PATH} if defined $ENV{GRUB_PATH};
44 foreach my $p (@grub_path) {
45 $copypath=$p if -e "$p/stage2_eltorito";
47 die "Cannot find a stage2_eltorito file..." unless defined $copypath;
51 mkdir "$dir/boot/grub";
52 system("cp $copypath/stage2_eltorito $dir/boot/grub");
53 chmod 0644, "$dir/boot/grub/stage2_eltorito";
56 sub grub1_mkisofs($$@)
58 my ($isofilename, $dir, @morefiles) = @_;
59 system("cp -v ".join(' ', @morefiles)." $dir") if @morefiles;
60 my $cmd = "mkisofs -f -R -b boot/grub/stage2_eltorito".
61 " -no-emul-boot -boot-load-size 4 -boot-info-table".
62 " -hide-rr-moved -J -joliet-long -o \"$isofilename\" \"$dir\"";
64 print "Generating GRUB1 image with cmd: $cmd\n";
66 die "Failed to create ISO" if $?;
69 sub prepare_grub2_dir($)
73 mkdir "$dir/boot/grub";
76 sub grub2_mkisofs($$@)
78 my ($isofilename, $dir, @morefiles) = @_;
79 my $cmd = "grub_mkisofs_arguments=-f grub-mkrescue"
80 ." --output=\"$isofilename\" $dir ".join(' ', @morefiles);
82 die "Failed to create ISO" if $?;