8c38e5192c02d9bf9be35906023363aa5a908754
[libguestfs.git] / images / guest-aux / make-fedora-img.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2010 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 # Make a standard test image which is used by all the tools test
20 # scripts.  This test image is supposed to look like a Fedora
21 # installation, or at least enough of one to fool the inspection API
22 # heuristics.
23
24 export LANG=C
25 set -e
26
27 # fstab file.
28 cat > fstab.tmp <<EOF
29 LABEL=BOOT /boot ext2 default 0 0
30 LABEL=ROOT / ext2 default 0 0
31 EOF
32
33 # Create a disk image.
34 ../fish/guestfish <<'EOF'
35 sparse fedora.img.tmp 512M
36 run
37
38 # Format the disk.
39 part-init /dev/sda mbr
40 part-add /dev/sda p 64     524287
41 part-add /dev/sda p 524288    -64
42
43 pvcreate /dev/sda2
44 vgcreate VG /dev/sda2
45 lvcreate Root VG 32
46 lvcreate LV1 VG 32
47 lvcreate LV2 VG 32
48 lvcreate LV3 VG 64
49
50 # Phony /boot filesystem.
51 mkfs-opts ext2 /dev/sda1 blocksize:4096
52 set-e2label /dev/sda1 BOOT
53 set-e2uuid /dev/sda1 01234567-0123-0123-0123-012345678901
54
55 # Phony root filesystem.
56 mkfs-opts ext2 /dev/VG/Root blocksize:4096
57 set-e2label /dev/VG/Root ROOT
58 set-e2uuid /dev/VG/Root 01234567-0123-0123-0123-012345678902
59
60 # Enough to fool inspection API.
61 mount-options "" /dev/VG/Root /
62 mkdir /boot
63 mount-options "" /dev/sda1 /boot
64 mkdir /bin
65 mkdir /etc
66 mkdir /etc/sysconfig
67 mkdir /usr
68 mkdir-p /var/lib/rpm
69
70 upload fstab.tmp /etc/fstab
71 write /etc/redhat-release "Fedora release 14 (Phony)"
72 write /etc/fedora-release "Fedora release 14 (Phony)"
73 write /etc/sysconfig/network "HOSTNAME=fedora.invalid"
74
75 upload guest-aux/fedora-name.db /var/lib/rpm/Name
76
77 upload bin-x86_64-dynamic /bin/ls
78
79 mkdir /boot/grub
80 touch /boot/grub/grub.conf
81
82 # Test files.
83 write /etc/test1 "abcdefg"
84 write /etc/test2 ""
85 write /bin/test1 "abcdefg"
86 write /bin/test2 "zxcvbnm"
87 write /bin/test3 "1234567"
88 write /bin/test4 ""
89 ln-s /bin/test1 /bin/test5
90 mkfifo 0777 /bin/test6
91 mknod 0777 10 10 /bin/test7
92
93 # Other filesystems.
94 # Note that these should be empty, for testing virt-df.
95 mkfs-opts ext2 /dev/VG/LV1 blocksize:4096
96 mkfs-opts ext2 /dev/VG/LV2 blocksize:1024
97 mkfs-opts ext2 /dev/VG/LV3 blocksize:2048
98 EOF
99
100 rm fstab.tmp
101 mv fedora.img.tmp fedora.img