3 # Copyright (C) 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 # Helper script which constructs the supermin appliance at runtime.
25 # Source directory containing the supermin input files.
26 sourcedir=$(cd "$1" > /dev/null; pwd)
33 # Look for the most recent kernel named vmlinuz-*.<arch>* which has a
34 # corresponding directory in /lib/modules/. If the architecture is x86, look
37 arch=$(echo "@host_cpu@" | sed 's/^i.86$/i?86/')
38 for f in $(ls -1vr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen); do
40 b=$(echo "$b" | sed 's,vmlinuz-,,')
41 modpath="/lib/modules/$b"
42 if [ -d "$modpath" ]; then
49 if [ -z "$modpath" ]; then
50 echo "$0: failed to find a suitable kernel" >&2
54 # The initrd consists of these components:
55 # (1) The base skeleton appliance that we constructed at build time.
56 # name = initramfs.@REPO@.@host_cpu@.supermin.img
57 # format = compressed cpio
58 # (2) The modules from modpath which are on the module whitelist.
60 # (3) The host files which match wildcards in *.supermin.hostfiles.
63 cp "$sourcedir"/initramfs.@REPO@.@host_cpu@.supermin.img "$initrd"
66 exec 5<"$sourcedir"/kmod.whitelist
68 while read kmod 0<&5; do
69 whitelist="$whitelist -o -name $kmod"
73 find "$modpath" \( -not -name '*.ko' $whitelist \) -a -print0 |
74 cpio --quiet -o -0 -H newc >> "$initrd"
80 cat "$sourcedir"/initramfs.@REPO@.@host_cpu@.supermin.hostfiles
82 cpio --quiet -o -H newc ) >> "$initrd"