Initial revision

This commit is contained in:
Michael Brown
2005-05-17 16:44:57 +00:00
parent 75a5374d79
commit 1097cf8685
164 changed files with 24592 additions and 0 deletions

76
contrib/mkffwnb/2.0.10/linuxrc Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/sh
#
# floppyfw initfile
#
# nicked from:
# hal91's initfile (/linuxrc), the bootup script of the system
#
VERSION=2.1.6
load_fsmod () {
case $1 in
/dev/hd*)
insmod ide-cd
insmod cdrom
;;
esac
case $2 in
vfat)
echo vfat support is builtin
;;
iso9660)
insmod isofs
;;
esac
}
#
/bin/busybox echo "Booting floppyfw"
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
#PATH="/bin"
TERM=linux
ignoreeof=10
no_exit_on_failed_exec=yes
export PATH TERM ignoreeof
umask 022
/bin/busybox echo "mounting: proc"
/bin/busybox mount -t proc /proc /proc
/bin/busybox echo "Generating links. (Thanks to busybox.lineo.com)"
/bin/busybox --install -s
echo "Generated"
# Modified by Gem, based on coyote distro, changes by Ken Yap
ROOTDEV=`sed -e 's/$/ /' -e 's/.*root=\([^ ]*\) .*/\1/' -e 's/,/ /g' -e 's:/dev/nfs:/dev/fd0:' /proc/cmdline`
set -- $ROOTDEV
# Backward compatibility with a single device argument
if [ $# -eq 1 ]
then
set -- $1 vfat
fi
while [ "$1" -a "$2" ]
do
echo "attempting to mount $1 ($2)"
load_fsmod $1 $2
if mount -t $2 $1 /mnt/tmp
then
echo "mounted $1 on /mnt/tmp"
break
fi
shift; shift
done
[ -f /mnt/tmp/floppyfw/floppyfw.ini ] && cat /mnt/tmp/floppyfw/floppyfw.ini \
| tr -d '\015' >/floppyfw.ini
[ -f /floppyfw.ini ] && chmod 777 /floppyfw.ini
[ -f /floppyfw.ini ] && exec /floppyfw.ini
echo
echo "** floppyfw.ini failed.. starting a shell"
echo
exec sh

View File

@@ -0,0 +1,43 @@
#!/usr/bin/perl -w
sub status_system ($$) {
my ($command, $message) = @_;
$status = system($command);
$status <<= 8;
if ($status < 0) {
print STDERR "$!\n";
}
if ($status != 0) {
print STDERR "$message\n";
}
}
sub extendinitrd ($$) {
my ($initrd, $nblocks) = @_;
if ($nblocks <= 1440) {
print STDERR "nblocks must be >= 1440\n";
return (1);
}
(undef, $type, undef, $fnlen, undef) = split(' ', `file $initrd`, 5);
print "$type $fnlen\n";
if ($type ne 'Minix' || $fnlen != 30) {
die "Can only handle Minix initrds with 30 char filenames\n";
return (1);
}
status_system("dd if=/dev/zero of=newinitrd bs=1k count=$nblocks", "Cannot create new initrd\n");
status_system("mkfs.minix -n 30 newinitrd $nblocks", "Cannot mkfs.minix new initrd\n");
mkdir("initrd.from") || print STDERR "Cannot make temp mount point initrd.from\n";
mkdir("initrd.to") || print STDERR "Cannot make temp mount point initrd.to\n";
status_system("mount -o ro,loop $initrd initrd.from", "Cannot mount $initrd on initrd.from");
status_system("mount -o loop newinitrd initrd.to", "Cannot mount newinitrd on initrd.to");
status_system("cp -a initrd.from/* initrd.to/", "Cannot copy initrd to newinitrd");
status_system("umount initrd.from", "Cannot umount initrd.from");
status_system("umount initrd.to", "Cannot umount initrd.to");
rmdir("initrd.from") || print STDERR "Cannot remove temp mount point initrd.from\n";
rmdir("initrd.to") || print STDERR "Cannot remove temp mount point initrd.to\n";
return (0);
}
1;

69
contrib/mkffwnb/README Normal file
View File

@@ -0,0 +1,69 @@
This is a quick and dirty script to convert a floppyfw floppy
(http://www.zelow.no/floppyfw/) to a tagged image for booting with
Etherboot (http://etherboot.sourceforge.net/). The advantages of network
booting include: it's much faster loading from the network than from a
floppy disk, you can boot from any size floppy, and you are not limited
to the maximum of 1.44 MB of the physical floppy. If you have enough RAM
and use a virtual floppy to build the initial boot image, you can put as
much on it as will fit the ramdisk.
See further down under -nonet if you want to boot from HD or CDROM.
This program requires mtools, tar, bzip2, loopback mount in the kernel,
and root privileges to execute. Hope you have them.
This script works for any of the releases for which a subdirectory of
that name is provided, but it should not be too hard to make it work for
other releases, all that is done here is to substitute some scripts for
the distributed ones.
First of all you should make the floppy work the way you want before
converting it to a tagged image. This involves editing the various
config files on the floppy. Instructions on this are distributed from
the floppyfw web page mentioned above.
Edit the $tftpdir assignment for the directory where you put your tagged
images. Edit the $libdir assignment and the use lib directive near the
top if you decide to put this package somewhere other than
/usr/local/lib/mkffwnb/. Adjust the instructions below as necessary.
Copy everything to $libdir.
mkdir -p /usr/local/lib/mkffwnb/
cp -a . /usr/local/lib/mkffwnb/
Make a link from /usr/local/lib/mkffwnb/mkffwnb.pl to
/usr/local/bin/mkffwnb so that it's in your path.
ln -s /usr/local/lib/mkffwnb/mkffwnb.pl /usr/local/bin/mkffwnb
Then run it as:
mkffwnb
You can also provide a floppy drive as an argument, e.g.
mkffwnb x:
where x: could be mapped to a disk file. This allows you to build an
image without a real floppy drive. Remember that for virtual drives root
must have the mapping for the drive in question in ~root/.mtoolsrc.
You can use the option --localtime=/etc/localtime to specify that the
file /etc/localtime is to be copied to /etc/localtime on the initrd.
Instead of /etc/localtime, you can use any of the timezone files under
/usr/share/zoneinfo/, it's just that /etc/localtime will usually be the
correct one for your timezone.
If you use the option -nonet, it leaves the intermediate files in
$tempdir, /tmp/mkffwnb by default. This is useful if you want the
vmlinuz and initrd.gz files for use with LILO or isolinux to boot from
HD or CDROM. Actually you can also use these with a floppy, it loads
faster if you fold all the scripts and modules into the initrd ahead
of time.
mkffwnb has to be run as root because it uses loopback mounts and also
because the files inside the initrd are owned by root.
Ken Yap
2003-04-20

226
contrib/mkffwnb/mkffwnb.pl Executable file
View File

@@ -0,0 +1,226 @@
#!/usr/bin/perl -w
#
# Perl script to make a bootable image from a floppyfw floppy
# The basic idea is to unpack and replace or convert all
# the necessary config files into the initrd
# and then make a bootable image out of it
#
# The --format= option overrides the default of nbi or elf hardcoded
# in the source. Valid arguments are nbi or elf.
#
# The --output= options specifies an output file instead of stdout
# The --nonet option specifies that a netbootable image is not to
# be built but the vmlinuz and initrd.gz files left behind in $tempdir
# The --localtime=f option specifies a timezone file that's to be
# copied to /etc/localtime in the initrd, allowing a different timezone.
# The --ffw29 option is intended for 2.9.x and above and extends
# the size of the initrd by making a bigger one and copying the original over.
#
# The first non-option argument is taken to be the letter of a floppy to
# convert, e.g. a:, b: or even x: where x: is mapped to a file using
# mtools mapping in $HOME/.mtoolsrc. See the mtools documentation.
# Thus you can work on a floppy image in a disk file and only write
# to a floppy with dd or cp when you need to test the image.
use Getopt::Long;
use lib '/usr/local/lib/mkffwnb/';
use Extendinitrd;
use strict;
use vars qw($testing $verbose $localtime $nonet $format $ffw29 $imagefile
$floppy $libdir $tftpdir $output $tempdir $tempmount);
sub findversion () {
my ($version) = grep(/FloppyFW/, `mtype $imagefile ${floppy}floppyfw.msg`);
return '' unless defined($version) and $version ne '';
chomp($version);
$version =~ s/.*FloppyFW (\d+\.\d+\.\d+(\.\d+)?).*/$1/;
return ($version);
}
sub getappendargs () {
my ($append) = join(' ', grep(/^\s*(append\s|console=)/, `mtype $imagefile ${floppy}syslinux.cfg`));
chomp ($append);
my @args = split(/\s+/, $append);
my @result = ();
foreach $_ (@args) {
next if (/^$/ or /^append/ or /^initrd=/);
next if (!$ffw29 and /^root=/);
push (@result, $_);
}
return (join(' ', @result));
}
# Copy whole floppy to the current directory
# m preserves timestamps, n overwrites without warning and / means recursive
sub mcopy ($) {
my ($tempdir) = @_;
print "mcopy $imagefile -mn/ ${floppy}* $tempdir\n";
my $status = system("mcopy -mn/ $imagefile ${floppy}* $tempdir");
return ($status / 256);
}
# Gunzip file, -f forces overwriting of uncompressed file
sub gunzip ($) {
my ($file) = @_;
print "Gunzipping $file\n" if ($verbose);
my $status = system('gunzip', '-f', $file);
return ($status / 256);
}
# Gzip file, -f forces overwriting of compressed file
sub gzip ($) {
my ($file) = @_;
print "Gzipping $file\n" if ($verbose);
my $status = system('gzip', '-9', '-f', $file);
return ($status / 256);
}
sub loopbackmount ($$) {
my ($file, $point) = @_;
print "Mounting $file on $point loopback\n" if ($verbose);
my $status = system('mount', '-o', 'loop', $file, $point);
return ($testing ? 0 : $status / 256);
}
sub loopbackumount ($) {
my ($point) = @_;
print "Umounting $point\n" if ($verbose);
my $status = system('umount', $point);
return ($testing ? 0 : $status / 256);
}
# Convert DOS CR-NL to Unix NL. $dst has implied prefix of $tempmount
# Use @output for temporary storage in case we write back to the same file
sub dostounix ($$) {
my ($src, $dst) = @_;
my @output = ();
$dst = "$tempmount/$dst";
print "Converting $src to $dst\n" if ($verbose);
unless (open(S, $src)) {
print "$src: $!\n";
return (0);
}
while (<S>) {
chomp;
tr /\015//d;
push(@output, $_);
}
close(S);
open(D, ">$dst") or return;
for $_ (@output) {
print D "$_\n";
}
close(D);
chmod(0755, $dst);
return (1);
}
sub bunzip2untar ($$) {
my ($file, $dir) = @_;
print "Unpacking $file into $dir\n" if ($verbose);
system("bunzip2 < $file | (cd $dir; tar xf -)");
}
$testing = $< != 0;
$verbose = 1;
$format = '';
$imagefile = '';
GetOptions('output=s' => \$output,
'nonet!' => \$nonet,
'localtime=s' => \$localtime,
'format=s' => \$format,
'ffw29!' => \$ffw29,
'ffw30!' => \$ffw29,
'i=s' => \$imagefile);
if (defined($output) and $output !~ m(^/)) {
my $d = `pwd`;
chomp($d);
$output = "$d/$output";
}
if ($imagefile) {
$imagefile = "-i $imagefile";
}
$libdir = '/usr/local/lib/mkffwnb';
$tftpdir = '/usr/local/var/tftpboot';
# default can also be 'elf'
$format = 'nbi' if ($format ne 'elf' and $format ne 'nbi');
$floppy = $#ARGV >= 0 ? $ARGV[0] : 'a:';
print <<EOF;
This program requires mtools, tar, bzip2, loopback mount in the kernel,
and root privileges to execute. Hope you have them.
EOF
my $version = &findversion();
$version ne '' or die "Cannot determine version\n";
print "Version $version\n";
my $append = &getappendargs();
$append = "--append='$append'" if $append ne '';
print "$append\n";
$libdir .= '/' . $version;
-d $libdir or die "Cannot find files for $version\n";
$tempdir = $nonet ? '/tmp/mkffwnb' : "/tmp/mkffwnb$$";
$tempmount = 'tmpmount';
mkdir($tempdir, 0755);
print "Copying files off floppy, please be patient...\n";
&mcopy($tempdir) == 0 or die "Mcopy failed, diskette problem?\n";
chdir($tempdir);
&gunzip('initrd.gz') == 0 or die "Gunzip of initrd.gz failed\n";
if ($ffw29) {
extendinitrd("initrd", 5760);
system("mv newinitrd initrd");
}
mkdir($tempmount, 0755);
&loopbackmount('initrd', $tempmount) == 0 or die "Loopback mount failed\n";
&dostounix("$libdir/linuxrc", "linuxrc") if (-r "$libdir/linuxrc");
unless (&dostounix("$libdir/floppyfw.ini", "floppyfw.ini")) {
&dostounix("floppyfw/floppyfw.ini", $ffw29 ? "etc/floppyfw.ini" : "floppyfw.ini");
}
&dostounix("config", $ffw29 ? "etc/config.prelogin" : "etc/config");
for my $i (glob('*.bz2 floppyfw/add.bz2 modules/*.bz2 packages/*.bz2')) {
&bunzip2untar($i, $tempmount);
}
for my $i (glob('packages/*.ini')) {
my $file = $i;
$file =~ s:packages/::;
&dostounix($i, "etc/$file");
}
&dostounix("hosts", "etc/hosts");
&dostounix("modules.lst", "etc/modules.lst");
&dostounix("network.ini", "etc/network.init");
&dostounix("firewall.ini", "etc/firewall.init");
&dostounix("syslog.cfg", "etc/syslog.conf");
&dostounix("packages/timeinfo", "etc/localtime");
system("cp -p licenses/* $tempmount/licenses/");
# This conditional code is for 1.1.2 and below
unless (glob('modules/*.bz2')) {
print "Copying additional modules\n" if ($verbose);
system("cp -p modules/* $tempmount/lib/modules/");
}
# If a timezone file has been specified, copy that onto initrd
if (defined($localtime)) {
if (-r $localtime) {
print "Copying $localtime to $tempmount/etc/localtime\n";
system("cp -p $localtime $tempmount/etc/localtime");
} else {
print "$localtime: $!\n";
}
}
&loopbackumount($tempmount) == 0 or die "Loopback umount failed\n";
&gzip('initrd') == 0 or die "Gzip of initrd failed\n";
if ($nonet) {
print "Floppyfw directory in $tempdir\n";
} else {
print "Calling mk$format-linux to make the netbootable image\n" if ($verbose);
$output = "$tftpdir/floppyfw-$version.nb" if (!defined($output));
system("mk$format-linux $append --output=$output vmlinuz initrd.gz");
system("rm -fr $tempdir");
}