2 # febootstrap-supermin-helper
3 # (C) Copyright 2009 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Written by Richard W.M. Jones <rjones@redhat.com>
26 -n febootstrap-supermin-helper -- "$@"`
28 echo "febootstrap-supermin-helper: problem parsing the command line arguments"
35 echo "Usage: febootstrap-supermin-helper supermin.img hostfiles.txt kernel initrd"
36 echo "Please read febootstrap-supermin-helper(8) man page for more information."
53 echo "Internal error!"
73 rm -f "$kernel" "$initrd"
76 # Look for the most recent kernel named vmlinuz-*.<arch>* which has a
77 # corresponding directory in /lib/modules/. If the architecture is x86, look
80 # RHEL 5 didn't append the arch to the kernel name, so look for kernels
81 # without arch second.
83 arch=$(echo "@host_cpu@" | sed 's/^i.86$/i?86/')
85 ls -1dvr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen ||: ;
86 ls -1dvr /boot/vmlinuz-* 2>/dev/null | grep -v xen
89 if [ -z "$kernels" ]; then
90 echo "$0: failed to find a suitable kernel in /boot directory" >&2
96 b=$(echo "$b" | sed 's,vmlinuz-,,')
97 modpath="/lib/modules/$b"
98 if [ -d "$modpath" ]; then
105 if [ -z "$modpath" ]; then
106 echo "$0: failed to find a suitable kernel" >&2
110 # The initrd consists of these components:
111 # (1) The base skeleton appliance that we constructed at build time.
112 # format = plain cpio (could be compressed cpio)
113 # (2) The modules from modpath which are on the module whitelist.
114 # format = plain cpio
115 # (3) The host files which match wildcards in hostfiles.
116 # format = plain cpio
118 cp "$supermin" "$initrd" ;# (1)
120 # Kernel modules (2).
122 if [ -n "$kmods" ]; then
125 while read kmod 0<&5; do
126 whitelist="$whitelist -o -name $kmod"
130 whitelist="-o -name *.ko"
133 find "$modpath" \( -not -name '*.ko' $whitelist \) -a -print0 |
134 cpio --quiet -o -0 -H newc >> "$initrd"
138 hostfiles=$(readlink -f "$hostfiles")
140 ls -1df $(cat "$hostfiles") 2>/dev/null |
141 cpio -C 65536 --quiet -o -H newc ) >> "$initrd"