File isolinux-config of Package syslinux (Revision 36e06afdb7f441bcdfb449a7fcbfdc9e)
Currently displaying revision 36e06afdb7f441bcdfb449a7fcbfdc9e, show latest
1
#! /usr/bin/perl
2
3
#
4
# Patch new base dir into isolinux.
5
#
6
# Makes some assumptions about memory layout in isolinux.
7
#
8
9
use Getopt::Long;
10
11
sub help;
12
13
$opt_base = undef;
14
$opt_help = undef;
15
16
GetOptions(
17
'help' => \$opt_help,
18
'base=s' => \$opt_base,
19
);
20
21
$file = shift;
22
23
help if $file eq '' || $opt_help;
24
25
open F, $file or die "$file: $!\n";
26
sysread F, $file_buf, -s($file);
27
close F;
28
29
die "$file: is not isolinux\n" unless (length $file_buf > (8 << 10)) && ($file_buf =~ m#(/boot(/[\x20-\xff]*)\x00*)\x00isolinux.cfg\x00#s);
30
31
$start = length $`;
32
$base_buf = $1;
33
$old_base = $2;
34
35
if(defined $opt_base) {
36
($base = $opt_base) =~ s#^/*##;;
37
38
$base = "/boot/$base";
39
die "$opt_base: file name too long\n" if length($base) > length($base_buf);
40
$base_buf = $base . "\x00" x (length($base_buf) - length($base));
41
substr($file_buf, $start, length($base_buf)) = $base_buf;
42
43
open F, ">$file" or die "$file: $!\n";
44
syswrite F, $file_buf;
45
close F;
46
47
($old_base = $base) =~ s#^/boot##;
48
}
49
50
print "base=$old_base\n";
51
52
53
sub help
54
{
55
die
56
"usage: isolinux-config [options] isolinux_binary\n" .
57
"Configure isolinux.\n" .
58
"Options:\n" .
59
" --base dir\tset isolinux base directory to dir\n" .
60
" --help\tthis message\n";
61
}
62
63