Added framework for the language bindings.
[libguestfs.git] / update-initramfs.sh.in
1 #!/bin/bash -
2 # @configure_input@
3 # Copyright (C) 2009 Red Hat Inc.
4 #
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.
9 #
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.
14 #
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.
18
19 # Update the daemon inside an existing initramfs.  Avoids the
20 # timeconsuming rebuild.
21
22 set -e
23
24 output=initramfs.@REPO@.@host_cpu@.img
25
26 # Make a safe 'install_file' function to install files into the
27 # filesystem.  XXX We need a 'febootstrap-install' utility.
28 # Usage: install_file <local-file> <target-pathname> mode owner[.group]
29 install_file ()
30 {
31     cp "$1" initramfs/"$2"
32     # Get the inode of the new file and remove it from fakeroot.log.
33     ino=$(ls -i initramfs/"$2" | awk '{print $1}')
34     cp initramfs/fakeroot.log fakeroot.log.old
35     grep -v "ino=$ino," fakeroot.log.old > initramfs/fakeroot.log
36     rm fakeroot.log.old
37     # Set mode, owner and group as desired.
38     @FEBOOTSTRAP_RUN@ initramfs -- chmod "$3" "$2"
39     @FEBOOTSTRAP_RUN@ initramfs -- chown "$4" "$2"
40 }
41
42 # Copy the daemon into the filesystem.
43 install_file @abs_builddir@/daemon/guestfsd /sbin/guestfsd 0755 root.root
44
45 # Generate final image.
46 @FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t
47 mv $output-t $output
48 ls -lh $output