test.sh revision e8a66f4af296dc1dd4879a1401eb42bf7b7aeb01
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering#!/bin/bash
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering# ex: ts=8 sw=4 sts=4 et filetype=sh
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringTEST_DESCRIPTION="cryptsetup systemd setup"
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringKVERSION=${KVERSION-$(uname -r)}
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringKERNEL_VER=$(uname -r)
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering# Uncomment this to debug failures
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering#DEBUGFAIL="systemd.unit=multi-user.target"
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringDEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort"
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poetteringrun_qemu() {
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # TODO: qemu wrapper script: http://www.spinics.net/lists/kvm/msg72389.html
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering qemu-kvm \
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering -hda $TESTDIR/rootdisk.img \
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering -m 512M -nographic \
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering -net none -kernel /boot/vmlinuz-$KERNEL_VER \
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd ro console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" || return 1
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering ret=1
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering mkdir -p $TESTDIR/root
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering mount ${LOOPDEV}p1 $TESTDIR/root
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering [[ -e $TESTDIR/root/testok ]] && ret=0
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering cp -a $TESTDIR/root/failed $TESTDIR
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mount /dev/mapper/varcrypt $TESTDIR/root/var
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering cp -a $TESTDIR/root/var/log/journal $TESTDIR
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering umount $TESTDIR/root/var
b1d4f8e154bf61b5de1b27461ef8e9c8c5e838a1Lennart Poettering umount $TESTDIR/root
b1d4f8e154bf61b5de1b27461ef8e9c8c5e838a1Lennart Poettering cryptsetup luksClose /dev/mapper/varcrypt
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering cat $TESTDIR/failed
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering ls -l $TESTDIR/journal/*/*.journal
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering test -s $TESTDIR/failed && ret=$(($ret+1))
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering return $ret
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering}
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poetteringtest_run() {
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering if check_qemu ; then
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering run_qemu || return 1
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering else
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering dwarn "can't run qemu-kvm, skipping"
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering fi
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering return 0
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering}
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poetteringtest_setup() {
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering rm -f $TESTDIR/rootdisk.img
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # Create the blank file to use as a root filesystem
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=200
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering [ -b $LOOPDEV ] || return 1
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering sfdisk -C 6400 -H 2 -S 32 -L $LOOPDEV <<EOF
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering,3200
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering,
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart PoetteringEOF
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering mkfs.ext3 -L systemd ${LOOPDEV}p1
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering echo -n test >$TESTDIR/keyfile
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering cryptsetup -q luksFormat ${LOOPDEV}p2 $TESTDIR/keyfile
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mkfs.ext3 -L var /dev/mapper/varcrypt
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering mkdir -p $TESTDIR/root
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mount ${LOOPDEV}p1 $TESTDIR/root
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mkdir -p $TESTDIR/root/run
115cbf7e209a86cf5317fa12d44566247b4af332Evgeny Vereshchagin mkdir -p $TESTDIR/root/var
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mount /dev/mapper/varcrypt $TESTDIR/root/var
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # Create what will eventually be our root filesystem onto an overlay
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering (
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering LOG_LEVEL=5
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering initdir=$TESTDIR/root
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # create the basic filesystem layout
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering setup_basic_dirs
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering # install compiled files
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering (cd ../..; make DESTDIR=$initdir install)
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # remove unneeded documentation
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering rm -fr $initdir/usr/share/{man,doc,gtk-doc}
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # install possible missing libraries
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering inst_libs $i
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering done
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # make a journal directory
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering mkdir -p $initdir/var/log/journal
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # install some basic config files
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering inst /etc/sysconfig/init
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering inst /etc/passwd
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering inst /etc/shadow
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering inst /etc/group
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering inst /etc/shells
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering inst /etc/nsswitch.conf
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering inst /etc/pam.conf
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering inst /etc/securetty
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering inst /etc/os-release
9444b1f20e311f073864d81e913bd4f32fe95cfdLennart Poettering inst /etc/localtime
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # we want an empty environment
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering > $initdir/etc/environment
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering > $initdir/etc/machine-id
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # set the hostname
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering echo systemd-testsuite > $initdir/etc/hostname
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt)
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering cat >$initdir/etc/crypttab <<EOF
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering$DM_NAME UUID=$ID_FS_UUID /etc/varkey
696fd1ef4f2f8574e349332a16987c6772641eddLennart PoetteringEOF
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering echo -n test > $initdir/etc/varkey
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering cat $initdir/etc/crypttab | ddebug
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering cat >$initdir/etc/fstab <<EOF
696fd1ef4f2f8574e349332a16987c6772641eddLennart PoetteringLABEL=systemd / ext3 rw 0 1
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering/dev/mapper/varcrypt /var ext3 defaults 0 1
696fd1ef4f2f8574e349332a16987c6772641eddLennart PoetteringEOF
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering # setup the testsuite target
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering cat >$initdir/etc/systemd/system/testsuite.target <<EOF
696fd1ef4f2f8574e349332a16987c6772641eddLennart Poettering[Unit]
696fd1ef4f2f8574e349332a16987c6772641eddLennart PoetteringDescription=Testsuite target
696fd1ef4f2f8574e349332a16987c6772641eddLennart PoetteringRequires=multi-user.target
115cbf7e209a86cf5317fa12d44566247b4af332Evgeny VereshchaginAfter=multi-user.target
115cbf7e209a86cf5317fa12d44566247b4af332Evgeny VereshchaginConflicts=rescue.target
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringAllowIsolate=yes
19f6d710772305610b928bc2678b9d77fe11e770Lennart PoetteringEOF
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # setup the testsuite service
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering cat >$initdir/etc/systemd/system/testsuite.service <<EOF
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering[Unit]
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringDescription=Testsuite service
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart PoetteringAfter=multi-user.target
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering[Service]
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do systemd-cat echo "testsuite service waiting for /var/log/journal" ; echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart PoetteringExecStopPost=/usr/bin/systemctl poweroff --no-block
b2c23da8cea1987a1a329f5a964d3299b7ca7890Lennart PoetteringType=oneshot
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart PoetteringEOF
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
15411c0cb1192799b37ec8f25d6f30e8d7292fc6David Herrmann # make the testsuite the default target
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering ln -fs testsuite.target $initdir/etc/systemd/system/default.target
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering mkdir -p $initdir/etc/rc.d
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering cat >$initdir/etc/rc.d/rc.local <<EOF
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering#!/bin/bash
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poetteringexit 0
19f6d710772305610b928bc2678b9d77fe11e770Lennart PoetteringEOF
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering chmod 0755 $initdir/etc/rc.d/rc.local
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # install basic tools needed
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering dracut_install sh bash setsid loadkeys setfont \
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering login sushell sulogin gzip sleep echo mount umount cryptsetup
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering dracut_install dmsetup modprobe
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering instmods dm_crypt =crypto
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering
7de80bfe2e61d5818601ccfddbadad3b7703ed70Karel Zak type -P dmeventd >/dev/null && dracut_install dmeventd
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
6569cae18ed640a4e9f52f73e2a3ec54b07d0406Lennart Poettering inst_libdir_file "libdevmapper-event.so*"
6569cae18ed640a4e9f52f73e2a3ec54b07d0406Lennart Poettering
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
115cbf7e209a86cf5317fa12d44566247b4af332Evgeny Vereshchagin # install libnss_files for login
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering inst_libdir_file "libnss_files*"
b2c23da8cea1987a1a329f5a964d3299b7ca7890Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # install dbus and pam
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering find \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /etc/dbus-1 \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /etc/pam.d \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /etc/security \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /lib64/security \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /lib/security -xtype f \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering | while read file; do
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering inst $file
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering done
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # install dbus socket and service file
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering inst /usr/lib/systemd/system/dbus.socket
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering inst /usr/lib/systemd/system/dbus.service
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # install basic keyboard maps and fonts
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering for i in \
7de80bfe2e61d5818601ccfddbadad3b7703ed70Karel Zak /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /usr/lib/kbd/keymaps/include/* \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /usr/lib/kbd/keymaps/i386/include/* \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering [[ -f $i ]] || continue
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering inst $i
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering done
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # some basic terminfo files
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering [ -f ${_terminfodir}/l/linux ] && break
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering done
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering dracut_install -o ${_terminfodir}/l/linux
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # softlink mtab
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering ln -fs /proc/self/mounts $initdir/etc/mtab
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # install any Exec's from the service files
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering | while read i; do
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering i=${i##Exec*=}; i=${i##-}
067d851d30386c553e3a84f59d81d003ff638b91Daniel Wallace inst $i
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering done
7de80bfe2e61d5818601ccfddbadad3b7703ed70Karel Zak
067d851d30386c553e3a84f59d81d003ff638b91Daniel Wallace # install plymouth, if found... else remove plymouth service files
067d851d30386c553e3a84f59d81d003ff638b91Daniel Wallace # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
7de80bfe2e61d5818601ccfddbadad3b7703ed70Karel Zak # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # dracut_install plymouth plymouthd
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # else
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering # fi
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # some helper tools for debugging
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering # install ld.so.conf* and run ldconfig
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering cp -a /etc/ld.so.conf* $initdir/etc
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering ldconfig -r "$initdir"
6569cae18ed640a4e9f52f73e2a3ec54b07d0406Lennart Poettering ddebug "Strip binaeries"
6569cae18ed640a4e9f52f73e2a3ec54b07d0406Lennart Poettering find "$initdir" -perm +111 -type f | xargs strip --strip-unneeded | ddebug
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # copy depmod files
15411c0cb1192799b37ec8f25d6f30e8d7292fc6David Herrmann inst /lib/modules/$KERNEL_VER/modules.order
3ef63c317481c2b3f1fe39e1b0f130aac3544522Lennart Poettering inst /lib/modules/$KERNEL_VER/modules.builtin
b2c23da8cea1987a1a329f5a964d3299b7ca7890Lennart Poettering # generate module dependencies
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering ! depmod -a -b "$initdir" $KERNEL_VER; then
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering dfatal "\"depmod -a $KERNEL_VER\" failed."
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering exit 1
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering fi
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering )
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering rm -fr $TESTDIR/nspawn-root
15411c0cb1192799b37ec8f25d6f30e8d7292fc6David Herrmann ddebug "cp -ar $TESTDIR/root $TESTDIR/nspawn-root"
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering cp -ar $TESTDIR/root $TESTDIR/nspawn-root
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering # we don't mount in the nspawn root
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering rm -fr $TESTDIR/nspawn-root/etc/fstab
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering ddebug "umount $TESTDIR/root/var"
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering umount $TESTDIR/root/var
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering cryptsetup luksClose /dev/mapper/varcrypt
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering ddebug "umount $TESTDIR/root"
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering umount $TESTDIR/root
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering}
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poetteringtest_cleanup() {
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering umount $TESTDIR/root/var 2>/dev/null
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering umount $TESTDIR/root 2>/dev/null
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering [[ $LOOPDEV ]] && losetup -d $LOOPDEV
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering return 0
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering}
2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2Lennart Poettering
41f9172f427bdbb8221c64029f78364b8dd4e527Lennart Poettering. $TEST_BASE_DIR/test-functions
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poetteringdo_test "$@"
19f6d710772305610b928bc2678b9d77fe11e770Lennart Poettering