images: Make a better phony Fedora image.
[libguestfs.git] / images / Makefile.am
1 # libguestfs test images
2 # Copyright (C) 2009-2010 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 # Old RHEL 5 autoconf doesn't have builddir.
21 builddir ?= $(top_builddir)/images
22
23 EXTRA_DIST = \
24         helloworld.tar \
25         helloworld.tar.gz \
26         helloworld.tar.xz \
27         mbr-ext2-empty.img.gz \
28         empty known-1 known-2 known-3 known-4 known-5 \
29         bin-i586-dynamic \
30         bin-sparc-dynamic \
31         bin-win32.exe \
32         bin-win64.exe \
33         bin-x86_64-dynamic \
34         lib-i586.so \
35         lib-sparc.so \
36         lib-win32.dll \
37         lib-win64.dll \
38         lib-x86_64.so \
39         test-grep.txt \
40         guest-aux/make-fedora-img.sh \
41         guest-aux/fedora-name.db.txt \
42         guest-aux/fedora-name.db
43
44 noinst_DATA = test.iso
45
46 # This is 'check_DATA' because we don't need it until 'make check'
47 # time and we need the tools we have built in order to make it.
48 check_DATA = fedora.img
49
50 CLEANFILES = \
51         test.iso test.sqsh \
52         100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
53         initrd fedora.img
54
55 images_files_src = \
56         $(srcdir)/helloworld.tar \
57         $(srcdir)/helloworld.tar.gz \
58         $(srcdir)/helloworld.tar.xz \
59         $(srcdir)/empty \
60         $(srcdir)/known-1 \
61         $(srcdir)/known-2 \
62         $(srcdir)/known-3 \
63         $(srcdir)/known-4 \
64         $(srcdir)/known-5 \
65         $(srcdir)/bin-i586-dynamic \
66         $(srcdir)/bin-sparc-dynamic \
67         $(srcdir)/bin-win32.exe \
68         $(srcdir)/bin-win64.exe \
69         $(srcdir)/bin-x86_64-dynamic \
70         $(srcdir)/lib-i586.so \
71         $(srcdir)/lib-sparc.so \
72         $(srcdir)/lib-win32.dll \
73         $(srcdir)/lib-win64.dll \
74         $(srcdir)/lib-x86_64.so \
75         $(srcdir)/test-grep.txt
76
77 images_files_build = \
78         $(builddir)/100kallzeroes \
79         $(builddir)/100kallnewlines \
80         $(builddir)/100kallspaces \
81         $(builddir)/100krandom \
82         $(builddir)/10klines \
83         $(builddir)/abssymlink \
84         $(builddir)/hello.b64 \
85         $(builddir)/initrd \
86         $(builddir)/initrd-x86_64.img \
87         $(builddir)/initrd-x86_64.img.gz \
88         $(builddir)/test-grep.txt.gz
89
90 images_files = $(images_files_src) $(images_files_build)
91
92 test.iso: $(images_files)
93         rm -f $@ $@-t
94         mkdir -p directory
95         $(MKISOFS) -J -r -graft-points \
96           -o $@-t \
97           $(images_files) /directory=directory
98         rmdir directory
99         mv $@-t $@
100
101 $(builddir)/100kallzeroes:
102         rm -f $@ $@-t
103         dd if=/dev/zero of=$@-t bs=1024 count=100
104         mv $@-t $@
105
106 $(builddir)/100kallnewlines: $(builddir)/100kallzeroes
107         rm -f $@ $@-t
108         tr '\0' '\n' < $< > $@-t
109         mv $@-t $@
110
111 $(builddir)/100kallspaces: $(builddir)/100kallzeroes
112         rm -f $@ $@-t
113         tr '\0' ' ' < $< > $@-t
114         mv $@-t $@
115
116 $(builddir)/100krandom:
117         rm -f $@ $@-t
118         dd if=/dev/urandom of=$@-t bs=1024 count=100
119         mv $@-t $@
120
121 $(builddir)/10klines:
122         rm -f $@ $@-t
123         i=0; \
124         while [ $$i -lt 10000 ]; do \
125           echo "$${i}abcdefghijklmnopqrstuvwxyz"; \
126           i=$$(($$i+1)); \
127         done > $@-t
128         mv $@-t $@
129
130 $(builddir)/abssymlink:
131         ln -sf /10klines $@
132
133 $(builddir)/hello.b64:
134         echo "hello" | base64 > $@
135
136 $(builddir)/initrd: empty known-1 known-2 known-3 known-4 known-5
137         rm -f $@ $@-t
138         for f in $^; do echo $$f; done | cpio -o -H newc | gzip --best > $@-t
139         mv $@-t $@
140
141 # Create a dummy initrd with a single file called 'bin/nash' which
142 # is used to test the Sys::Guestfs::Lib::file_architecture function.
143 $(builddir)/initrd-x86_64.img: bin-x86_64-dynamic
144         rm -rf bin $@ $@-t
145         mkdir bin
146         cp $< bin/nash
147         echo bin/nash | cpio -o -H newc > $@-t
148         mv $@-t $@
149         rm -rf bin $@-t
150
151 $(builddir)/initrd-x86_64.img.gz: initrd-x86_64.img
152         rm -f $@ $@-t
153         gzip --best -c $< > $@-t
154         mv $@-t $@
155
156 $(builddir)/test-grep.txt.gz: test-grep.txt
157         rm -f $@ $@-t
158         gzip --best -c $< > $@-t
159         mv $@-t $@
160
161 # Make a (dummy) Fedora image.
162 fedora.img: guest-aux/make-fedora-img.sh guest-aux/fedora-name.db
163         LIBGUESTFS_PATH=../appliance \
164         LD_LIBRARY_PATH=../src/.libs \
165         bash $<
166
167 guest-aux/fedora-name.db: guest-aux/fedora-name.db.txt
168         db_load $@ < $<