summaryrefslogtreecommitdiffstats
path: root/tools/install-xml-file-list
blob: 5d43ac9ebf158750df45013606ef5dd571a7e675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#!/usr/bin/perl

use MDK::Common;
use XML::Parser;
use Data::Dumper;
use File::Glob;
use Config;
use Cwd 'cwd';

my $want_sudo = $ARGV[0] eq '--sudo' && shift @ARGV;

@ARGV == 2 or die "usage: install-xml-file-list [--sudo] <xml file> <destination>\n";
my ($xml_file_list, $DEST) = @ARGV;

my $sudo = '';
if ($>) {
    $sudo = "sudo" if $want_sudo;
    $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
}

#$verbose = 1;

my $initial_dir = cwd();
my $ARCH = arch() =~ /i.86/ ? 'i386' : arch();
my $LIB = arch() =~ /x86_64/ ? "lib64" : "lib";

my $base_cpio_options = '-pumd --quiet';

my $problem;
my $tree = XML::Parser->new(Style => 'Tree')->parsefile($xml_file_list);

my $main_node = decompose($tree);

$main_node->{tag} eq 'list' or die "bad file $xml_file_list (main tag should be <list>)\n";

handle_nodes({}, $main_node);

$problem and exit 1;

install_needed_libraries();

final_cleanup();

sub error {
    my ($err) = @_;
    warn "FATAL: $err\n";
    $problem = 1;
}

sub final_cleanup() {
    #- cpio creates directory 700, that's not nice
    system("find $DEST -type d -print0 | xargs -0 $sudo chmod 755");
}

sub handle_nodes {
    my ($env, $e) = @_;
    handle_node($env, decompose($_)) foreach @{$e->{l}};
}
sub handle_node {
    my ($env, $node) = @_;

    if (!$node->{tag} && $node->{text} !~ /\S/) {
    } elsif (!$node->{tag}) {
	install($env, $node->{text});
    } elsif ($node->{tag} eq 'if') {
	my $cond = valid_cond($node->{attr});
	handle_nodes($env, $node) if $cond;
    } elsif ($node->{tag} eq 'if-not') {
	my $cond = valid_cond($node->{attr});
	handle_nodes($env, $node) if !$cond;
    } elsif (member($node->{tag}, 'from', 'to', 'mode', 'filter')) {
	handle_nodes(add_to_env($env, $node->{tag} => $node->{attr}), $node);
    } else {
	warn "expecting tag <from>, not <$node->{tag}>\n";
    }
}

sub valid_cond {
    my ($attr) = @_;
    every {
	if ($_ eq 'ARCH') {
	    $ARCH =~ /$attr->{$_}/;
	} elsif ($_ eq 'set') {
	    $ENV{$attr->{$_}};
	} else {
	    die "<if>: unknown condition $_\n";
	}
    } keys %$attr;
}

sub add_to_env {
    my ($env, $tag, $attr) = @_;
    my %env = map_each { $::a => +{%$::b} } %$env;
    foreach (keys %$attr) {
	!$env{$tag}{$_} or die qq(overriding attribute <$tag $_="$env{$tag}{$_}"> with $_="$attr->{$_}"\n); 
	$env{$tag}{$_} = $attr->{$_};
    }
    \%env;
}

sub group_by_n {
    my ($n, $l) = @_;
    my (@r, $subl);
    my $i = 0;
    foreach (@$l) {
	if ($i % $n == 0) {
	    push @r, $subl = [];
	}
	push @$subl, $_;
	$i++;
    }
    @r;
}

sub identify_file {
    my ($dev, $ino) = @_;
    "$dev:$ino";
}

sub all_files_rec_ {
    my ($d) = @_;

    $d, -d $d && ! -l $d ? map {  all_files_rec_("$d/$_") } all($d) : ();
}

sub expand_macros {
    my ($f) = @_;
    $f =~ s!\bLIB\b!$LIB!g;
    $f =~ s!\bARCH\b!$ARCH!ge;
    $f =~ s!\$\((\w+)\)!$ENV{$1} || die "$1 undefined\n"!ge;
    $f;
}

my %needed_libraries;
sub collect_needed_libraries {
    my (@to_check) = @_;
    while (@to_check) {
	my $to_check = join(' ', @to_check);
	my @l = `ldd $to_check 2>/dev/null` =~ m! => (/\S+)!g;
	foreach (@l) {
	    if ($main_node->{attr}{'no-arch-libraries'}) {
		#- replace /lib/tls or /lib/i686 with /lib
		s!^(/lib(64)?/).*?/!$1! if arch() !~ /x86_64/;
	    }
	}
	@to_check = grep { !$needed_libraries{$_}++ } @l;	
	@to_check = ();
    }
}
sub install_needed_libraries {
    copy_files('', $DEST, [ keys %needed_libraries ], '', '--dereference');
}

