Correctly handle the case when select runs out of filehandles.
[libguestfs.git] / make-initramfs.sh.in
index c8deae2..0812edb 100755 (executable)
@@ -39,7 +39,7 @@ rm -f $output $koutput
 # Create the basic initramfs.
 @FEBOOTSTRAP@ $modules @REPO@ initramfs @MIRROR@
 
-# Nuke some stuff.  The kernel pulls in plymouth crapola which pulls in
+# Nuke some stuff.  The kernel pulls mkinitrd and plymouth which pulls in
 # all of Python.  Sheez.
 find initramfs -name '*plymouth*' -print0 | xargs -0 rm -rf
 find initramfs -name '*python*' -print0 | xargs -0 rm -rf
@@ -55,29 +55,29 @@ rm -rf initramfs/lib/modules/*/kernel/arch/x86/kvm
 mv initramfs/boot/vmlinuz* $koutput
 rm -rf initramfs/boot
 
-# Older versions of febootstrap-minimize didn't remove this, so:
-rm -rf initramfs/usr/share/gnome/help
-
 # Minimize the image.
 @FEBOOTSTRAP_MINIMIZE@ initramfs
 
 # Add some missing configuration files.
 if [ ! -f initramfs/etc/hosts ]; then
-    cat > initramfs/etc/hosts <<'__EOF__'
+    cat > initramfs/etc/hosts.new <<'__EOF__'
 127.0.0.1 guestfs localhost.localdomain localhost
 ::1       localhost6.localdomain6 localhost6
 __EOF__
+    @FEBOOTSTRAP_RUN@ initramfs -- \
+       install -m 0644 -o root -g root /etc/hosts.new /etc/hosts
+    rm initramfs/etc/hosts.new
 fi
 
 if [ ! -f initramfs/etc/fstab ]; then
-    touch initramfs/etc/fstab
+    @FEBOOTSTRAP_RUN@ initramfs -- touch /etc/fstab
 fi
 
 # Copy the daemon into the filesystem.
 #cp daemon/guestfsd initramfs/sbin
 
 # Create the init script.
-cat > initramfs/init <<'__EOF__'
+cat > initramfs/init.new <<'__EOF__'
 #!/bin/sh
 PATH=/sbin:/usr/sbin:$PATH
 MAKEDEV mem null port zero core full ram tty console fd \
@@ -96,15 +96,17 @@ rpc.mountd
 __EOF__
 
 if [ "x$debug" != "xyes" ]; then
-    echo exec guestfsd -f >> initramfs/init
+    echo exec guestfsd -f >> initramfs/init.new
 else
-    echo guestfsd >> initramfs/init
-    echo exec bash -i >> initramfs/init
+    echo guestfsd >> initramfs/init.new
+    echo exec bash -i >> initramfs/init.new
 fi
 
-chmod +x initramfs/init
+@FEBOOTSTRAP_RUN@ initramfs -- install -m 0755 -o root -g root /init.new /init
+rm initramfs/init.new
 
 # Generate final image.
 @FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t
 mv $output-t $output
 ls -lh $output
+ls -lh $koutput