appliance: Change comment about unreadable binaries.
[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 include $(top_srcdir)/subdir-rules.mk
19
20 EXTRA_DIST = \
21         kmod.whitelist.in \
22         packagelist.in \
23         init \
24         debian/modules/install_kernel \
25         debian/modules/y0_install-guestfsd \
26         debian/modules/z99_final-cleanups \
27         debian/debirf.conf.in \
28         make.sh.in
29
30 # Build the root filesystem (appliance).
31 # Currently this is arch-dependent, so it seems like putting it in
32 # $(libdir) is best.  When we build cross-architecture filesystems we
33 # should probably move them to $(datadir).
34 fsdir = $(libdir)/guestfs
35 superminfsdir = $(libdir)/guestfs/supermin.d
36
37 # These are the resulting output files from the whole process:
38 #   VMLINUZ        kernel for the full appliance
39 #   INITRAMFSIMG   initramfs (ie. root fs) for the full appliance
40 # For details of the supermin appliance, read the README file.
41 fs_DATA = $(INITRAMFSIMG) $(VMLINUZ)
42 if SUPERMIN
43 fs_DATA += kmod.whitelist
44 superminfs_DATA = \
45         supermin.d/base.img \
46         supermin.d/daemon.img \
47         supermin.d/hostfiles
48 endif
49
50 # Don't change these names - they must be the same as in '*.sh' scripts.
51 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
52 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
53
54 # This is for building the normal appliance:
55 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
56
57 $(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist packagelist $(top_builddir)/daemon/guestfsd
58         mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak 2>/dev/null; :
59         mv $(VMLINUZ) $(VMLINUZ).bak 2>/dev/null; :
60         if ! bash make.sh; then rm -f $@; exit 1; fi
61
62 # This used to be a configure-generated file (as is update.sh still).
63 # However config.status always touches the destination file, which
64 # means the appliance got rebuilt too often.
65 make.sh: make.sh.in
66         cd $(top_builddir) && \
67           ./config.status --file=appliance/$@-t:appliance/$<
68         chmod +x $@-t
69         mv $@-t $@
70
71 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd init update.sh
72         rm -f $@
73         bash update.sh
74         touch $@
75
76 kmod.whitelist: kmod.whitelist.in
77         grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@
78
79 packagelist: packagelist.in
80         cpp -undef -D$(DIST)=1 < $< | \
81         grep -v '^[[:space:]]*$$' | grep -v '^#' > $@
82
83 # This is for building the supermin appliance.  It has to be enabled
84 # specifically with './configure --enable-supermin'.  You really need
85 # to read the README file.
86
87 if SUPERMIN
88
89 supermin.d/base.img supermin.d/hostfiles: stamp-supermin
90 stamp-supermin: $(INITRAMFSIMG)
91         mkdir -p supermin.d
92         rm -f $@ supermin.d/base.img supermin.d/hostfiles
93         febootstrap-to-supermin $(top_builddir)/initramfs supermin.d/base.img supermin.d/hostfiles
94         touch $@
95
96 supermin.d/daemon.img: $(INITRAMFSIMG)
97         mkdir -p supermin.d
98         rm -f $@ $@-t
99         (cd $(top_builddir)/initramfs && \
100           echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc ) > $@-t
101         mv $@-t $@
102 endif
103
104 # Extra symlinks needed by the Debian appliance.
105 debirf_symlinks = \
106         a0_prep-root \
107         z0_remove-aptitude \
108         z0_remove-locales \
109         z1_clean-root
110 noinst_DATA = $(debirf_symlinks:%=debian/modules/%)
111 $(debirf_symlinks:%=debian/modules/%): stamp-debirf-modules
112 stamp-debirf-modules:
113         mkdir -p debian/modules
114         for f in $(debirf_symlinks); do \
115           ln -sf /usr/share/debirf/modules/$$f debian/modules/$$f; \
116         done
117         touch $@
118
119 #----------------------------------------------------------------------
120 # Extra rules for testing the appliance.
121
122 # Test-boot the appliance.
123
124 test-boot: emptydisk
125         qemu-system-$(host_cpu) \
126           -m 384 \
127           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
128           -hda emptydisk
129
130 emptydisk:
131         rm -f emptydisk
132         dd if=/dev/zero of=emptydisk bs=1024 count=1440
133         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
134
135 # This is a more realistic test boot command line which better
136 # reflects what the library does.
137
138 test-boot-realistic: emptydisk
139         qemu-system-$(host_cpu) \
140           -m 384 \
141           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
142           -hda emptydisk \
143           -append "console=ttyS0 guestfs=10.0.2.4:6666 guestfs_rescue=1" \
144           -nographic \
145           -serial stdio \
146           -net channel,6666:unix:/tmp/sock,server,nowait \
147           -net user,vlan=0 \
148           -net nic,model=virtio,vlan=0
149
150 # Make clean.
151
152 CLEANFILES = packagelist kmod.whitelist
153
154 clean-local:
155         rm -f supermin.d/*
156         rm -rf $(top_builddir)/initramfs