Experimental implementation of the supermin appliance (passes most tests).
[libguestfs.git] / appliance / Makefile.am
1 # libguestfs
2 # Copyright (C) 2009 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 EXTRA_DIST = \
19         make.sh update.sh supermin-split.sh supermin-make.sh
20
21 # Build the root filesystem (appliance).
22 # Currently this is arch-dependent, so it seems like putting it in
23 # $(libdir) is best.  When we build cross-architecture filesystems we
24 # should probably move them to $(datadir).
25 fsdir = $(libdir)/guestfs
26 fs_DATA = $(APPLIANCE_FILES)
27
28 # These are the resulting output files from the whole process:
29 #   VMLINUZ        kernel for the full appliance
30 #   INITRAMFSIMG   initramfs (ie. root fs) for the full appliance
31 # For details of the supermin appliance, read the README file:
32 #   SUPERMINIMG    initramfs (ie. partial root fs) for the supermin appliance
33 #   SUPERMINFILES  list of missing files (the ones we will pull out of the
34 #                    host filesystem at runtime) in the supermin appliance
35 APPLIANCE_FILES = $(INITRAMFSIMG) $(VMLINUZ)
36 if SUPERMIN
37 APPLIANCE_FILES += $(SUPERMINIMG) $(SUPERMINFILES) kmod.whitelist
38 bin_SCRIPTS = guestfs-supermin-helper
39 endif
40
41 # Don't change these names - they must be the same as in '*.sh' scripts.
42 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
43 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
44 if SUPERMIN
45 SUPERMINIMG = initramfs.$(REPO).$(host_cpu).supermin.img
46 SUPERMINFILES = initramfs.$(REPO).$(host_cpu).supermin.hostfiles
47 endif
48
49 # This is for building the normal appliance:
50 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
51
52 $(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist
53         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
54         -mv $(VMLINUZ) $(VMLINUZ).bak
55         if ! bash make.sh; then rm -f $@; exit 1; fi
56
57 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd update.sh
58         rm -f $@
59         bash update.sh
60         touch $@
61
62 kmod.whitelist: kmod.whitelist.in
63         grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@
64
65 # This is for building the supermin appliance.  It has to be enabled
66 # specifically with './configure --enable-supermin'.  You really need
67 # to read the README file.
68
69 if SUPERMIN
70
71 # First we need to decide which files go in and out of the supermin
72 # appliance.  This decision is made by 'supermin-split.sh'.
73 $(SUPERMINFILES): supermin.incfiles
74 supermin.incfiles: $(top_builddir)/initramfs/fakeroot.log supermin-split.sh
75         rm -f supermin.incfiles $(SUPERMINFILES)
76         bash supermin-split.sh
77
78 # Second we need to create a supermin appliance with just the included
79 # files (leaving out the host files, which we'll add back at runtime).
80 $(SUPERMINIMG): supermin.incfiles supermin-make.sh
81         rm -f $@
82         bash supermin-make.sh
83
84 endif
85
86 # This should rebuild the scripts if the input files change, although
87 # it doesn't always seem to work.
88 %.sh: %.sh.in
89         cd .. && ./config.status appliance/$@
90         chmod +x $@
91
92 guestfs-supermin-helper: guestfs-supermin-helper.in
93         cd .. && ./config.status appliance/$@
94         chmod +x $@
95
96 #----------------------------------------------------------------------
97 # Extra rules for testing the appliance.
98
99 # Test-boot the appliance.
100
101 test-boot: emptydisk
102         qemu-system-$(host_cpu) \
103           -m 384 \
104           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
105           -hda emptydisk
106
107 emptydisk:
108         rm -f emptydisk
109         dd if=/dev/zero of=emptydisk bs=1024 count=1440
110         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
111
112 # This is a more realistic test boot command line which better
113 # reflects what the library does.
114
115 test-boot-realistic: emptydisk
116         qemu-system-$(host_cpu) \
117           -m 384 \
118           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
119           -hda emptydisk \
120           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
121           -nographic \
122           -serial stdio \
123           -net channel,6666:unix:/tmp/sock,server,nowait \
124           -net user,vlan=0 \
125           -net nic,model=virtio,vlan=0
126
127 # Make clean.
128
129 CLEANFILES = $(APPLIANCE_FILES)
130
131 clean-local:
132         rm -rf $(top_builddir)/initramfs
133