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