]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-99-RPM/test.sh
TEST-99-RPM: ignore weak dependencies in dnf
[thirdparty/dracut.git] / test / TEST-99-RPM / test.sh
1 #!/bin/bash
2
3 TEST_DESCRIPTION="rpm integrity after dracut and kernel install"
4
5 test_check() {
6 command -v rpm &>/dev/null && ( command -v yum || command -v dnf ) &>/dev/null
7 }
8
9 test_run() {
10 set -x
11 set -e
12 export rootdir=$TESTDIR/root
13
14 mkdir -p $rootdir
15
16 mkdir -p "$rootdir/proc"
17 mkdir -p "$rootdir/sys"
18 mkdir -p "$rootdir/dev"
19 mkdir -p "$rootdir/boot"
20
21 trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
22 trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
23
24 mount --bind /proc "$rootdir/proc"
25 mount --bind /sys "$rootdir/sys"
26 mount -t devtmpfs devtmpfs "$rootdir/dev"
27
28 mkdir -p "$rootdir/$TESTDIR"
29 cp --reflink=auto -a \
30 "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
31 "$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
32 "$rootdir/$TESTDIR/"
33 . /etc/os-release
34 dnf_or_yum=yum
35 dnf_or_yum_cmd=yum
36 command -v dnf >/dev/null && { dnf_or_yum="dnf"; dnf_or_yum_cmd="dnf --allowerasing"; }
37 for (( i=0; i < 5 ; i++)); do
38 $dnf_or_yum_cmd -v --nogpgcheck --installroot "$rootdir"/ --releasever "$VERSION_ID" --disablerepo='*' \
39 --enablerepo=fedora --enablerepo=updates --setopt=install_weak_deps=False \
40 install -y \
41 $dnf_or_yum \
42 passwd \
43 rootfiles \
44 systemd \
45 systemd-udev \
46 kernel \
47 kernel-core \
48 redhat-release \
49 device-mapper-multipath \
50 lvm2 \
51 mdadm \
52 bash \
53 iscsi-initiator-utils \
54 "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \
55 ${NULL} && break
56 #"$TESTDIR"/dracut-config-rescue-[0-9]*.$(uname -m).rpm \
57 #"$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \
58 # ${NULL}
59 done
60 (( i < 5 ))
61
62 cat >"$rootdir"/test.sh <<EOF
63 #!/bin/bash
64 set -x
65 export LC_MESSAGES=C
66 rpm -Va |& \
67 grep -F \
68 '85-display-manager.preset| /run| /var| /usr/lib/variant| /etc/machine-id| /etc/systemd/system/dbus-org.freedesktop.network1.service| /etc/systemd/system/dbus-org.freedesktop.resolve1.service| /etc/udev/hwdb.bin| /usr/share/info/dir.old' \
69 &> /test.output
70
71 find / -xdev -type f -not -path '/var/*' \
72 -not -path '/usr/lib/modules/*/modules.*' \
73 -not -path '/etc/*-' \
74 -not -path '/etc/.pwd.lock' \
75 -not -path '/run/mount/utab' \
76 -not -path '/test.sh' \
77 -not -path '/test.output' \
78 -not -path '/etc/nsswitch.conf.bak' \
79 -not -path '/etc/iscsi/initiatorname.iscsi' \
80 -not -path '/boot/*0-rescue*' \
81 -not -path '/usr/share/mime/*' \
82 -not -path '/etc/crypto-policies/*' \
83 -not -path '/dev/null' \
84 -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \
85 -not -path "/boot/\$(cat /etc/machine-id)/*" \
86 -not -path '/etc/openldap/certs/*' \
87 -print0 | xargs -0 rpm -qf | \
88 grep -F 'not owned' &>> /test.output || :
89 exit 0
90 EOF
91
92 chmod 0755 "$rootdir/test.sh"
93
94 chroot "$rootdir" /test.sh || :
95
96 if [[ -s "$rootdir"/test.output ]]; then
97 failed=1
98 echo TEST Failed >&2
99 cat "$rootdir"/test.output >&2
100 fi
101
102 umount "$rootdir/proc"
103 umount "$rootdir/sys"
104 umount "$rootdir/dev"
105
106 [[ $failed ]] && return 1
107 return 0
108
109 }
110
111 test_setup() {
112 make -C "$basedir" DESTDIR="$TESTDIR/" rpm
113 return 0
114 }
115
116 test_cleanup() {
117 rm -fr -- "$TESTDIR"/*.rpm
118 return 0
119 }
120
121 . $testdir/test-functions