Rename guestfs-supermin-helper -> libguestfs-supermin-helper.
[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         libguestfs-supermin-helper \
21         kmod.whitelist \
22         kmod.whitelist.in
23
24 # Build the root filesystem (appliance).
25 # Currently this is arch-dependent, so it seems like putting it in
26 # $(libdir) is best.  When we build cross-architecture filesystems we
27 # should probably move them to $(datadir).
28 fsdir = $(libdir)/guestfs
29 fs_DATA = $(APPLIANCE_FILES)
30
31 # These are the resulting output files from the whole process:
32 #   VMLINUZ        kernel for the full appliance
33 #   INITRAMFSIMG   initramfs (ie. root fs) for the full appliance
34 # For details of the supermin appliance, read the README file:
35 #   SUPERMINIMG    initramfs (ie. partial root fs) for the supermin appliance
36 #   SUPERMINFILES  list of missing files (the ones we will pull out of the
37 #                    host filesystem at runtime) in the supermin appliance
38 APPLIANCE_FILES = $(INITRAMFSIMG) $(VMLINUZ)
39 if SUPERMIN
40 APPLIANCE_FILES += $(SUPERMINIMG) $(SUPERMINFILES) kmod.whitelist
41 bin_SCRIPTS = libguestfs-supermin-helper
42 endif
43
44 # Don't change these names - they must be the same as in '*.sh' scripts.
45 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
46 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
47 if SUPERMIN
48 SUPERMINIMG = initramfs.$(REPO).$(host_cpu).supermin.img
49 SUPERMINFILES = initramfs.$(REPO).$(host_cpu).supermin.hostfiles
50 endif
51
52 # This is for building the normal appliance:
53 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
54
55 $(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist
56         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
57         -mv $(VMLINUZ) $(VMLINUZ).bak
58         if ! bash make.sh; then rm -f $@; exit 1; fi
59
60 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd update.sh
61         rm -f $@
62         bash update.sh
63         touch $@
64
65 kmod.whitelist: kmod.whitelist.in
66         grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@
67
68 # This is for building the supermin appliance.  It has to be enabled
69 # specifically with './configure --enable-supermin'.  You really need
70 # to read the README file.
71
72 if SUPERMIN
73
74 # First we need to decide which files go in and out of the supermin
75 # appliance.  This decision is made by 'supermin-split.sh'.
76 $(SUPERMINFILES): supermin.incfiles
77 supermin.incfiles: $(top_builddir)/initramfs/fakeroot.log supermin-split.sh
78         rm -f supermin.incfiles $(SUPERMINFILES)
79         bash supermin-split.sh
80
81 # Second we need to create a supermin appliance with just the included
82 # files (leaving out the host files, which we'll add back at runtime).
83 $(SUPERMINIMG): supermin.incfiles supermin-make.sh
84         rm -f $@
85         bash supermin-make.sh
86
87 endif
88
89 # This should rebuild the scripts if the input files change, although
90 # it doesn't always seem to work.
91 %.sh: %.sh.in
92         cd .. && ./config.status appliance/$@
93         chmod +x $@
94
95 libguestfs-supermin-helper: libguestfs-supermin-helper.in
96         cd .. && ./config.status appliance/$@
97         chmod +x $@
98
99 #----------------------------------------------------------------------
100 # Extra rules for testing the appliance.
101
102 # Test-boot the appliance.
103
104 test-boot: emptydisk
105         qemu-system-$(host_cpu) \
106           -m 384 \
107           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
108           -hda emptydisk
109
110 emptydisk:
111         rm -f emptydisk
112         dd if=/dev/zero of=emptydisk bs=1024 count=1440
113         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
114
115 # This is a more realistic test boot command line which better
116 # reflects what the library does.
117
118 test-boot-realistic: emptydisk
119         qemu-system-$(host_cpu) \
120           -m 384 \
121           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
122           -hda emptydisk \
123           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
124           -nographic \
125           -serial stdio \
126           -net channel,6666:unix:/tmp/sock,server,nowait \
127           -net user,vlan=0 \
128           -net nic,model=virtio,vlan=0
129
130 # Make clean.
131
132 CLEANFILES = $(APPLIANCE_FILES)
133
134 clean-local:
135         rm -rf $(top_builddir)/initramfs
136