sub collect_needed_perl_files {
    my ($local_rep, $dest, @scripts) = @_;

    my (%local, %global);
    foreach my $script (@scripts) {
	foreach (`strace -efile perl -cw -I$local_rep $script 2>&1`) {
	    my ($f) = /^open\("(.*?)",.*\)\s*=\s*\d+$/ or next;
	    if ($f =~ m!^\Q$local_rep\E/(.*)!) {
		$local{$1} = 1;
	    } elsif (begins_with($f, '/dev/')) {
		# skip
	    } elsif (begins_with($f, '/')) {
		if ($main_node->{attr}{'no-arch-libraries'}) {
		    #- replace /lib/tls or /lib/i686 with /lib
		    $f =~ s!^(/lib(64)?/).*?/!$1! if arch() !~ /x86_64/;
		}
		$global{$f} = 1;
	    }
	}
    }
    [ keys %local ], [ keys %global ];
}

sub copy_files {
    my ($working_dir, $to_dir, $files, $b_flatten, @options) = @_;

    if ($b_flatten) {
	mkdir_p($to_dir);
	my $options = join(' ', '-r', @options);
	foreach (group_by_n(20, $files)) {
	    warn "cp $options to_dir $to_dir from $working_dir: @$_\n" if $verbose;
	    system("cd $working_dir ; $sudo cp $options @$_ $to_dir");
	}
    } else {
	my $options = join(' ', $base_cpio_options, @options);
	warn "cpio $options to_dir=$to_dir from=$working_dir: @$files\n" if $verbose;
	open(my $F, "| cd $working_dir ; $sudo cpio $options $to_dir");
	print $F "$_\n" foreach @$files;
	close($F) or die "cpio $to_dir failed\n";
    }
}

sub install {
    my ($env, $text) = @_;

    my $from_dir = expand_macros($env->{from}{dir});
    my $to_dir = $DEST . expand_macros($env->{to}{dir} || $env->{to}{flatten} && $from_dir || '');
    my $copy_mode = $env->{mode}{copy} || '';
    my $working_dir = '.';

    my $expand = $env->{from}{expand} || '';

    my $disallow_from_dir = sub {
	!$from_dir or die "from dir not allowed with $expand binary\n";
    };

    my $from_file = sub {
	my ($rel, $b_full_glob, $b_recursive_dirs) = @_;
	my $f = expand_macros($from_dir ? "$from_dir/$rel" : $rel);
	my @l = $f;
	chdir $working_dir;
	if ($f =~ /\*/ || $b_full_glob) {
	    @l = File::Glob::bsd_glob($f); #- using bsd_glob because CORE::glob() splits on whitespace and we don't want this
	    if (@l == 0) { 
		error("no match for $f");
	    } elsif (@l == 1 || $b_full_glob) {
	    } else { 
		error("multiple match for $f");
		@l = ();
	    }
	} elsif (! -e $f) {
	    error("missing file $f ($rel) in $working_dir");
	    @l = ();
	}
	if (@l == 1 && -d $l[0] && $b_recursive_dirs) {
	    @l = all_files_rec_($l[0]);
	}
	@l = grep { !m!/(\.svn|CVS)($|/)! } @l;
	if (my $re = $env->{from}{matching}) {
	    @l = grep { eval $re } @l;
	}

	collect_needed_libraries(grep { -x $_ } @l);

	chdir $initial_dir;
	@l;
    };

    my @text_l = $env->{from}{spaces_in_filename} ? $text =~ /^\s*(.*?)\s*$/ : split(' ', $text);
    my @files;
    if ($expand eq 'tar') {
	foreach (@text_l) {
	    my ($tarball) = $from_file->($_) or next;
	    system('tar', 'xfj', $tarball, '-C', $to_dir);
	}
	# not filling @files, things are already done

    } elsif ($expand eq 'command') {
	@files = chomp_(`$text`);

    } elsif ($expand eq 'glob') {
	#- glob done in $from_file
	@files = @text_l;

    } elsif ($expand eq 'binary') {
	$disallow_from_dir->();
	my @PATH = qw(/sbin /bin /usr/bin /usr/sbin /usr/X11R6/bin);
	foreach my $name (map { expand_macros($_) } @text_l) {
	    my @l = grep { -x $_ } map { "$_/$name" } @PATH;
	    @l or error("can't find binary $name"), next;
	    if (@l > 1) {
		my @m = grep { ! -l $_ } @l;
		if (@m == 1) {
		    my $id = identify_file($m[0]);
		    push @files, grep { -l $_ && identify_file($_) eq $id } @l;
		}
		@l = @m if @m;
	    }
	    if (@l > 1) {
		warn "many matches for binary $name: " . join(' ', @l) . ", choosing $l[0]\n";
	    }
	    my $f = $l[0];
	    while (1) {
		push @files, $f;
		$copy_mode ne 'dereference' or last;
		my $l = readlink($f) or last;
		if ($l =~ m!/! && $l !~ m!^\.\..*/s?bin/[^/]+$!) {
		    warn "keeping symlink $f -> $l as is\n";
		    last;
		}
		$f = dirname($f) . '/' . $l;
	    }
	}	
	$copy_mode ||= 'keep-links';
	$env->{filter}{command} ||= 'strip';

    } elsif ($expand eq 'rpm') {
	$disallow_from_dir->();
	foreach my $rpm (@text_l) {
	    my @l = chomp_(`rpm -ql $rpm`) or error("rpm $rpm must be installed");
	    push @files, @l;
	}

    } elsif ($expand eq 'perl') {
	$disallow_from_dir->();
	$from_dir = '/usr/lib/perl5/vendor_perl/*';
	@files = @text_l;
    } elsif ($expand eq 'main-perl') {
	$disallow_from_dir->();
	$from_dir = $Config{privlib};
	@files = @text_l;
    } elsif ($expand =~ /collect-perl-files/) {
	my (undef, $local, $to) = split(' ', $expand);

	@files = @text_l;
	warn "collect-perl-files $local $to @files ($env->{filter}{command})\n";
	my ($local_perl_files, $global_perl_files) = collect_needed_perl_files($local, $to, @files);
	warn "collect-perl-files gave: ", join(' ', @$local_perl_files), "\n";
#	warn "                    and: ", join(' ', @$global_perl_files), "\n";
	copy_and_filter($local =~ m!/! ? $local : "$working_dir/$local", "$DEST$to", $local_perl_files, $env->{filter}, '', '--dereference');
	copy_and_filter('', $DEST, $global_perl_files, $env->{filter}, '', '--dereference');

    } elsif ($expand) {
	die "unknown expand method $expand\n";
    } else {
	@files = @text_l;

	$env->{filter}{command} ||= 'strip' if $to_dir =~ m!/bin$!;
    }

    if ($env->{to}{dir} && $from_dir) {
	$working_dir = $from_dir;
	undef $from_dir;
    }

    my @all_files = map { $from_file->($_, $expand eq 'glob', $expand ne 'rpm') } @files;
   
    my @options = (
	if_($copy_mode ne 'keep-links', '--dereference'),
    );
    if (@all_files) {
	copy_and_filter($working_dir, $to_dir, \@all_files, $env->{filter}, $env->{to}{flatten}, @options);
    }
}

