Update FSF address.
[libguestfs.git] / images / guest-aux / make-ubuntu-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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 # Make an Ubuntu image which is enough to fool the inspection heuristics.
20
21 export LANG=C
22 set -e
23
24 # fstab file.
25 cat > fstab.tmp <<EOF
26 LABEL=BOOT /boot ext2 default 0 0
27 /dev/sda2 / ext2 default 1 2
28 EOF
29
30 # lsb-release file.
31 cat > release.tmp <<'EOF'
32 DISTRIB_ID=Ubuntu
33 DISTRIB_RELEASE=10.10
34 DISTRIB_CODENAME=maverick
35 DISTRIB_DESCRIPTION="Ubuntu 10.10 (Phony Pharaoh)"
36 EOF
37
38 # Create a disk image.
39 ../run ../fish/guestfish <<EOF
40 sparse ubuntu.img.tmp 512M
41 run
42
43 # Format the disk.
44 part-init /dev/sda mbr
45 part-add /dev/sda p 64     524287
46 part-add /dev/sda p 524288    -64
47
48 # Phony /boot filesystem.
49 mkfs-opts ext2 /dev/sda1 blocksize:4096
50 set-e2label /dev/sda1 BOOT
51 set-e2uuid /dev/sda1 01234567-0123-0123-0123-012345678901
52
53 # Phony root filesystem (Ubuntu doesn't use LVM by default).
54 mkfs-opts ext2 /dev/sda2 blocksize:4096
55 set-e2uuid /dev/sda2 01234567-0123-0123-0123-012345678902
56
57 # Enough to fool inspection API.
58 mount-options "" /dev/sda2 /
59 mkdir /boot
60 mount-options "" /dev/sda1 /boot
61 mkdir /bin
62 mkdir /etc
63 mkdir /home
64 mkdir /usr
65 mkdir-p /var/lib/dpkg
66
67 upload fstab.tmp /etc/fstab
68 write /etc/debian_version "5.0.1"
69 upload release.tmp /etc/lsb-release
70 write /etc/hostname "ubuntu.invalid"
71
72 upload ${SRCDIR}/guest-aux/debian-packages /var/lib/dpkg/status
73
74 upload ${SRCDIR}/bin-x86_64-dynamic /bin/ls
75
76 mkdir /boot/grub
77 touch /boot/grub/grub.conf
78 EOF
79
80 rm fstab.tmp release.tmp
81 mv ubuntu.img.tmp ubuntu.img