test.sh revision 0d6e798a784ef0ba6b95512e4453067b2f84a91a
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers#!/bin/bash
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers# ex: ts=8 sw=4 sts=4 et filetype=sh
a660c63c551b88136ac6176855b5907cc533e848Kay SieversTEST_DESCRIPTION="Basic systemd setup"
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay SieversKVERSION=${KVERSION-$(uname -r)}
a660c63c551b88136ac6176855b5907cc533e848Kay SieversKERNEL_VER=$(uname -r)
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers# Uncomment this to debug failures
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers#DEBUGFAIL="systemd.unit=multi-user.target"
a660c63c551b88136ac6176855b5907cc533e848Kay SieversDEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort"
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay Sieversrun_qemu() {
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers # TODO: qemu wrapper script: http://www.spinics.net/lists/kvm/msg72389.html
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers qemu-kvm \
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers -hda $TESTDIR/rootdisk.img \
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers -m 512M -nographic \
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers -net none -kernel /boot/vmlinuz-$KERNEL_VER \
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers -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
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers ret=1
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers mkdir -p $TESTDIR/root
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers mount ${LOOPDEV}p1 $TESTDIR/root
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers [[ -e $TESTDIR/root/testok ]] && ret=0
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers cp -a $TESTDIR/root/failed $TESTDIR
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
25da63b9dac8f166ebf390ca92d1de18fbfc9d11Kay Sievers mount /dev/mapper/varcrypt $TESTDIR/root/var
25da63b9dac8f166ebf390ca92d1de18fbfc9d11Kay Sievers cp -a $TESTDIR/root/var/log/journal $TESTDIR
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers umount $TESTDIR/root/var
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers umount $TESTDIR/root
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers cryptsetup luksClose /dev/mapper/varcrypt
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers cat $TESTDIR/failed
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers ls -l $TESTDIR/journal/*/*.journal
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers test -s $TESTDIR/failed && ret=$(($ret+1))
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers return $ret
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers}
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovernrun_nspawn() {
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern systemd-nspawn -b -D $TESTDIR/nspawn-root /usr/lib/systemd/systemd
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers ret=1
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers [[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers cp -a $TESTDIR/nspawn-root/var/log/journal $TESTDIR
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers cp -a $TESTDIR/nspawn-root/failed $TESTDIR
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers cat $TESTDIR/failed
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern ls -l $TESTDIR/journal/*/*.journal
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern test -s $TESTDIR/failed && ret=$(($ret+1))
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers return $ret
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers}
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sieverstest_run() {
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers if check_qemu ; then
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers run_qemu || return 1
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers else
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers dwarn "can't run qemu-kvm, skipping"
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers fi
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers if check_nspawn; then
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers#run_nspawn || return 1
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers :
de892aea1c486b59e04884268b612081d1660514Kay Sievers else
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers dwarn "can't run systemd-nspawn, skipping"
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers fi
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers return 0
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers}
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers
decd634e801bee2c554edb35383cc9d43417a850Kay Sieverstest_setup() {
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers rm -f $TESTDIR/rootdisk.img
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers # Create the blank file to use as a root filesystem
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=200
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers [ -b $LOOPDEV ] || return 1
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers sfdisk -C 6400 -H 2 -S 32 -L $LOOPDEV <<EOF
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers,3200
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers,
f610d6de38119b372b377ec41b2a6089872d3294Kay SieversEOF
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers mkfs.ext3 -L systemd ${LOOPDEV}p1
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers echo -n test >$TESTDIR/keyfile
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers cryptsetup -q luksFormat ${LOOPDEV}p2 $TESTDIR/keyfile
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers mkfs.ext3 -L var /dev/mapper/varcrypt
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers mkdir -p $TESTDIR/root
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers mount ${LOOPDEV}p1 $TESTDIR/root
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers mkdir -p $TESTDIR/root/run
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers mkdir -p $TESTDIR/root/var
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers mount /dev/mapper/varcrypt $TESTDIR/root/var
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers # Create what will eventually be our root filesystem onto an overlay
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers (
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers LOG_LEVEL=5
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers initdir=$TESTDIR/root
de892aea1c486b59e04884268b612081d1660514Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers # create the basic filesystem layout
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers setup_basic_dirs
a5c32cff1f56afe6f0c6c70d91a88a7a8238b2d7Harald Hoyer
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers # install compiled files
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers (cd ../..; make DESTDIR=$initdir install)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # remove unneeded documentation
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers rm -fr $initdir/usr/share/{man,doc,gtk-doc}
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers
e3d563346c4237af23335cc6904e0662efdf62adTom Gundersen # install possible missing libraries
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst_libs $i
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers done
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # activate kmsg import
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # make a journal directory
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers mkdir -p $initdir/var/log/journal
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # install some basic config files
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/sysconfig/init
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/passwd
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/shadow
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/group
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers inst /etc/shells
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers inst /etc/nsswitch.conf
e3d563346c4237af23335cc6904e0662efdf62adTom Gundersen inst /etc/pam.conf
e3d563346c4237af23335cc6904e0662efdf62adTom Gundersen inst /etc/securetty
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/os-release
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers inst /etc/localtime
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # we want an empty environment
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers > $initdir/etc/environment
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers > $initdir/etc/machine-id
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers # set the hostname
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers echo systemd-testsuite > $initdir/etc/hostname
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
01d183ddae6fb3445c4519cf1d90c6575f17292eKay Sievers eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt)
01d183ddae6fb3445c4519cf1d90c6575f17292eKay Sievers eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers cat >$initdir/etc/crypttab <<EOF
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers$DM_NAME UUID=$ID_FS_UUID /etc/varkey
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay SieversEOF
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers echo -n test > $initdir/etc/varkey
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers cat $initdir/etc/crypttab | ddebug
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers cat >$initdir/etc/fstab <<EOF
0260944060426d54d9ecb40930baad985cbd02a1Kay SieversLABEL=systemd / ext3 rw 0 1
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers/dev/mapper/varcrypt /var ext3 defaults 0 1
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay SieversEOF
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers
137661d87525a3c339afd2804e577532d58d3fbcKay Sievers # setup the testsuite target
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers cat >$initdir/etc/systemd/system/testsuite.target <<EOF
de892aea1c486b59e04884268b612081d1660514Kay Sievers[Unit]
3c123e0899b56c0587db36420da5e049c56d9e19Lukas NykrynDescription=Testsuite target
0260944060426d54d9ecb40930baad985cbd02a1Kay SieversRequires=multi-user.target
1328f66ad16b5afeb5684858c27e121a46c1959eKay SieversAfter=multi-user.target
de892aea1c486b59e04884268b612081d1660514Kay SieversConflicts=rescue.target
de892aea1c486b59e04884268b612081d1660514Kay SieversAllowIsolate=yes
de892aea1c486b59e04884268b612081d1660514Kay SieversEOF
de892aea1c486b59e04884268b612081d1660514Kay Sievers
de892aea1c486b59e04884268b612081d1660514Kay Sievers # setup the testsuite service
de892aea1c486b59e04884268b612081d1660514Kay Sievers cat >$initdir/etc/systemd/system/testsuite.service <<EOF
de892aea1c486b59e04884268b612081d1660514Kay Sievers[Unit]
de892aea1c486b59e04884268b612081d1660514Kay SieversDescription=Testsuite service
de892aea1c486b59e04884268b612081d1660514Kay SieversAfter=multi-user.target
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers[Service]
de892aea1c486b59e04884268b612081d1660514Kay SieversExecStart=/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;'
f168c27313e4d7b0aabee037dc9c78a5799f0597Thomas Hindoe Paaboel AndersenExecStopPost=/usr/bin/systemctl poweroff
3c123e0899b56c0587db36420da5e049c56d9e19Lukas NykrynType=oneshot
1328f66ad16b5afeb5684858c27e121a46c1959eKay SieversEOF
de892aea1c486b59e04884268b612081d1660514Kay Sievers mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
de892aea1c486b59e04884268b612081d1660514Kay Sievers ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # make the testsuite the default target
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-Szmek ln -fs testsuite.target $initdir/etc/systemd/system/default.target
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers mkdir -p $initdir/etc/rc.d
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers cat >$initdir/etc/rc.d/rc.local <<EOF
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers#!/bin/bash
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sieversexit 0
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-SzmekEOF
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-Szmek chmod 0755 $initdir/etc/rc.d/rc.local
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # install basic tools needed
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-Szmek dracut_install sh bash setsid loadkeys setfont \
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers login sushell sulogin gzip sleep echo mount umount cryptsetup
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-Szmek dracut_install dmsetup modprobe
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers instmods dm_crypt =crypto
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers type -P dmeventd >/dev/null && dracut_install dmeventd
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers inst_libdir_file "libdevmapper-event.so*"
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern # install libnss_files for login
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern inst_libdir_file "libnss_files*"
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern # install dbus and pam
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers find \
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers /etc/dbus-1 \
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers /etc/pam.d \
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers /etc/security \
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers /lib64/security \
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers /lib/security -xtype f \
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers | while read file; do
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst $file
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers done
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # install dbus socket and service file
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst /usr/lib/systemd/system/dbus.socket
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst /usr/lib/systemd/system/dbus.service
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # install basic keyboard maps and fonts
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers for i in \
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers /usr/lib/kbd/keymaps/include/* \
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers /usr/lib/kbd/keymaps/i386/include/* \
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers [[ -f $i ]] || continue
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst $i
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers done
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # some basic terminfo files
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers [ -f ${_terminfodir}/l/linux ] && break
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers done
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers dracut_install -o ${_terminfodir}/l/linux
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # softlink mtab
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers ln -fs /proc/self/mounts $initdir/etc/mtab
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # install any Exec's from the service files
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
641906e9366891e0ad3e6e38b7396a427678c4cfThomas Hindoe Paaboel Andersen | while read i; do
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers i=${i##Exec*=}; i=${i##-}
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst $i
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers done
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # install plymouth, if found... else remove plymouth service files
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # dracut_install plymouth plymouthd
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers # else
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern # fi
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern # some helper tools for debugging
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers # install ld.so.conf* and run ldconfig
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers cp -a /etc/ld.so.conf* $initdir/etc
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers ldconfig -r "$initdir"
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers ddebug "Strip binaeries"
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers find "$initdir" -perm +111 -type f | xargs strip --strip-unneeded | ddebug
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # copy depmod files
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst /lib/modules/$KERNEL_VER/modules.order
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers inst /lib/modules/$KERNEL_VER/modules.builtin
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers # generate module dependencies
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
5b8180d3f6598a1b2f296645690de41d726fd5abKay Sievers ! depmod -a -b "$initdir" $KERNEL_VER; then
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers dfatal "\"depmod -a $KERNEL_VER\" failed."
5b8180d3f6598a1b2f296645690de41d726fd5abKay Sievers exit 1
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers fi
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers )
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers rm -fr $TESTDIR/nspawn-root
bb26309dd042c79de907f103d83f398b9436cde0Rob Clark ddebug "cp -ar $TESTDIR/root $TESTDIR/nspawn-root"
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers cp -ar $TESTDIR/root $TESTDIR/nspawn-root
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers # we don't mount in the nspawn root
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers rm -fr $TESTDIR/nspawn-root/etc/fstab
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers ddebug "umount $TESTDIR/root/var"
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers umount $TESTDIR/root/var
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers cryptsetup luksClose /dev/mapper/varcrypt
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers ddebug "umount $TESTDIR/root"
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers umount $TESTDIR/root
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers}
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sieverstest_cleanup() {
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers umount $TESTDIR/root/var 2>/dev/null
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers umount $TESTDIR/root 2>/dev/null
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers [[ $LOOPDEV ]] && losetup -d $LOOPDEV
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers return 0
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers}
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers. $TEST_BASE_DIR/test-functions
0260944060426d54d9ecb40930baad985cbd02a1Kay Sieversdo_test "$@"
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers