Harald Hoyer 55891e
From ea8e543bb86660dd6ccc3048ae9916358b58a6b3 Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 55891e
Date: Wed, 17 Aug 2011 13:42:16 +0200
Harald Hoyer 55891e
Subject: [PATCH] add TEST-16-DMSQUASH
Harald Hoyer 55891e
Harald Hoyer 55891e
This is a test for Fedora LiveCDs created via livecd-tools
Harald Hoyer 55891e
---
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/99-idesymlinks.rules     |    8 +
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/Makefile                 |   10 ++
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/create.py                |  186 ++++++++++++++++++++++++
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/cryptroot-ask            |    6 +
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/hard-off.sh              |    3 +
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/livecd-fedora-minimal.ks |   22 +++
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/test-init                |   17 ++
Harald Hoyer 55891e
 test/TEST-16-DMSQUASH/test.sh                  |   66 +++++++++
Harald Hoyer 55891e
 8 files changed, 318 insertions(+), 0 deletions(-)
Harald Hoyer 55891e
 create mode 100644 test/TEST-16-DMSQUASH/99-idesymlinks.rules
Harald Hoyer 55891e
 create mode 100644 test/TEST-16-DMSQUASH/Makefile
Harald Hoyer 55891e
 create mode 100644 test/TEST-16-DMSQUASH/create.py
Harald Hoyer 55891e
 create mode 100755 test/TEST-16-DMSQUASH/cryptroot-ask
Harald Hoyer 55891e
 create mode 100755 test/TEST-16-DMSQUASH/hard-off.sh
Harald Hoyer 55891e
 create mode 100644 test/TEST-16-DMSQUASH/livecd-fedora-minimal.ks
Harald Hoyer 55891e
 create mode 100755 test/TEST-16-DMSQUASH/test-init
Harald Hoyer 55891e
 create mode 100755 test/TEST-16-DMSQUASH/test.sh
Harald Hoyer 55891e
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/99-idesymlinks.rules b/test/TEST-16-DMSQUASH/99-idesymlinks.rules
Harald Hoyer 55891e
new file mode 100644
Harald Hoyer 55891e
index 0000000..d557790
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/99-idesymlinks.rules
Harald Hoyer 55891e
@@ -0,0 +1,8 @@
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
Harald Hoyer 55891e
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/Makefile b/test/TEST-16-DMSQUASH/Makefile
Harald Hoyer 55891e
new file mode 100644
Harald Hoyer 55891e
index 0000000..bc0ddb6
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/Makefile
Harald Hoyer 55891e
@@ -0,0 +1,10 @@
Harald Hoyer 55891e
+all:
Harald Hoyer 55891e
+	@make -s --no-print-directory -C ../.. all
Harald Hoyer 55891e
+	@basedir=../.. testdir=../ ./test.sh --all
Harald Hoyer 55891e
+setup:
Harald Hoyer 55891e
+	@make --no-print-directory -C ../.. all
Harald Hoyer 55891e
+	@basedir=../.. testdir=../ ./test.sh --setup
Harald Hoyer 55891e
+clean:
Harald Hoyer 55891e
+	@basedir=../.. testdir=../ ./test.sh --clean
Harald Hoyer 55891e
+run:
Harald Hoyer 55891e
+	@basedir=../.. testdir=../ ./test.sh --run
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/create.py b/test/TEST-16-DMSQUASH/create.py
Harald Hoyer 55891e
new file mode 100644
Harald Hoyer 55891e
index 0000000..15d29ff
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/create.py
Harald Hoyer 55891e
@@ -0,0 +1,186 @@
Harald Hoyer 55891e
+#!/usr/bin/python -tt
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# livecd-creator : Creates Live CD based for Fedora.
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# Copyright 2007, Red Hat  Inc.
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# This program is free software; you can redistribute it and/or modify
Harald Hoyer 55891e
+# it under the terms of the GNU General Public License as published by
Harald Hoyer 55891e
+# the Free Software Foundation; version 2 of the License.
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# This program is distributed in the hope that it will be useful,
Harald Hoyer 55891e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Harald Hoyer 55891e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Harald Hoyer 55891e
+# GNU Library General Public License for more details.
Harald Hoyer 55891e
+#
Harald Hoyer 55891e
+# You should have received a copy of the GNU General Public License
Harald Hoyer 55891e
+# along with this program; if not, write to the Free Software
Harald Hoyer 55891e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+import os
Harald Hoyer 55891e
+import os.path
Harald Hoyer 55891e
+import sys
Harald Hoyer 55891e
+import time
Harald Hoyer 55891e
+import optparse
Harald Hoyer 55891e
+import logging
Harald Hoyer 55891e
+import shutil
Harald Hoyer 55891e
+from distutils.dir_util import copy_tree
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+import imgcreate
Harald Hoyer 55891e
+from imgcreate.fs import makedirs
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+class myLiveImageCreator(imgcreate.x86LiveImageCreator):
Harald Hoyer 55891e
+    def install(self, repo_urls = {}):
Harald Hoyer 55891e
+        copy_tree("root-source", self._instroot)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    def configure(self):
Harald Hoyer 55891e
+        self._create_bootconfig()
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    def _get_kernel_versions(self):
Harald Hoyer 55891e
+        ret = {}
Harald Hoyer 55891e
+        version=os.uname()
Harald Hoyer 55891e
+        version=version[2]
Harald Hoyer 55891e
+        ret["kernel-" + version] = [version]
Harald Hoyer 55891e
+        return ret
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    def __sanity_check(self):
Harald Hoyer 55891e
+        pass
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+class Usage(Exception):
Harald Hoyer 55891e
+    def __init__(self, msg = None, no_error = False):
Harald Hoyer 55891e
+        Exception.__init__(self, msg, no_error)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+def parse_options(args):
Harald Hoyer 55891e
+    parser = optparse.OptionParser()
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    imgopt = optparse.OptionGroup(parser, "Image options",
Harald Hoyer 55891e
+                                  "These options define the created image.")
Harald Hoyer 55891e
+    imgopt.add_option("-c", "--config", type="string", dest="kscfg",
Harald Hoyer 55891e
+                      help="Path or url to kickstart config file")
Harald Hoyer 55891e
+    imgopt.add_option("-b", "--base-on", type="string", dest="base_on",
Harald Hoyer 55891e
+                      help="Add packages to an existing live CD iso9660 image.")
Harald Hoyer 55891e
+    imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel",
Harald Hoyer 55891e
+                      help="File system label (default based on config name)")
Harald Hoyer 55891e
+    # Provided for img-create compatibility
Harald Hoyer 55891e
+    imgopt.add_option("-n", "--name", type="string", dest="fslabel",
Harald Hoyer 55891e
+                      help=optparse.SUPPRESS_HELP)
Harald Hoyer 55891e
+    imgopt.add_option("", "--image-type", type="string", dest="image_type",
Harald Hoyer 55891e
+                      help=optparse.SUPPRESS_HELP)
Harald Hoyer 55891e
+    imgopt.add_option("", "--compression-type", type="string", dest="compress_type",
Harald Hoyer 55891e
+                      help="Compression type recognized by mksquashfs "
Harald Hoyer 55891e
+                           "(default xz needs a 2.6.38+ kernel, gzip works "
Harald Hoyer 55891e
+                           "with all kernels, lzo needs a 2.6.36+ kernel, lzma "
Harald Hoyer 55891e
+                           "needs custom kernel.) Set to 'None' to force read "
Harald Hoyer 55891e
+                           "from base_on.",
Harald Hoyer 55891e
+                      default="xz")
Harald Hoyer 55891e
+    imgopt.add_option("", "--releasever", type="string", dest="releasever",
Harald Hoyer 55891e
+                      default=None,
Harald Hoyer 55891e
+                      help="Value to substitute for $releasever in kickstart repo urls")
Harald Hoyer 55891e
+    parser.add_option_group(imgopt)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    # options related to the config of your system
Harald Hoyer 55891e
+    sysopt = optparse.OptionGroup(parser, "System directory options",
Harald Hoyer 55891e
+                                  "These options define directories used on your system for creating the live image")
Harald Hoyer 55891e
+    sysopt.add_option("-t", "--tmpdir", type="string",
Harald Hoyer 55891e
+                      dest="tmpdir", default="/var/tmp",
Harald Hoyer 55891e
+                      help="Temporary directory to use (default: /var/tmp)")
Harald Hoyer 55891e
+    sysopt.add_option("", "--cache", type="string",
Harald Hoyer 55891e
+                      dest="cachedir", default=None,
Harald Hoyer 55891e
+                      help="Cache directory to use (default: private cache")
Harald Hoyer 55891e
+    parser.add_option_group(sysopt)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    imgcreate.setup_logging(parser)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    # debug options not recommended for "production" images
Harald Hoyer 55891e
+    # Start a shell in the chroot for post-configuration.
Harald Hoyer 55891e
+    parser.add_option("-l", "--shell", action="store_true", dest="give_shell",
Harald Hoyer 55891e
+                      help=optparse.SUPPRESS_HELP)
Harald Hoyer 55891e
+    # Don't compress the image.
Harald Hoyer 55891e
+    parser.add_option("-s", "--skip-compression", action="store_true", dest="skip_compression",
Harald Hoyer 55891e
+                      help=optparse.SUPPRESS_HELP)
Harald Hoyer 55891e
+    parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize",
Harald Hoyer 55891e
+                      help=optparse.SUPPRESS_HELP)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    (options, args) = parser.parse_args()
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    # Pretend to be a image-creator if called with that name
Harald Hoyer 55891e
+    options.image_type = 'livecd'
Harald Hoyer 55891e
+    if options.image_type not in ('livecd', 'image'):
Harald Hoyer 55891e
+        raise Usage("'%s' is a recognized image type" % options.image_type)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    # image-create compatibility: Last argument is kickstart file
Harald Hoyer 55891e
+    if len(args) == 1:
Harald Hoyer 55891e
+        options.kscfg = args.pop()
Harald Hoyer 55891e
+    if len(args):
Harald Hoyer 55891e
+        raise Usage("Extra arguments given")
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    if options.base_on and not os.path.isfile(options.base_on):
Harald Hoyer 55891e
+        raise Usage("Image file '%s' does not exist" %(options.base_on,))
Harald Hoyer 55891e
+    if options.image_type == 'livecd':
Harald Hoyer 55891e
+        if options.fslabel and len(options.fslabel) > imgcreate.FSLABEL_MAXLEN:
Harald Hoyer 55891e
+            raise Usage("CD labels are limited to 32 characters")
Harald Hoyer 55891e
+        if options.fslabel and options.fslabel.find(" ") != -1:
Harald Hoyer 55891e
+            raise Usage("CD labels cannot contain spaces.")
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    return options
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+def main():
Harald Hoyer 55891e
+    try:
Harald Hoyer 55891e
+        options = parse_options(sys.argv[1:])
Harald Hoyer 55891e
+    except Usage, (msg, no_error):
Harald Hoyer 55891e
+        if no_error:
Harald Hoyer 55891e
+            out = sys.stdout
Harald Hoyer 55891e
+            ret = 0
Harald Hoyer 55891e
+        else:
Harald Hoyer 55891e
+            out = sys.stderr
Harald Hoyer 55891e
+            ret = 2
Harald Hoyer 55891e
+        if msg:
Harald Hoyer 55891e
+            print >> out, msg
Harald Hoyer 55891e
+        return ret
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    if os.geteuid () != 0:
Harald Hoyer 55891e
+        print >> sys.stderr, "You must run %s as root" % sys.argv[0]
Harald Hoyer 55891e
+        return 1
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    if options.fslabel:
Harald Hoyer 55891e
+        fslabel = options.fslabel
Harald Hoyer 55891e
+        name = fslabel
Harald Hoyer 55891e
+    else:
Harald Hoyer 55891e
+        name = "livecd"
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+        fslabel = "LiveCD"
Harald Hoyer 55891e
+        logging.info("Using label '%s' and name '%s'" % (fslabel, name))
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    ks = imgcreate.read_kickstart(options.kscfg)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    creator = myLiveImageCreator(ks, name,
Harald Hoyer 55891e
+                                 fslabel=fslabel,
Harald Hoyer 55891e
+                                 releasever=options.releasever,
Harald Hoyer 55891e
+                                 tmpdir=os.path.abspath(options.tmpdir))
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    creator.compress_type = options.compress_type
Harald Hoyer 55891e
+    creator.skip_compression = options.skip_compression
Harald Hoyer 55891e
+    creator.skip_minimize = options.skip_minimize
Harald Hoyer 55891e
+    if options.cachedir:
Harald Hoyer 55891e
+        options.cachedir = os.path.abspath(options.cachedir)
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    try:
Harald Hoyer 55891e
+        creator.mount(options.base_on, options.cachedir)
Harald Hoyer 55891e
+        creator.install()
Harald Hoyer 55891e
+        creator.configure()
Harald Hoyer 55891e
+        if options.give_shell:
Harald Hoyer 55891e
+            print "Launching shell. Exit to continue."
Harald Hoyer 55891e
+            print "----------------------------------"
Harald Hoyer 55891e
+            creator.launch_shell()
Harald Hoyer 55891e
+        creator.unmount()
Harald Hoyer 55891e
+        creator.package()
Harald Hoyer 55891e
+    except imgcreate.CreatorError, e:
Harald Hoyer 55891e
+        logging.error(u"Error creating Live CD : %s" % e)
Harald Hoyer 55891e
+        return 1
Harald Hoyer 55891e
+    finally:
Harald Hoyer 55891e
+        creator.cleanup()
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    return 0
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+if __name__ == "__main__":
Harald Hoyer 55891e
+    sys.exit(main())
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/cryptroot-ask b/test/TEST-16-DMSQUASH/cryptroot-ask
Harald Hoyer 55891e
new file mode 100755
Harald Hoyer 55891e
index 0000000..db27c5b
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/cryptroot-ask
Harald Hoyer 55891e
@@ -0,0 +1,6 @@
Harald Hoyer 55891e
+#!/bin/sh
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+[ -b /dev/mapper/$2 ] && exit 0
Harald Hoyer 55891e
+echo -n test >/keyfile
Harald Hoyer 55891e
+/sbin/cryptsetup luksOpen $1 $2 
Harald Hoyer 55891e
+
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/hard-off.sh b/test/TEST-16-DMSQUASH/hard-off.sh
Harald Hoyer 55891e
new file mode 100755
Harald Hoyer 55891e
index 0000000..12c3d5a
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/hard-off.sh
Harald Hoyer 55891e
@@ -0,0 +1,3 @@
Harald Hoyer 55891e
+#!/bin/sh
Harald Hoyer 55891e
+getarg rd.shell || poweroff -f
Harald Hoyer 55891e
+getarg failme && poweroff -f
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/livecd-fedora-minimal.ks b/test/TEST-16-DMSQUASH/livecd-fedora-minimal.ks
Harald Hoyer 55891e
new file mode 100644
Harald Hoyer 55891e
index 0000000..88637ae
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/livecd-fedora-minimal.ks
Harald Hoyer 55891e
@@ -0,0 +1,22 @@
Harald Hoyer 55891e
+lang en_US.UTF-8
Harald Hoyer 55891e
+keyboard us
Harald Hoyer 55891e
+timezone US/Eastern
Harald Hoyer 55891e
+auth --useshadow --enablemd5
Harald Hoyer 55891e
+selinux --enforcing
Harald Hoyer 55891e
+firewall --disabled
Harald Hoyer 55891e
+part / --size 1024
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+repo --name=fedora --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-16&arch=$basearch
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+%packages
Harald Hoyer 55891e
+@core
Harald Hoyer 55891e
+anaconda-runtime
Harald Hoyer 55891e
+bash
Harald Hoyer 55891e
+kernel
Harald Hoyer 55891e
+passwd
Harald Hoyer 55891e
+policycoreutils
Harald Hoyer 55891e
+chkconfig
Harald Hoyer 55891e
+authconfig
Harald Hoyer 55891e
+rootfiles
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+%end
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/test-init b/test/TEST-16-DMSQUASH/test-init
Harald Hoyer 55891e
new file mode 100755
Harald Hoyer 55891e
index 0000000..616bf68
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/test-init
Harald Hoyer 55891e
@@ -0,0 +1,17 @@
Harald Hoyer 55891e
+#!/bin/sh
Harald Hoyer 55891e
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
Harald Hoyer 55891e
+strstr() { [ "${1#*$2*}" != "$1" ]; }
Harald Hoyer 55891e
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
Harald Hoyer 55891e
+plymouth --quit
Harald Hoyer 55891e
+exec >/dev/console 2>&1
Harald Hoyer 55891e
+echo "dracut-root-block-success" >/dev/sda
Harald Hoyer 55891e
+export TERM=linux
Harald Hoyer 55891e
+export PS1='initramfs-test:\w\$ '
Harald Hoyer 55891e
+[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
Harald Hoyer 55891e
+[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
Harald Hoyer 55891e
+stty sane
Harald Hoyer 55891e
+echo "made it to the rootfs!"
Harald Hoyer 55891e
+strstr "$CMDLINE" "rd.shell" && sh -i
Harald Hoyer 55891e
+echo "Powering down."
Harald Hoyer 55891e
+mount -n -o remount,ro /
Harald Hoyer 55891e
+poweroff -f
Harald Hoyer 55891e
diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh
Harald Hoyer 55891e
new file mode 100755
Harald Hoyer 55891e
index 0000000..5d8075c
Harald Hoyer 55891e
--- /dev/null
Harald Hoyer 55891e
+++ b/test/TEST-16-DMSQUASH/test.sh
Harald Hoyer 55891e
@@ -0,0 +1,66 @@
Harald Hoyer 55891e
+#!/bin/bash
Harald Hoyer 55891e
+TEST_DESCRIPTION="root filesystem on a LiveCD dmsquash filesystem"
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+KVERSION=${KVERSION-$(uname -r)}
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+# Uncomment this to debug failures
Harald Hoyer 55891e
+#DEBUGFAIL="rd.shell rd.break"
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+test_run() {
Harald Hoyer 55891e
+    $testdir/run-qemu -boot order=d -cdrom livecd.iso -hda root.img -m 256M -nographic \
Harald Hoyer 55891e
+	-net none -kernel /boot/vmlinuz-$KVERSION \
Harald Hoyer 55891e
+	-append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
Harald Hoyer 55891e
+	-initrd initramfs.testing
Harald Hoyer 55891e
+    grep -m 1 -q dracut-root-block-success root.img || return 1
Harald Hoyer 55891e
+}
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+test_setup() {
Harald Hoyer 55891e
+    mkdir -p overlay
Harald Hoyer 55891e
+    (
Harald Hoyer 55891e
+	initdir=overlay
Harald Hoyer 55891e
+	. $basedir/dracut-functions
Harald Hoyer 55891e
+	dracut_install poweroff shutdown
Harald Hoyer 55891e
+	inst_hook emergency 000 ./hard-off.sh
Harald Hoyer 55891e
+	inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
Harald Hoyer 55891e
+    )
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    dd if=/dev/null of=root.img seek=100
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    sudo $basedir/dracut -l -i overlay / \
Harald Hoyer 55891e
+	-a "debug" \
Harald Hoyer 55891e
+	-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
Harald Hoyer 55891e
+	-f initramfs.testing $KVERSION || return 1
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    mkdir -p root-source
Harald Hoyer 55891e
+    kernel=$KVERSION
Harald Hoyer 55891e
+    # Create what will eventually be our root filesystem onto an overlay
Harald Hoyer 55891e
+    (
Harald Hoyer 55891e
+	initdir=root-source
Harald Hoyer 55891e
+	. $basedir/dracut-functions
Harald Hoyer 55891e
+	dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
Harald Hoyer 55891e
+	    /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \
Harald Hoyer 55891e
+	    umount strace less
Harald Hoyer 55891e
+	inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
Harald Hoyer 55891e
+	inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
Harald Hoyer 55891e
+	dracut_install grep syslinux isohybrid
Harald Hoyer 55891e
+	for f in /usr/share/syslinux/*; do
Harald Hoyer 55891e
+	    inst_simple "$f"
Harald Hoyer 55891e
+	done
Harald Hoyer 55891e
+	inst ./test-init /sbin/init
Harald Hoyer 55891e
+	inst ./initramfs.testing "/boot/initramfs-$KVERSION.img"
Harald Hoyer 55891e
+	inst /boot/vmlinuz-$KVERSION
Harald Hoyer 55891e
+	find_binary plymouth >/dev/null && dracut_install plymouth
Harald Hoyer 55891e
+	(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
Harald Hoyer 55891e
+	cp -a /etc/ld.so.conf* $initdir/etc
Harald Hoyer 55891e
+	sudo ldconfig -r "$initdir"
Harald Hoyer 55891e
+    )
Harald Hoyer 55891e
+    python create.py -d -c livecd-fedora-minimal.ks
Harald Hoyer 55891e
+    exit 0
Harald Hoyer 55891e
+}
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+test_cleanup() {
Harald Hoyer 55891e
+    rm -fr overlay root-source
Harald Hoyer 55891e
+    rm -f root.img initramfs.makeroot initramfs.testing livecd.iso
Harald Hoyer 55891e
+}
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+. $testdir/test-functions