9353e1785a2744603404333ac5979036b5597edf
[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 EXTRA_DIST = \
19         helloworld.tar \
20         helloworld.tar.gz \
21         mbr-ext2-empty.img.gz \
22         empty known-1 known-2 known-3
23
24 noinst_DATA = test.sqsh
25
26 CLEANFILES = \
27         test.sqsh \
28         100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
29         initrd
30
31 squash_files_src = \
32     $(srcdir)/helloworld.tar \
33     $(srcdir)/helloworld.tar.gz \
34     $(srcdir)/empty \
35     $(srcdir)/known-1 \
36     $(srcdir)/known-2 \
37     $(srcdir)/known-3
38
39 squash_files_build = \
40     $(builddir)/100kallzeroes \
41     $(builddir)/100kallnewlines \
42     $(builddir)/100kallspaces \
43     $(builddir)/100krandom \
44     $(builddir)/10klines \
45     $(builddir)/initrd
46
47 squash_files = $(squash_files_src) $(squash_files_build)
48
49 test.sqsh: $(squash_files)
50         rm -f $@
51         $(MKSQUASHFS) $(squash_files) $@
52
53 100kallzeroes:
54         rm -f $@ $@-t
55         dd if=/dev/zero of=$@-t bs=1024 count=100
56         mv $@-t $@
57
58 100kallnewlines: 100kallzeroes
59         rm -f $@ $@-t
60         tr '\0' '\n' < $< > $@-t
61         mv $@-t $@
62
63 100kallspaces: 100kallzeroes
64         rm -f $@ $@-t
65         tr '\0' ' ' < $< > $@-t
66         mv $@-t $@
67
68 100krandom:
69         rm -f $@ $@-t
70         dd if=/dev/urandom of=$@-t bs=1024 count=100
71         mv $@-t $@
72
73 10klines:
74         rm -f $@ $@-t
75         i=0; \
76         while [ $$i -lt 10000 ]; do \
77           echo "$${i}abcdefghijklmnopqrstuvwxyz"; \
78           i=$$(($$i+1)); \
79         done > $@-t
80         mv $@-t $@
81
82 initrd: empty known-1 known-2 known-3
83         rm -f $@ $@-t
84         for f in $^; do echo $$f; done | cpio -o -H newc | gzip --best > $@-t
85         mv $@-t $@