]>
Commit | Line | Data |
---|---|---|
4eafdbdb | 1 | #!/bin/bash |
967cc19a | 2 | |
4eafdbdb | 3 | TEST_DESCRIPTION="rpm integrity after dracut and kernel install" |
e22e04ae HH |
4 | |
5 | test_check() { | |
6 | command -v rpm &>/dev/null && ( command -v yum || command -v dnf ) &>/dev/null | |
7 | } | |
4eafdbdb HH |
8 | |
9 | test_run() { | |
10 | set -x | |
00929425 | 11 | set -e |
4eafdbdb HH |
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" | |
eac751f1 | 19 | mkdir -p "$rootdir/boot" |
4eafdbdb | 20 | |
ffc2ca20 HH |
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 | |
43bac63e | 23 | |
4eafdbdb HH |
24 | mount --bind /proc "$rootdir/proc" |
25 | mount --bind /sys "$rootdir/sys" | |
26 | mount -t devtmpfs devtmpfs "$rootdir/dev" | |
27 | ||
eac751f1 HH |
28 | mkdir -p "$rootdir/$TESTDIR" |
29 | cp --reflink=auto -a \ | |
12f023ab JW |
30 | "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \ |
31 | "$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \ | |
eac751f1 | 32 | "$rootdir/$TESTDIR/" |
286685cb | 33 | . /etc/os-release |
00929425 | 34 | dnf_or_yum=yum |
eac751f1 HH |
35 | dnf_or_yum_cmd=yum |
36 | command -v dnf >/dev/null && { dnf_or_yum="dnf"; dnf_or_yum_cmd="dnf --allowerasing"; } | |
ffc2ca20 | 37 | for (( i=0; i < 5 ; i++)); do |
286685cb | 38 | $dnf_or_yum_cmd -v --nogpgcheck --installroot "$rootdir"/ --releasever "$VERSION_ID" --disablerepo='*' \ |
ffc2ca20 HH |
39 | --enablerepo=fedora --enablerepo=updates \ |
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 \ | |
12f023ab | 54 | "$TESTDIR"/dracut-[0-9]*.$(uname -m).rpm \ |
f13278ea | 55 | ${NULL} && break |
12f023ab JW |
56 | #"$TESTDIR"/dracut-config-rescue-[0-9]*.$(uname -m).rpm \ |
57 | #"$TESTDIR"/dracut-network-[0-9]*.$(uname -m).rpm \ | |
ffc2ca20 HH |
58 | # ${NULL} |
59 | done | |
60 | (( i < 5 )) | |
4eafdbdb HH |
61 | |
62 | cat >"$rootdir"/test.sh <<EOF | |
63 | #!/bin/bash | |
eac751f1 | 64 | set -x |
4eafdbdb | 65 | export LC_MESSAGES=C |
e3fb6458 HH |
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 | ||
4eafdbdb HH |
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' \ | |
db9fbaf9 | 80 | -not -path '/boot/*0-rescue*' \ |
00929425 HH |
81 | -not -path '/usr/share/mime/*' \ |
82 | -not -path '/etc/crypto-policies/*' \ | |
4eafdbdb | 83 | -not -path '/dev/null' \ |
fd28794b HH |
84 | -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \ |
85 | -not -path "/boot/\$(cat /etc/machine-id)/*" \ | |
eac751f1 HH |
86 | -not -path '/etc/openldap/certs/*' \ |
87 | -print0 | xargs -0 rpm -qf | \ | |
00929425 HH |
88 | grep -F 'not owned' &>> /test.output || : |
89 | exit 0 | |
4eafdbdb HH |
90 | EOF |
91 | ||
92 | chmod 0755 "$rootdir/test.sh" | |
93 | ||
00929425 | 94 | chroot "$rootdir" /test.sh || : |
4eafdbdb HH |
95 | |
96 | if [[ -s "$rootdir"/test.output ]]; then | |
ffc2ca20 HH |
97 | failed=1 |
98 | echo TEST Failed >&2 | |
99 | cat "$rootdir"/test.output >&2 | |
4eafdbdb HH |
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() { | |
924a669a | 112 | make -C "$basedir" DESTDIR="$TESTDIR/" rpm |
4eafdbdb HH |
113 | return 0 |
114 | } | |
115 | ||
116 | test_cleanup() { | |
2811e4ed | 117 | rm -fr -- "$TESTDIR"/*.rpm |
4eafdbdb HH |
118 | return 0 |
119 | } | |
120 | ||
121 | . $testdir/test-functions |