From: <ef...@sy...> - 2007-04-10 14:29:07
|
Author: efocht Date: 2007-04-10 09:28:57 -0500 (Tue, 10 Apr 2007) New Revision: 4017 Added: trunk/initrd_source/skel/etc/dhclient-script.si-prefix Removed: trunk/initrd_source/skel/etc/dhclient-script.systemimager-prefix Modified: trunk/initrd_source/skel/etc/init.d/functions trunk/lib/SystemImager/UseYourOwnKernel.pm Log: Added support for minix filesystem initrd. The opensuse10.2 kernel has only minix builtin. To my failures to use a UYOK cpio built initramfs on opensuse10.2 this was the only workaround. The minix filesystem allows filename lengths of maximum 30 characters. This means the longest filenmae in the initrd skeleton had to be shortened. Copied: trunk/initrd_source/skel/etc/dhclient-script.si-prefix (from rev 4016, trunk/initrd_source/skel/etc/dhclient-script.systemimager-prefix) =================================================================== --- trunk/initrd_source/skel/etc/dhclient-script.si-prefix (rev 0) +++ trunk/initrd_source/skel/etc/dhclient-script.si-prefix 2007-04-10 14:28:57 UTC (rev 4017) @@ -0,0 +1,101 @@ +#!/bin/sh +# +# "SystemImager" +# +# Copyright (C) 2000 Brian Elliott Finley +# <br...@bg...> +# Copyright (C) 2002-2003 Bald Guy Software +# <br...@bg...> +# +# $Id$ +# +# See http://www.iana.org/assignments/bootp-dhcp-parameters for details +# on custom options (new_option_NNN) as viewed below. -BEF- +# +# option-100 -> IMAGESERVER (depricated -> actually reserved for "printer name") +# option-140 -> IMAGESERVER +# option-141 -> LOG_SERVER_PORT +# option-142 -> SSH_DOWNLOAD_URL +# option-143 -> FLAMETHROWER_DIRECTORY_PORTBASE +# option-144 -> TMPFS_STAGING +# option-208 -> SSH_DOWNLOAD_URL (deprecated) +# disabled by JRT 2006-10-11 +# see dhclient.conf for commentary + +### BEGIN SystemImager stuff part 0 ### +FILE="/tmp/dhcp_info.$interface" + +echo "# This file was generated by /etc/dhclient-start" > $FILE + +echo "HOSTNAME=$new_host_name" >> $FILE +echo "DOMAINNAME=$new_domain_name" >> $FILE + +################################################################################ +# +# Originally we assumed the DHCP server was the imageserver, then we started +# using option-100 (turns out option-100 is reserved for "printer name"), +# now we use option-140 (reserved for "private use"). The following +# funkification is for backwards compatibility with servers using older +# dhcp.conf files. -BEF- +# +if [ ! -z $new_option_140 ]; then + IMAGESERVER=$new_option_140 + echo "Using option-140 as IMAGESERVER: $IMAGESERVER" + +elif [ ! -z $new_option_100 ]; then + IMAGESERVER=$new_option_100 + echo "Using option-100 (deprecated) as IMAGESERVER: $IMAGESERVER" + +elif [ ! -z $new_dhcp_server_identifier ]; then + IMAGESERVER=$new_dhcp_server_identifier + echo "Using DHCP server (very deprecated) as IMAGESERVER: $IMAGESERVER" + +fi + +echo "IMAGESERVER=$IMAGESERVER" >> $FILE + +echo "LOG_SERVER=$new_log_servers" >> $FILE +echo "LOG_SERVER_PORT=$new_option_141" >> $FILE + +echo "DEVICE=$interface" >> $FILE +echo "IPADDR=$new_ip_address" >> $FILE +echo "NETMASK=$new_subnet_mask" >> $FILE +echo "NETWORK=$new_network_number" >> $FILE +echo "BROADCAST=$new_broadcast_address" >> $FILE +echo "FLAMETHROWER_DIRECTORY_PORTBASE=$new_option_143" >> $FILE +echo "TMPFS_STAGING=$new_option_144" >> $FILE +echo "GATEWAY=$new_routers" >> $FILE +echo "GATEWAYDEV=$interface" >> $FILE + + +################################################################################ +# +# Originally we used option-208 here, but pxelinux started using it too, so +# we switched to using option-142. The following funkification is for +# backwards compatibility with servers using older dhcp.conf files. -BEF- +# +if [ ! -z $new_option_142 ]; then + SSH_DOWNLOAD_URL=$new_option_142 + +#elif [ ! -z $new_option_208 ]; then +# SSH_DOWNLOAD_URL=$new_option_208 +# disabled by JRT 2006-10-11 (see dhclient.conf for commentary) +# +fi +echo "SSH_DOWNLOAD_URL=$SSH_DOWNLOAD_URL" >> $FILE + +### END SystemImager stuff part 0 ### + + + + + + + + + + + + + + Deleted: trunk/initrd_source/skel/etc/dhclient-script.systemimager-prefix =================================================================== --- trunk/initrd_source/skel/etc/dhclient-script.systemimager-prefix 2007-04-07 13:35:36 UTC (rev 4016) +++ trunk/initrd_source/skel/etc/dhclient-script.systemimager-prefix 2007-04-10 14:28:57 UTC (rev 4017) @@ -1,101 +0,0 @@ -#!/bin/sh -# -# "SystemImager" -# -# Copyright (C) 2000 Brian Elliott Finley -# <br...@bg...> -# Copyright (C) 2002-2003 Bald Guy Software -# <br...@bg...> -# -# $Id$ -# -# See http://www.iana.org/assignments/bootp-dhcp-parameters for details -# on custom options (new_option_NNN) as viewed below. -BEF- -# -# option-100 -> IMAGESERVER (depricated -> actually reserved for "printer name") -# option-140 -> IMAGESERVER -# option-141 -> LOG_SERVER_PORT -# option-142 -> SSH_DOWNLOAD_URL -# option-143 -> FLAMETHROWER_DIRECTORY_PORTBASE -# option-144 -> TMPFS_STAGING -# option-208 -> SSH_DOWNLOAD_URL (deprecated) -# disabled by JRT 2006-10-11 -# see dhclient.conf for commentary - -### BEGIN SystemImager stuff part 0 ### -FILE="/tmp/dhcp_info.$interface" - -echo "# This file was generated by /etc/dhclient-start" > $FILE - -echo "HOSTNAME=$new_host_name" >> $FILE -echo "DOMAINNAME=$new_domain_name" >> $FILE - -################################################################################ -# -# Originally we assumed the DHCP server was the imageserver, then we started -# using option-100 (turns out option-100 is reserved for "printer name"), -# now we use option-140 (reserved for "private use"). The following -# funkification is for backwards compatibility with servers using older -# dhcp.conf files. -BEF- -# -if [ ! -z $new_option_140 ]; then - IMAGESERVER=$new_option_140 - echo "Using option-140 as IMAGESERVER: $IMAGESERVER" - -elif [ ! -z $new_option_100 ]; then - IMAGESERVER=$new_option_100 - echo "Using option-100 (deprecated) as IMAGESERVER: $IMAGESERVER" - -elif [ ! -z $new_dhcp_server_identifier ]; then - IMAGESERVER=$new_dhcp_server_identifier - echo "Using DHCP server (very deprecated) as IMAGESERVER: $IMAGESERVER" - -fi - -echo "IMAGESERVER=$IMAGESERVER" >> $FILE - -echo "LOG_SERVER=$new_log_servers" >> $FILE -echo "LOG_SERVER_PORT=$new_option_141" >> $FILE - -echo "DEVICE=$interface" >> $FILE -echo "IPADDR=$new_ip_address" >> $FILE -echo "NETMASK=$new_subnet_mask" >> $FILE -echo "NETWORK=$new_network_number" >> $FILE -echo "BROADCAST=$new_broadcast_address" >> $FILE -echo "FLAMETHROWER_DIRECTORY_PORTBASE=$new_option_143" >> $FILE -echo "TMPFS_STAGING=$new_option_144" >> $FILE -echo "GATEWAY=$new_routers" >> $FILE -echo "GATEWAYDEV=$interface" >> $FILE - - -################################################################################ -# -# Originally we used option-208 here, but pxelinux started using it too, so -# we switched to using option-142. The following funkification is for -# backwards compatibility with servers using older dhcp.conf files. -BEF- -# -if [ ! -z $new_option_142 ]; then - SSH_DOWNLOAD_URL=$new_option_142 - -#elif [ ! -z $new_option_208 ]; then -# SSH_DOWNLOAD_URL=$new_option_208 -# disabled by JRT 2006-10-11 (see dhclient.conf for commentary) -# -fi -echo "SSH_DOWNLOAD_URL=$SSH_DOWNLOAD_URL" >> $FILE - -### END SystemImager stuff part 0 ### - - - - - - - - - - - - - - Modified: trunk/initrd_source/skel/etc/init.d/functions =================================================================== --- trunk/initrd_source/skel/etc/init.d/functions 2007-04-07 13:35:36 UTC (rev 4016) +++ trunk/initrd_source/skel/etc/init.d/functions 2007-04-10 14:28:57 UTC (rev 4017) @@ -1009,7 +1009,7 @@ # combine systemimager code to the stock debian dhclient-script # and make executable - cat /etc/dhclient-script.systemimager-prefix \ + cat /etc/dhclient-script.si-prefix \ /etc/dhclient-script.debian-dist \ > /etc/dhclient-script chmod +x /etc/dhclient-script Modified: trunk/lib/SystemImager/UseYourOwnKernel.pm =================================================================== --- trunk/lib/SystemImager/UseYourOwnKernel.pm 2007-04-07 13:35:36 UTC (rev 4016) +++ trunk/lib/SystemImager/UseYourOwnKernel.pm 2007-04-10 14:28:57 UTC (rev 4017) @@ -530,7 +530,7 @@ open(FILESYSTEMS,"<$file") or die("Couldn't open $file for reading."); while (<FILESYSTEMS>) { chomp; - push (@filesystems, $_) if (m/(cramfs|ext2|ext3|reiserfs|xfs|jfs)/); + push (@filesystems, $_) if (m/(cramfs|ext2|ext3|reiserfs|xfs|jfs|minix)/); } close(FILESYSTEMS); @@ -543,6 +543,15 @@ $fs = "cramfs"; } + # minix + elsif ((grep { /minix/ } @filesystems) + and (! -e "$modules_dir/kernel/fs/minix/minix.o") + and (! -e "$modules_dir/kernel/fs/minix/minix.ko") + and (! -e "$modules_dir/kernel/fs/minix/minix.ko.gz") + ) { + $fs = "minix"; + } + # ext2 elsif ((grep { /ext2/ } @filesystems) and (! -e "$modules_dir/kernel/fs/ext2/ext2.o") @@ -751,6 +760,8 @@ _create_initrd_jfs($staging_dir, $boot_dir); } elsif ($fs eq 'xfs') { _create_initrd_xfs($staging_dir, $boot_dir); + } elsif ($fs eq 'minix') { + _create_initrd_minix($staging_dir, $boot_dir); } elsif ($fs eq 'cpio') { _create_initrd_cpio($staging_dir, $boot_dir); } else { @@ -882,6 +893,63 @@ return 1; } +sub _create_initrd_minix($$) { + + my $staging_dir = shift; + my $boot_dir = shift; + + my $new_initrd = $boot_dir . "/initrd"; + + my $new_initrd_mount_dir = _mk_tmp_dir(); + + # cleanup routine. + $SIG{__DIE__} = sub { + my $msg = shift; + run_cmd("umount $new_initrd_mount_dir", $verbose, 0) if ($is_mounted); + unlink($new_initrd) if (-f $new_initrd); + run_cmd("rm -fr $staging_dir $new_initrd_mount_dir", $verbose, 1); + die $msg; + }; + + print ">>> New initrd mount point: $new_initrd_mount_dir\n" if($verbose); + eval { mkpath($new_initrd_mount_dir, 0, 0755) }; + if ($@) { + die "Couldn't mkpath $new_initrd_mount_dir $@"; + } + + my $cmd; + + # loopback file + chomp(my $size = `du -ks $staging_dir`); + $size =~ s/\s+.*$//; + my $breathing_room = 2000; + $size = $size + $breathing_room; + run_cmd("dd if=/dev/zero of=$new_initrd bs=1024 count=$size", $verbose, 1); + + # fs creation + chomp(my $inodes = `find $staging_dir -printf "%i\n" | sort -u | wc -l`); + $inodes = $inodes + 10; + run_cmd("mkfs -t minix -i $inodes $new_initrd", $verbose, 1); + + # mount + run_cmd("mount $new_initrd $new_initrd_mount_dir -o loop -t minix", $verbose); + $is_mounted = 1; + + # copy from staging dir to new initrd + run_cmd("tar -C $staging_dir -cf - . | tar -C $new_initrd_mount_dir -xf -", $verbose, 0); + + # umount and gzip up + run_cmd("umount $new_initrd_mount_dir", $verbose); + $is_mounted = 0; + run_cmd("gzip -f -9 -S .img $new_initrd", $verbose); + run_cmd("ls -l $new_initrd.img", $verbose, 1) if($verbose); + + # cleanup the temporary mount dir + run_cmd("rm -fr $new_initrd_mount_dir", $verbose, 1); + + return 1; +} + sub _create_initrd_ext2($$) { my $staging_dir = shift; |