From: Richard Jones Date: Fri, 3 Apr 2009 00:13:42 +0000 (+0100) Subject: Add update-initramfs.sh.in so we don't need to rebuild initramfs for X-Git-Tag: 0.4~42 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=207056e82372093fa5bc678a9e55a2abc33704fa Add update-initramfs.sh.in so we don't need to rebuild initramfs for small changes in the daemon. --- diff --git a/.gitignore b/.gitignore index 8d79766..ebfc2a3 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,5 @@ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 stamp-h1 +update-initramfs.sh vmlinuz.* diff --git a/Makefile.am b/Makefile.am index 31cb6e3..05613bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,17 +33,21 @@ VMLINUZ = vmlinuz.$(REPO).$(host_cpu) 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 $@ - bash $(builddir)/make-initramfs.sh + bash $(builddir)/update-initramfs.sh touch $@ # Make clean. -CLEANFILES = $(fs_DATA) initramfs.timestamp emptydisk +CLEANFILES = $(fs_DATA) emptydisk clean-local: rm -rf initramfs diff --git a/configure.ac b/configure.ac index 03bdb9e..69a55f2 100644 --- a/configure.ac +++ b/configure.ac @@ -91,7 +91,8 @@ AC_CONFIG_SUBDIRS([daemon]) 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? diff --git a/make-initramfs.sh.in b/make-initramfs.sh.in index 0812edb..aaaa92e 100755 --- a/make-initramfs.sh.in +++ b/make-initramfs.sh.in @@ -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@ -rm -f $output $koutput +rm -f $output +rm -f $koutput # 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) -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 @@ -73,9 +74,6 @@ if [ ! -f initramfs/etc/fstab ]; then @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 @@ -105,6 +103,12 @@ fi @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 diff --git a/update-initramfs.sh.in b/update-initramfs.sh.in new file mode 100755 index 0000000..89f629c --- /dev/null +++ b/update-initramfs.sh.in @@ -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