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 # This is called from the Makefile to build the initramfs.
26 if [ "@DIST@" = "REDHAT" ]; then
28 # Decide on names for the final output. These have to match Makefile.am.
29 output=appliance/initramfs.@REPO@.@host_cpu@.img
30 koutput=appliance/vmlinuz.@REPO@.@host_cpu@
34 # Create the basic initramfs.
35 exec 5<appliance/packagelist
37 while read pkg 0<&5; do
38 packages="$packages -i $pkg"
42 @FEBOOTSTRAP@ $packages -u @UPDATES@ @REPO@ initramfs @MIRROR@
44 # /sysroot is where the guest root filesystem will be mounted.
45 @FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /sysroot
47 # Create /tmp if it is missing.
48 @FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /tmp
50 # Nuke some stuff. The kernel pulls mkinitrd and plymouth which pulls in
51 # all of Python. Sheez.
52 (cd initramfs && find -name '*plymouth*' -print0) |
53 xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf
54 (cd initramfs && find -name '*python*' -print0) |
55 xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf
57 # In Fedora >= 11, it pulls in all of Perl from somewhere. Nuke from orbit.
58 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/perl5 /usr/lib64/perl5
60 # Anaconda? JPEG images?
61 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/anaconda-runtime
63 # Don't need any firmware.
64 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /lib/firmware
66 # Don't need any keyboard maps.
67 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /lib/kbd
69 # Remove anything in home directory. Because of the potential for disaster
70 # we don't put a slash before 'home'.
71 (cd initramfs && echo home/*) |
72 xargs @FEBOOTSTRAP_RUN@ initramfs -- rm -rf
74 # Remove /var/lib/yum stuff.
75 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /var/lib/yum
77 # Remove some unreadable binaries which are incompatible with
78 # the supermin appliance. Since these binaries can't be read
79 # from the host filesystem, they generate warnings like:
80 # cpio: ./usr/bin/chfn: Cannot open: Permission denied
81 # These binaries are not needed for operation of the appliance.
82 @FEBOOTSTRAP_RUN@ initramfs -- rm -f \
85 /usr/libexec/pt_chown \
89 /usr/sbin/tzdata-update \
95 $(cd initramfs && echo usr/sbin/glibc_post_upgrade.*)
97 # Kernel modules take up nearly half of the image. Only include ones
98 # which are on the whitelist.
99 exec 5<appliance/kmod.whitelist
101 while read kmod 0<&5; do
102 whitelist="$whitelist -a -not -name $kmod"
107 find lib/modules/*/kernel -name '*.ko' $whitelist -a -print0 ) |
108 xargs -0 febootstrap-run initramfs -- rm
110 # Pull the kernel out into the current directory. We don't want it in
111 # the initramfs image.
112 cp initramfs/boot/vmlinuz* $koutput
113 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf boot
115 # Minimize the image.
116 @FEBOOTSTRAP_MINIMIZE@ initramfs
118 # Add some missing configuration files.
119 if [ ! -f initramfs/etc/hosts ]; then
120 cat > hosts.new <<'__EOF__'
121 127.0.0.1 guestfs localhost.localdomain localhost
122 ::1 localhost6.localdomain6 localhost6
124 @FEBOOTSTRAP_INSTALL@ initramfs hosts.new /etc/hosts 0644 root.root
128 if [ ! -f initramfs/etc/fstab ]; then
129 @FEBOOTSTRAP_RUN@ initramfs -- touch /etc/fstab
132 echo nameserver 10.0.2.3 > resolv.conf.new
133 @FEBOOTSTRAP_INSTALL@ initramfs resolv.conf.new /etc/resolv.conf 0644 root.root
138 # Now directly run the update script to copy/update the daemon in the
140 cd appliance && bash update.sh
142 elif [ "@DIST@" = "DEBIAN" ]; then
143 cd @top_builddir@/appliance
144 debirf make -n debian
145 mkdir -p @top_builddir@/initramfs
146 touch @top_builddir@/initramfs/fakeroot.log