sub copy_and_filter {
    my ($working_dir, $to_dir, $all_files, $filter, $flatten, @copy_options) = @_;

    copy_files($working_dir, $to_dir, $all_files, $flatten, @copy_options);
    apply_filter($to_dir, $filter, $all_files, $flatten);
}

sub apply_filter {
    my ($to_dir, $filter, $all_files, $b_flatten) = @_;

    chdir $to_dir;
    foreach (group_by_n(20, $all_files)) {
	my @l = $b_flatten ? (map { basename($_) } @$_) : (map { "./$_" } @$_);
	@l = grep { ! -d $_ } @l;

	if (my $subst = $filter->{subst}) {
	    system('perl', '-pi', '-e', $subst, @l);
	}
	if (my $command = $filter->{command}) {
	    $command = $initial_dir . "/$command" if $command =~ m!^..?/!;
	    if ($command =~ /simplify-drakx-modules/) {
		@l = grep { !/\.so($|\.)/ } @l;
	    }
	    my @options = (
		if_($command eq 'gzip', '-9f'),
		if_($command eq 'strip', '2>/dev/null'),
	    );
	    warn "running $command @options @l\n" if $verbose;
	    system(join(' ', $command, @options, @l));
	}
    }
    chdir $initial_dir;
}

sub decompose {
    my ($tree) = @_;
    my ($tag, $val) = @$tree;
    if ($tag eq '0') {
	{ text => $val };
    } else {
	my ($attr, @l) = @$val;
	{ tag => $tag, attr => $attr, l => [ group_by2(@l) ] };
    }
}
@kernels = $main; } else { @kernels = map { m|kernel/all.kernels/(.*)| } glob('kernel/all.kernels/*'); $img =~ /usb/ and @kernels = grep { $_ !~ /2\.2\.14/ } @kernels; #- 2.2.14 is too old, usb support was not working properly } foreach (@kernels) { if ($img =~ /rdz$/) { initrd($mnt, "$img-$_"); } else { print STDERR "calling boot_img_$arch\n"; $::{"boot_img_$arch"}->($mnt, "$img-$_", glob("kernel/all.kernels/$_/boot/vmlinu*")); rename("$img-$main", "$img"); } } if ($arch =~ /i.86/ && $img =~ /all/) { isolinux($main, @kernels); my ($img, $img_sav) = ("images/cdrom.img-$main", 'images/cdrom.img-sav'); rename($img, $img_sav); $type = 'cdrom'; boot_img_i386($mnt, $img, "kernel/all.kernels/$main/boot/vmlinu*", sub { $_[0] =~ s/\bautomatic=\S+\b//; "$_[0] changedisk" }); rename($img, 'images/cdrom-changedisk.img'); rename($img_sav, $img); } if (my ($tftpboot) = grep { -e $_ } qw(/tftpboot /var/lib/tftpboot)) { system("/bin/cp -f kernel/all.kernels/$main/boot/vmlinu* $tftpboot/vmlinuz 2>/dev/null"); system("/bin/cp -f images/network.rdz-$main $tftpboot/network.rdz 2>/dev/null"); } sub install_stripped { _ "strip $_[0]"; _ "$sudo install $_[0] $_[1]" } sub initrd { my ($mnt, $img) = @_; my ($ltype, $I) = $type =~ /(.*?)(64)/; $ltype ||= $type; my $tmp = "$ENV{HOME}/tmp/initrd"; my $tar = "$instdir/stage1-data/stage1.tar.bz2"; __ "$sudo umount $tmp $mnt 2>/dev/null"; _ "dd if=/dev/zero of=$tmp bs=1k count=" . ($arch =~ /ia64/ ? ($type eq "all" ? 16386 : 16384) : ($type eq "all" ? 4000 : 2000)); _ "$mke2fs $tmp"; _ "$sudo mount -t ext2 $tmp $mnt -o loop"; _ "$sudo tar xjC $mnt -f $tar"; install_stripped("$instdir/init", "$mnt/sbin"); install_stripped("$instdir/$install", "$mnt/sbin/stage1"); if (member($type, qw(network network_gigabit_usb all blank))) { install_stripped("$instdir/ppp/pppd-bin", "$mnt/sbin/pppd"); install_stripped("$instdir/rp-pppoe/pppoe-bin", "$mnt/sbin/pppoe"); _ "$sudo mknod $mnt/dev/ppp c 108 0"; _ "$sudo mknod $mnt/dev/ptyp0 c 2 0"; _ "$sudo mknod $mnt/dev/ttyp0 c 3 0"; } if (member($type, qw(pcmcia all network)) && $arch !~ /ppc/ && $arch !~ /ia64/) { _ "$sudo cp -a /etc/pcmcia $mnt/etc"; _ "cp $mnt/etc/pcmcia/config /tmp/pcmcia_config_tmp"; _ "tools/patch_pcmcia_config.pl /tmp/pcmcia_config_tmp kernel/all.modules/$main/modules.dep"; _ "sudo mv /tmp/pcmcia_config_tmp $mnt/etc/pcmcia/config"; } my ($ext) = $img =~ /rdz-(.*)/ or die "bad initrd name ($img)"; $modz = "kernel/all.modules$I/$ext"; if ($type !~ /blank/) { _ "$sudo cp -f $modz/${ltype}_modules.mar $mnt/modules/modules$I.mar" ; _ "$sudo cp -f $modz/modules.dep $mnt/modules/"; } _ "$sudo umount $mnt"; # Workaround for vfat-loop bug (quite touchy) _ "gzip -9f $tmp"; _ "cp -f $tmp.gz $img"; _ "rm -f $tmp.gz"; # _ "gzip -9 -c $tmp > $img"; # _ "rm -f $tmp"; } sub entries_append { my ($type) = @_; my $automatic = ""; $automatic = "automatic=method:cdrom" if ($type eq "cdrom"); $automatic = "automatic=method:disk" if ($type eq "hd"); my @simple_entries = ( linux => "$default_vga", vgalo => "vga=785", vgahi => "vga=791", vga16 => "vga16", text => "text", patch => "patch $default_vga", expert => "expert $default_vga", rescue => "rescue rw", ); my @entries = ( (map { $_->[0] => "$automatic $default_acpi $_->[1]" } group_by2(@simple_entries)), acpi => "$automatic $default_vga", if_(member($type, "cdrom", "all"), oem => "automatic=method:cdrom $default_vga $default_acpi rescue oem rw",), if_($type eq "all", all => "pcmcia $default_vga $default_acpi"), ); map { [ $_->[0], "$default_append $_->[1]" ] } group_by2(@entries); } sub boot_img_i386 { my ($mnt, $img, $kernel, $args_callback) = @_; __ "$sudo umount $mnt 2>/dev/null"; if ($type eq "hd") { _ "bunzip2 -c $instdir/init-data/msgboot.img.bz2 > $img"; } elsif ($type eq "all") { _ "bunzip2 -c $instdir/init-data/msgboot-graphicallogo-2880.img.bz2 > $img"; } elsif ($type eq "blank") { _ "bunzip2 -c $instdir/init-data/msgboot-blank.img.bz2 > $img"; } else { _ "bunzip2 -c $instdir/init-data/msgboot-graphicallogo.img.bz2 > $img"; } _ "$sudo mount -t vfat -o umask=0 $img $mnt -o loop"; _ "cat $kernel > $mnt/vmlinuz" if $type !~ /blank/; my $rdz = $img; $rdz =~ s/\.img/.rdz/; initrd("${mnt}2", $rdz) if !-e $rdz; my $short_type = substr($type, 0, 8); eval { _ "cp -f $rdz $mnt/$short_type.rdz" }; if ($@) { unlink "$mnt/$short_type.rdz"; my $avail = (split ' ', `df $mnt`)[-3]; my $s = int((-s $rdz) / 1024); die sprintf("not enough room for $rdz: need %dKB (available %dKB < needed %dKB)\n", $s - $avail, $avail, $s); } my $timeout = 72; output "$mnt/syslinux.cfg", "default linux prompt 1 timeout $timeout display boot.msg F1 help.msg F2 advanced.msg F3 boot.msg " . join('', map { my $args = $args_callback ? $args_callback->($_->[1]) : $_->[1]; "label $_->[0] kernel vmlinuz append initrd=$short_type.rdz $args " } entries_append($type)); _ "sync"; _ "df $mnt"; } sub boot_img_alpha { my ($mnt, $img) = @_; __ "$sudo umount $mnt 2>/dev/null"; _ "dd if=/dev/zero of=$img bs=1k count=1440"; _ "$mke2fs $img"; _ "/sbin/e2writeboot $img /boot/bootlx"; _ "$sudo mount -t ext2 $img $mnt -o loop"; _ "cp -f vmlinux.gz $mnt" if $type !~ /blank/; -f "$type.rdz" ? _ "cp -f $type.rdz $mnt" : initrd("${mnt}2", "$mnt/$type.rdz"); mkdir "$mnt/etc", 0777; output("$mnt/etc/aboot.conf", "0:vmlinux.gz initrd=$type.rdz rw $default_append $type 1:vmlinux.gz initrd=$type.rdz rw $default_append text $type "); _ "sync"; _ "df $mnt"; } sub boot_img_ia64 { my ($mnt, $img, $kernel) = @_; my $rdz = $img; $rdz =~ s/\.img/.rdz/; __ "$sudo umount $mnt 2>/dev/null"; _ "dd if=/dev/zero of=$img bs=1k count=16384"; _ "mkdosfs $img"; _ "$sudo mount -t vfat $img $mnt -o loop,umask=000"; _ "$sudo cp -f $kernel $mnt/vmlinux"; _ "cp -f $rdz $mnt/$type.rdz"; _ "$sudo cp -f tools/ia64/elilo.efi $mnt"; output("$mnt/elilo.conf", " prompt timeout=50 image=vmlinux label=linux root=/dev/ram3 initrd=$type.rdz append=\" ramdisk_size=120000\" read-only image=vmlinux label=rescue root=/dev/ram3 initrd=$type.rdz append=\" rescue ramdisk_size=120000\" "); _ "sync"; _ "df $mnt"; } sub boot_img_sparc { my ($mnt, $img) = @_; if ($type =~ /^live(.*)/) { #- hack to produce directly into /export the needed file for cdrom boot. my $dir = "/export"; my $boot = "boot"; #- non-absolute pathname only! _ "mkdir -p $dir/$boot"; _ "cp -f /boot/cd.b /boot/second.b $dir/$boot"; _ "cp -f vmlinux$1 $dir/$boot/vmlinux$1"; -f "live$1.rdz" ? _ "cp -f live$1.rdz $dir/$boot" : initrd("${mnt}2", "$dir/$boot/live$1.rdz"); output("$dir/$boot/silo.conf", " partition=1 default=linux timeout=100 read-write message=/$boot/boot.msg image=\"cat /$boot/boot.msg\" label=1 single-key image=\"cat /$boot/general.msg\" label=2 single-key image=\"cat /$boot/expert.msg\" label=3 single-key image=\"cat /$boot/rescue.msg\" label=4 single-key image=\"cat /$boot/kickit.msg\" label=5 single-key image=\"cat /$boot/param.msg\" label=6 single-key image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=linux alias=install initrd=/$boot/live.rdz append=\"ramdisk_size=128000 root=/dev/ram3\" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=text initrd=/$boot/live.rdz append=\"ramdisk_size=128000 text root=/dev/ram3\" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=expert initrd=/$boot/live.rdz append=\"ramdisk_size=128000 expert root=/dev/ram3\" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=ks initrd=/$boot/live.rdz append=\"ramdisk_size=128000 ks root=/dev/ram3\" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=rescue initrd=/$boot/live.rdz append=\"ramdisk_size=128000 rescue rw root=/dev/ram3\" image[sun4u]=/$boot/vmlinux64 label=linux alias=install initrd=/$boot/live64.rdz append=\"ramdisk_size=128000 root=/dev/ram3\" image[sun4u]=/$boot/vmlinux64 label=text initrd=/$boot/live64.rdz append=\"ramdisk_size=128000 text root=/dev/ram3\" image[sun4u]=/$boot/vmlinux64 label=expert initrd=/$boot/live64.rdz append=\"ramdisk_size=128000 expert root=/dev/ram3\" image[sun4u]=/$boot/vmlinux64 label=ks initrd=/$boot/live64.rdz append=\"ramdisk_size=128000 ks root=/dev/ram3\" image[sun4u]=/$boot/vmlinux64 label=rescue initrd=/$boot/live64.rdz append=\"ramdisk_size=128000 rescue rw root=/dev/ram3\" "); output("$dir/$boot/README", " To Build a Bootable CD-ROM, try: mkisofs -R -o t.iso -s /$boot/silo.conf /export "); } elsif ($type =~ /^tftprd(.*)/) { my $dir = "/export"; my $boot = "images"; my $setarch = $1 ? "sparc64" : "sparc32"; _ "mkdir -p $dir/$boot"; -f "$type.rdz" or initrd("${mnt}2", "$type.rdz"); _ "cp -f vmlinux$1.aout $dir/$boot/$type.img"; _ "$setarch kernel$1/src/arch/sparc$1/boot/piggyback $dir/$boot/$type.img kernel$1/boot/System.map $type.rdz"; } elsif ($type =~ /^tftp(.*)/) { my $dir = "/export"; my $boot = "images"; _ "mkdir -p $dir/$boot"; _ "cp -f vmlinux$1.aout $dir/$boot/$type.img"; } else { my $dir = "floppy"; my ($ltype, $I) = $type =~ /(.*?)(64)/; $ltype ||= $type; __ "$sudo umount $mnt 2>/dev/null"; _ "rm -rf $dir"; _ "mkdir -p $dir"; _ "cp -f /boot/fd.b /boot/second.b $dir"; _ "cp -f vmlinuz$I $dir/vmlinux$I.gz" if $type !~ /blank/; -f "$type.rdz" ? _ "cp -f $type.rdz $dir" : initrd("${mnt}2", "$dir/$type.rdz"); output("$dir/boot.msg", " Welcome to Mandrake Linux 7.1 Press <Enter> to install or upgrade a system 7mMandrake Linux7m "); output("$dir/silo.conf", " partition=1 default=linux timeout=100 read-write message=/boot.msg image=/vmlinux$I.gz label=linux initrd=/$type.rdz append=\"ramdisk_size=128000 $ltype root=/dev/ram3\" "); _ "genromfs -d $dir -f /dev/ram -A 2048,/.. -a 512 -V \'DrakX boot disk\'"; _ "$sudo mount -t romfs /dev/ram $mnt"; _ "silo -r $mnt -F -i /fd.b -b /second.b -C /silo.conf"; _ "$sudo umount $mnt"; _ "dd if=/dev/ram of=$type.img bs=1440k count=1"; _ "sync"; _ "$sudo mount -t romfs /dev/ram $mnt"; _ "df $mnt"; } } sub boot_img_ppc { my (@kernels) = @_; #- hack to produce directly into /export the needed file for cdrom boot. my $dir = "/export"; my $boot = "boot"; #- non-absolute pathname only! _ "rm -rf $dir/$boot"; mkdir "$dir/$boot", 0777; foreach (glob("kernel/all.kernels/*")) { my $ext = basename($_); if ($ext =~ /2.4/) { _ "cp $_/boot/vmlinux $dir/$boot/vmlinux"; _ "cp images/all.rdz-$ext $dir/$boot/all.gz"; } if ($ext =~ /2.2/) { _ "cp $_/boot/vmlinux $dir/$boot/vmlinux-2.2"; _ "cp images/all.rdz-$ext $dir/$boot/all-2.2.gz"; } } _ "cp -f /usr/lib/yaboot/yaboot $dir/$boot/yaboot"; output("$dir/$boot/ofboot.b", "<CHRP-BOOT> <COMPATIBLE> MacRISC </COMPATIBLE> <DESCRIPTION> Mandrake Linux PPC bootloader </DESCRIPTION> <BOOT-SCRIPT> \" screen\" output dev screen \" \"(0000000000aa00aa0000aaaaaa0000aa00aaaa5500aaaaaa)\" drop 0 8 set-colors \" \"(5555555555ff55ff5555ffffff5555ff55ffffff55ffffff)\" drop 8 8 set-colors device-end 3 to foreground-color 0 to background-color \" \"(0C)\" fb8-write drop \" Booting Mandrake Linux PPC...\" fb8-write drop 100 ms boot cd:2,\\\\yaboot </BOOT-SCRIPT> <OS-BADGE-ICONS> 1010 000000000000F8FEACF6000000000000 0000000000F5FFFFFEFEF50000000000 00000000002BFAFEFAFCF70000000000 0000000000F65D5857812B0000000000 0000000000F5350B2F88560000000000 0000000000F6335708F8FE0000000000 00000000005600F600F5FD8100000000 00000000F9F8000000F5FAFFF8000000 000000008100F5F50000F6FEFE000000 000000F8F700F500F50000FCFFF70000 00000088F70000F50000F5FCFF2B0000 0000002F582A00F5000008ADE02C0000 00090B0A35A62B0000002D3B350A0000 000A0A0B0B3BF60000505E0B0A0B0A00 002E350B0B2F87FAFCF45F0B2E090000 00000007335FF82BF72B575907000000 000000000000ACFFFF81000000000000 000000000081FFFFFFFF810000000000 0000000000FBFFFFFFFFAC0000000000 000000000081DFDFDFFFFB0000000000 000000000081DD5F83FFFD0000000000 000000000081DDDF5EACFF0000000000 0000000000FDF981F981FFFF00000000 00000000FFACF9F9F981FFFFAC000000 00000000FFF98181F9F981FFFF000000 000000ACACF981F981F9F9FFFFAC0000 000000FFACF9F981F9F981FFFFFB0000 00000083DFFBF981F9F95EFFFFFC0000 005F5F5FDDFFFBF9F9F983DDDD5F0000 005F5F5F5FDD81F9F9E7DF5F5F5F5F00 0083DD5F5F83FFFFFFFFDF5F835F0000 000000FBDDDFACFBACFBDFDFFB000000 000000000000FFFFFFFF000000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFFFF00000000 00000000FFFFFFFFFFFFFFFFFF000000 00000000FFFFFFFFFFFFFFFFFF000000 000000FFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFFFF0000 00FFFFFFFFFFFFFFFFFFFFFFFFFF0000 00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 00FFFFFFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFF000000 </OS-BADGE-ICONS> </CHRP-BOOT> "); output("$dir/$boot/yaboot.conf", " init-message = \"\\nWelcome to Mandrake Linux PPC!\\nHit <TAB> for boot options.\\n\\n\" timeout = 150 default = install-gui message=cd:,\\\\\\\\yaboot.msg image = cd:,\\\\\\\\vmlinux label = install-gui root = /dev/ram3 initrd = cd:,\\\\\\\\all.gz initrd-size = 34000 image = cd:,\\\\\\\\vmlinux-2.2 label = install-gui-2.2 root = /dev/ram3 initrd = cd:,\\\\\\\\all-2.2.gz initrd-size = 34000 image = cd:,\\\\\\\\vmlinux label = install-text root = /dev/ram3 initrd = cd:,\\\\\\\\all.gz initrd-size = 34000 append = \" text video=ofonly\" image = cd:,\\\\\\\\vmlinux-2.2 label = install-text-2.2 root = /dev/ram3 initrd = cd:,\\\\\\\\all-2.2.gz initrd-size = 34000 append = \" text video=ofonly\" image = cd:,\\\\\\\\vmlinux label = install-gui-old root = /dev/ram3 initrd = cd:,\\\\\\\\all.gz initrd-size = 34000 append = \" gui-old video=ofonly\" image = cd:,\\\\\\\\vmlinux-2.2 label = install-gui-old-2.2 root = /dev/ram3 initrd = cd:,\\\\\\\\all-2.2.gz initrd-size = 34000 append = \" gui-old video=ofonly\" image = enet:0,vmlinux label = install-net root = /dev/ram3 initrd = enet:0,all.gz initrd-size = 34000 append = \" video=ofonly\" image = enet:0,vmlinux-2.2 label = install-net-2.2 root = /dev/ram3 initrd = enet:0,all-2.2.gz initrd-size = 34000 append = \" video=ofonly\" image = enet:0,vmlinux label = install-net-text root = /dev/ram3 initrd = enet:0,all.gz initrd-size = 34000 append = \" text video=ofonly\" image = enet:0,vmlinux-2.2 label = install-net-text-2.2 root = /dev/ram3 initrd = enet:0,all-2.2.gz initrd-size = 34000 append = \" text video=ofonly\" image = cd:,\\\\\\\\vmlinux label = rescue root = /dev/ram3 initrd = cd:,\\\\\\\\all.gz initrd-size = 34000 append = \" rescue video=ofonly\" image = enet:0,vmlinux label = rescue-net root = /dev/ram3 initrd = enet:0,all.gz initrd-size = 34000 append = \" rescue video=ofonly\" "); output("$dir/$boot/yaboot.msg", " Thanks for choosing Mandrake Linux PPC. The following is a short explanation of the various options for booting the install CD. All options ending with \"2.2\" will use the 2.2.20-9mdkBOOT kernel. The default syntax with no suffix uses the 2.4.18-4mdkBOOT kernel. The default if you just hit enter is \"install-gui\". install-gui: uses XFree86 fbdev mode install-text: text based install install-gui-old: old Xpmac gui install-net: allows you to use a minimal boot CD, pulling the rest of the install from a network server install-net-text: text mode network install rescue: boots the rescue image rescue-net: boots the rescue image from a network server "); } sub isolinux { my ($main, @kernels) = @_; @kernels = ($main, grep { $_ ne $main } @kernels); _ "rm -rf isolinux"; mkdir "isolinux", 0777; my $i = 0; foreach (@kernels) { mkdir "isolinux/alt$i", 0777; my ($kernel) = glob("kernel/all.kernels/$_/boot/vmlinu*"); _ "cp $kernel isolinux/alt$i/vmlinuz"; _ "cp images/all.rdz-$_ isolinux/alt$i/all.rdz"; $i++; } if (-e "isolinux-graphic.bmp") { #- change here for newer picture isolinux-graphic.bmp and newer parameters. _ "lilo-bmp2mdk mode:0x103 progress:425,173,16,7,64+21 clear:600,800,64+59 pos:0,0 <isolinux-graphic.bmp >isolinux/boot.msg"; } _ "cp /usr/lib/syslinux/isolinux.bin isolinux/isolinux.bin"; output "isolinux/isolinux.cfg", " default linux prompt 1 timeout 150 " . (-e "isolinux/boot.msg" ? "display boot.msg" : "display help.msg") . " F1 help.msg F2 advanced.msg " . (-e "isolinux/boot.msg" && "F3 boot.msg") . " " . join('', map { "label $_->[0] kernel alt0/vmlinuz append initrd=alt0/all.rdz $_->[1] automatic=method:cdrom " } entries_append('all')) . join('', map_index { "label alt$::i kernel alt$::i/vmlinuz append initrd=alt$::i/all.rdz $default_append $default_acpi $default_vga " } @kernels); output "isolinux/help.msg", (-e "isolinux/boot.msg" && pack "C*", 0x0E, 0x80, 0x03, 0x00) . " 0aWelcome to 09Mandrake Linux0a install help07 In most cases, the best way to get started is to simply press the 0e<Enter>07 key. If you experience problems with standard install, try one of the following install types (type the highlighted text and press 0e<Enter>07): o 0fvgalo07 for low resolution graphical installation. o 0ftext07 for text installation instead of the graphical one. o 0flinux07 for standard graphical installation at normal resolution. o 0fexpert07 for expert graphical installation at normal resolution. To use this CD to repair an already installed system type 0frescue07 followed by 0e<Enter>07. You can also pass some 0f<specific kernel options>07 to the Linux kernel. For example, try 0flinux mem=128M07 if your system has 128Mb of RAM but the default kernel ($main) does not detect it correctly. 0cNOTE07: You cannot pass options to modules (SCSI, ethernet card) or devices such as CD-ROM drives in this way. If you need to do so, use expert mode. " . (-e "isolinux/boot.msg" ? "0c[F1-Help] [F2-Advanced Help] [F3-Main]07" : "0c[F1-Help] [F2-Advanced Help]07") . "\n"; output "isolinux/advanced.msg", (-e "isolinux/boot.msg" && pack "C*", 0x0E, 0x80, 0x03, 0x00) . " The following install types may be used instead of previously notified : o 0fvgahi07 for high resolution graphical installation. o 0fvga1607 for 640x480 in 16 colors graphical installation. The following options may be added on the command line : o 0freadonly=107 to disable editing disk partitions. o 0fdisplay=ackbar:007 to export display to 09ackbar07 machine screen 0 during installation. o 0fnoauto07 to disable automatic detection (generally used with 0fexpert07). o 0fsecurity=n07 to set security level to value 09n07. o 0fupdatemodules07 to use the special update floppy containing modules updates. o 0fpatch07 to use a patch from the floppy (file named 09patch.pl07). o 0fauto_install=floppy07 to enable auto_install using 09auto_inst.cfg07 file on the floppy. You can choose the following kernels : " . join('', map_index { " o 0falt$::i07 is kernel $_\n" } @kernels) . " " . (-e "isolinux/boot.msg" ? "0c[F1-Help] [F2-Advanced Help] [F3-Main]07" : "0c[F1-Help] [F2-Advanced Help]07") . "\n"; }