3c30df5aecbcd51fc06e6a3f67d9909e8d1d5213
[libguestfs.git] / images / Makefile.am
1 # libguestfs test images
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 # Old RHEL 5 autoconf doesn't have builddir.
19 builddir ?= $(top_builddir)/images
20
21 EXTRA_DIST = \
22         helloworld.tar \
23         helloworld.tar.gz \
24         mbr-ext2-empty.img.gz \
25         empty known-1 known-2 known-3 known-4 known-5 \
26         bin-i586-dynamic \
27         bin-sparc-dynamic \
28         bin-win32.exe \
29         bin-win64.exe \
30         bin-x86_64-dynamic \
31         lib-i586.so \
32         lib-sparc.so \
33         lib-win32.dll \
34         lib-win64.dll \
35         lib-x86_64.so \
36         test-grep.txt
37
38 noinst_DATA = test.sqsh
39
40 CLEANFILES = \
41         test.sqsh \
42         100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
43         initrd
44
45 squash_files_src = \
46         $(srcdir)/helloworld.tar \
47         $(srcdir)/helloworld.tar.gz \
48         $(srcdir)/empty \
49         $(srcdir)/known-1 \
50         $(srcdir)/known-2 \
51         $(srcdir)/known-3 \
52         $(srcdir)/known-4 \
53         $(srcdir)/known-5 \
54         $(srcdir)/bin-i586-dynamic \
55         $(srcdir)/bin-sparc-dynamic \
56         $(srcdir)/bin-win32.exe \
57         $(srcdir)/bin-win64.exe \
58         $(srcdir)/bin-x86_64-dynamic \
59         $(srcdir)/lib-i586.so \
60         $(srcdir)/lib-sparc.so \
61         $(srcdir)/lib-win32.dll \
62         $(srcdir)/lib-win64.dll \
63         $(srcdir)/lib-x86_64.so \
64         $(srcdir)/test-grep.txt
65
66 squash_files_build = \
67         $(builddir)/100kallzeroes \
68         $(builddir)/100kallnewlines \
69         $(builddir)/100kallspaces \
70         $(builddir)/100krandom \
71         $(builddir)/10klines \
72         $(builddir)/initrd \
73         $(builddir)/initrd-x86_64.img \
74         $(builddir)/initrd-x86_64.img.gz \
75         $(builddir)/test-grep.txt.gz
76
77 squash_files = $(squash_files_src) $(squash_files_build)
78
79 test.sqsh: $(squash_files)
80         rm -f $@ $@-t
81         mkdir -p directory
82         $(MKSQUASHFS) $(squash_files) directory $@-t
83         rmdir directory
84         mv $@-t $@
85
86 $(builddir)/100kallzeroes:
87         rm -f $@ $@-t
88         dd if=/dev/zero of=$@-t bs=1024 count=100
89         mv $@-t $@
90
91 $(builddir)/100kallnewlines: $(builddir)/100kallzeroes
92         rm -f $@ $@-t
93         tr '\0' '\n' < $< > $@-t
94         mv $@-t $@
95
96 $(builddir)/100kallspaces: $(builddir)/100kallzeroes
97         rm -f $@ $@-t
98         tr '\0' ' ' < $< > $@-t
99         mv $@-t $@
100
101 $(builddir)/100krandom:
102         rm -f $@ $@-t
103         dd if=/dev/urandom of=$@-t bs=1024 count=100
104         mv $@-t $@
105
106 $(builddir)/10klines:
107         rm -f $@ $@-t
108         i=0; \
109         while [ $$i -lt 10000 ]; do \
110           echo "$${i}abcdefghijklmnopqrstuvwxyz"; \
111           i=$$(($$i+1)); \
112         done > $@-t
113         mv $@-t $@
114
115 $(builddir)/initrd: empty known-1 known-2 known-3 known-4 known-5
116         rm -f $@ $@-t
117         for f in $^; do echo $$f; done | cpio -o -H newc | gzip --best > $@-t
118         mv $@-t $@
119
120 # Create a dummy initrd with a single file called 'bin/nash' which
121 # is used to test the Sys::Guestfs::Lib::file_architecture function.
122 $(builddir)/initrd-x86_64.img: bin-x86_64-dynamic
123         rm -rf bin $@ $@-t
124         mkdir bin
125         cp $< bin/nash
126         echo bin/nash | cpio -o -H newc > $@-t
127         mv $@-t $@
128         rm -rf bin $@-t
129
130 $(builddir)/initrd-x86_64.img.gz: initrd-x86_64.img
131         rm -f $@ $@-t
132         gzip --best -c $< > $@-t
133         mv $@-t $@
134
135 $(builddir)/test-grep.txt.gz: test-grep.txt
136         rm -f $@ $@-t
137         gzip --best -c $< > $@-t
138         mv $@-t $@