066becbbef37f32a19ef71d17516fc00eb7ac495
[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-initramfs.sh update-initramfs.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
26 fsdir = $(libdir)/guestfs
27
28 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
29 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
30
31 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
32
33 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
34
35 $(top_builddir)/initramfs/fakeroot.log: make-initramfs.sh.in
36         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
37         -mv $(VMLINUZ) $(VMLINUZ).bak
38         if ! bash make-initramfs.sh; then rm -f $@; exit 1; fi
39
40 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd
41         rm -f $@
42         bash update-initramfs.sh
43         touch $@
44
45 make-initramfs.sh: make-initramfs.sh.in
46         cd .. && ./config.status appliance/$@
47
48 # Test-boot the image.
49
50 test-boot: emptydisk
51         qemu-system-$(host_cpu) \
52           -m 384 \
53           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
54           -hda emptydisk
55
56 emptydisk:
57         rm -f emptydisk
58         dd if=/dev/zero of=emptydisk bs=1024 count=1440
59         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
60
61 # This is a more realistic test boot command line which better
62 # reflects what the library does.
63
64 test-boot-realistic: emptydisk
65         qemu-system-$(host_cpu) \
66           -m 384 \
67           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
68           -hda emptydisk \
69           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
70           -nographic \
71           -serial stdio \
72           -net channel,6666:unix:/tmp/sock,server,nowait \
73           -net user,vlan=0 \
74           -net nic,model=virtio,vlan=0
75
76 # Make clean.
77
78 CLEANFILES = $(fs_DATA)
79
80 clean-local:
81         rm -rf $(top_builddir)/initramfs
82