images: Make a better phony Fedora image.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 16 Nov 2010 15:41:16 +0000 (15:41 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 18 Nov 2010 11:59:05 +0000 (11:59 +0000)
This now includes a product string, major and minor version,
hostname and even some applications.
(cherry picked from commit 6d4815d3a4921219379bc9ec3cceead217668426)

.gitignore
images/Makefile.am
images/guest-aux/fedora-name.db.txt [new file with mode: 0644]
images/guest-aux/make-fedora-img.sh [moved from images/make-dummy-fedora-img.sh with 80% similarity]
tools/test-virt-ls.sh
tools/test-virt-tar.sh

index 6254ffd..88a0b5f 100644 (file)
@@ -115,6 +115,7 @@ images/100krandom
 images/10klines
 images/abssymlink
 images/fedora.img
+images/guest-aux/fedora-name.db
 images/hello.b64
 images/initrd
 images/initrd-x86_64.img
index b1b4855..a2eb199 100644 (file)
@@ -37,7 +37,9 @@ EXTRA_DIST = \
        lib-win64.dll \
        lib-x86_64.so \
        test-grep.txt \
-       make-dummy-fedora-img.sh
+       guest-aux/make-fedora-img.sh \
+       guest-aux/fedora-name.db.txt \
+       guest-aux/fedora-name.db
 
 noinst_DATA = test.iso
 
@@ -157,7 +159,10 @@ $(builddir)/test-grep.txt.gz: test-grep.txt
        mv $@-t $@
 
 # Make a (dummy) Fedora image.
-fedora.img: make-dummy-fedora-img.sh
+fedora.img: guest-aux/make-fedora-img.sh guest-aux/fedora-name.db
        LIBGUESTFS_PATH=../appliance \
        LD_LIBRARY_PATH=../src/.libs \
        bash $<
+
+guest-aux/fedora-name.db: guest-aux/fedora-name.db.txt
+       db_load $@ < $<
diff --git a/images/guest-aux/fedora-name.db.txt b/images/guest-aux/fedora-name.db.txt
new file mode 100644 (file)
index 0000000..105b0fe
--- /dev/null
@@ -0,0 +1,13 @@
+VERSION=3
+format=print
+type=hash
+h_nelem=3
+db_pagesize=4096
+HEADER=END
+ test1
+ !\0b\00\00\00\00\00\00
+ test2
+ 7\0b\00\00\00\00\00\00
+ test3
+ \dd\0c\00\00\00\00\00\00
+DATA=END
similarity index 80%
rename from images/make-dummy-fedora-img.sh
rename to images/guest-aux/make-fedora-img.sh
index 635ad10..3198930 100755 (executable)
@@ -24,8 +24,7 @@
 export LANG=C
 set -e
 
-rm -f fedora.img
-
+# fstab file.
 cat > fstab.tmp <<EOF
 LABEL=BOOT /boot ext2 default 0 0
 LABEL=ROOT / ext2 default 0 0
@@ -33,7 +32,7 @@ EOF
 
 # Create a disk image.
 ../fish/guestfish <<'EOF'
-sparse fedora.img- 512M
+sparse fedora.img.tmp 512M
 run
 
 # Format the disk.
@@ -51,19 +50,32 @@ lvcreate LV3 VG 64
 # Phony /boot filesystem.
 mkfs-b ext2 4096 /dev/sda1
 set-e2label /dev/sda1 BOOT
+set-e2uuid /dev/sda1 01234567-0123-0123-0123-012345678901
 
 # Phony root filesystem.
 mkfs-b ext2 4096 /dev/VG/Root
 set-e2label /dev/VG/Root ROOT
+set-e2uuid /dev/VG/Root 01234567-0123-0123-0123-012345678902
 
-# Enough to fool virt-inspector.
+# Enough to fool inspection API.
 mount-options "" /dev/VG/Root /
 mkdir /boot
 mount-options "" /dev/sda1 /boot
 mkdir /bin
 mkdir /etc
+mkdir /etc/sysconfig
 mkdir /usr
+mkdir-p /var/lib/rpm
+
 upload fstab.tmp /etc/fstab
+write /etc/redhat-release "Fedora release 14 (Phony)"
+write /etc/fedora-release "Fedora release 14 (Phony)"
+write /etc/sysconfig/network "HOSTNAME=fedora.invalid"
+
+upload guest-aux/fedora-name.db /var/lib/rpm/Name
+
+upload bin-x86_64-dynamic /bin/ls
+
 mkdir /boot/grub
 touch /boot/grub/grub.conf
 
@@ -86,4 +98,4 @@ mkfs-b ext2 2048 /dev/VG/LV3
 EOF
 
 rm fstab.tmp
-mv fedora.img- fedora.img
+mv fedora.img.tmp fedora.img
index c8330d2..a0c9fc5 100755 (executable)
@@ -7,7 +7,8 @@ set -e
 uuid=868b1447-0ec5-41bf-a2e5-6a77a4c9b66f
 
 # Read out the test directory using virt-ls.
-if [ "$(./virt-ls ../images/fedora.img /bin)" != "test1
+if [ "$(./virt-ls ../images/fedora.img /bin)" != "ls
+test1
 test2
 test3
 test4
index 40cee90..2239c13 100755 (executable)
@@ -7,6 +7,7 @@ set -e
 ./virt-tar -x ../images/fedora.img /bin test.tar
 
 if [ "$(tar tf test.tar)" != "./
+./ls
 ./test1
 ./test2
 ./test3