Add update-initramfs.sh.in so we don't need to rebuild initramfs for
authorRichard Jones <rjones@redhat.com>
Fri, 3 Apr 2009 00:13:42 +0000 (01:13 +0100)
committerRichard Jones <rjones@redhat.com>
Fri, 3 Apr 2009 00:13:42 +0000 (01:13 +0100)
small changes in the daemon.

.gitignore
Makefile.am
configure.ac
make-initramfs.sh.in
update-initramfs.sh.in [new file with mode: 0755]

index 8d79766..ebfc2a3 100644 (file)
@@ -36,4 +36,5 @@ m4/ltsugar.m4
 m4/ltversion.m4
 m4/lt~obsolete.m4
 stamp-h1
 m4/ltversion.m4
 m4/lt~obsolete.m4
 stamp-h1
+update-initramfs.sh
 vmlinuz.*
 vmlinuz.*
index 31cb6e3..05613bb 100644 (file)
@@ -33,17 +33,21 @@ VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
 
 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
 
 
 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
 
-$(VMLINUZ) $(INITRAMFSIMG): initramfs.timestamp
+$(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
 
 
-#initramfs.timestamp: make-initramfs.sh.in daemon/guestfsd
-initramfs.timestamp: make-initramfs.sh.in
+initramfs/fakeroot.log: make-initramfs.sh.in
+       -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
+       -mv $(VMLINUZ) $(VMLINUZ).bak
+       bash $(builddir)/make-initramfs.sh || rm -f $@
+
+$(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
        rm -f $@
        rm -f $@
-       bash $(builddir)/make-initramfs.sh
+       bash $(builddir)/update-initramfs.sh
        touch $@
 
 # Make clean.
 
        touch $@
 
 # Make clean.
 
-CLEANFILES = $(fs_DATA) initramfs.timestamp emptydisk
+CLEANFILES = $(fs_DATA) emptydisk
 
 clean-local:
        rm -rf initramfs
 
 clean-local:
        rm -rf initramfs
index 03bdb9e..69a55f2 100644 (file)
@@ -91,7 +91,8 @@ AC_CONFIG_SUBDIRS([daemon])
 
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
 
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile make-initramfs.sh])
+AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile
+                make-initramfs.sh update-initramfs.sh])
 AC_OUTPUT
 
 dnl WTF?
 AC_OUTPUT
 
 dnl WTF?
index 0812edb..aaaa92e 100755 (executable)
@@ -34,7 +34,8 @@ fi
 # Decide on names for the final output.  These have to match Makefile.am.
 output=initramfs.@REPO@.@host_cpu@.img
 koutput=vmlinuz.@REPO@.@host_cpu@
 # Decide on names for the final output.  These have to match Makefile.am.
 output=initramfs.@REPO@.@host_cpu@.img
 koutput=vmlinuz.@REPO@.@host_cpu@
-rm -f $output $koutput
+rm -f $output
+rm -f $koutput
 
 # Create the basic initramfs.
 @FEBOOTSTRAP@ $modules @REPO@ initramfs @MIRROR@
 
 # Create the basic initramfs.
 @FEBOOTSTRAP@ $modules @REPO@ initramfs @MIRROR@
@@ -47,7 +48,7 @@ find initramfs -name '*python*' -print0 | xargs -0 rm -rf
 # Modules take up nearly half of the image.  It's a rough guess that
 # we don't need any drivers (which take up most of the space).
 # (We need to keep kernel/net/sunrpc for NFS)
 # Modules take up nearly half of the image.  It's a rough guess that
 # we don't need any drivers (which take up most of the space).
 # (We need to keep kernel/net/sunrpc for NFS)
-rm -rf initramfs/lib/modules/*/kernel/{drivers,sound}
+#rm -rf initramfs/lib/modules/*/kernel/{drivers,sound}
 rm -rf initramfs/lib/modules/*/kernel/arch/x86/kvm
 
 # Pull the kernel out into the current directory.  We don't want it in
 rm -rf initramfs/lib/modules/*/kernel/arch/x86/kvm
 
 # Pull the kernel out into the current directory.  We don't want it in
@@ -73,9 +74,6 @@ if [ ! -f initramfs/etc/fstab ]; then
     @FEBOOTSTRAP_RUN@ initramfs -- touch /etc/fstab
 fi
 
     @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.new <<'__EOF__'
 #!/bin/sh
 # Create the init script.
 cat > initramfs/init.new <<'__EOF__'
 #!/bin/sh
@@ -105,6 +103,12 @@ fi
 @FEBOOTSTRAP_RUN@ initramfs -- install -m 0755 -o root -g root /init.new /init
 rm initramfs/init.new
 
 @FEBOOTSTRAP_RUN@ initramfs -- install -m 0755 -o root -g root /init.new /init
 rm initramfs/init.new
 
+# Copy the daemon into the filesystem.
+cp @abs_builddir@/daemon/guestfsd initramfs/sbin/guestfsd.new
+@FEBOOTSTRAP_RUN@ initramfs -- \
+  install -m 0755 -o root -g root /sbin/guestfsd.new /sbin/guestfsd
+rm initramfs/sbin/guestfsd.new
+
 # Generate final image.
 @FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t
 mv $output-t $output
 # Generate final image.
 @FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t
 mv $output-t $output
diff --git a/update-initramfs.sh.in b/update-initramfs.sh.in
new file mode 100755 (executable)
index 0000000..89f629c
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash -
+# @configure_input@
+# Copyright (C) 2009 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# Update the daemon inside an existing initramfs.  Avoids the
+# timeconsuming rebuild.
+
+set -e
+
+output=initramfs.@REPO@.@host_cpu@.img
+
+# Copy the daemon into the filesystem.
+cp @abs_builddir@/daemon/guestfsd initramfs/sbin/guestfsd.new
+@FEBOOTSTRAP_RUN@ initramfs -- \
+  install -m 0755 -o root -g root /sbin/guestfsd.new /sbin/guestfsd
+rm initramfs/sbin/guestfsd.new
+
+# Generate final image.
+@FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t
+mv $output-t $output
+ls -lh $output