-
Notifications
You must be signed in to change notification settings - Fork 157
/
kernel-replace
executable file
·124 lines (118 loc) · 4.73 KB
/
kernel-replace
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
## kola:
## # Increase timeout since this test has a lot of I/O and involves rebasing
## timeoutMin: 20
## # We've seen some OOM when 1024M is used:
## # https://github.com/coreos/fedora-coreos-tracker/issues/1506
## minMemory: 2048
## # This test only runs on FCOS due to a problem with skopeo copy on
## # RHCOS. See: https://github.com/containers/skopeo/issues/1846
## distros: fcos
## # Needs internet access as we fetch files from koji
## # We add the "reprovision" tag here even though we aren't
## # reprovisioning as a hack so that in our pipeline the test
## # will execute with no other tests. We were seeing a lot of
## # timeouts on ppc64le.
## tags: "needs-internet platform-independent reprovision"
## description: Verify that build of a container image with a new kernel
## and reboot into it succeeds.
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euxo pipefail
# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"
cd $(mktemp -d)
# TODO: It'd be much better to test this via a registry
image_dir=/var/tmp/fcos
image=oci:$image_dir
image_pull=ostree-unverified-image:$image
tmp_imagedir=/var/tmp/fcos-tmp
arch=$(arch)
kver="6.2.9-300.fc38.${arch}"
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# Take the existing ostree commit, and export it to a container image, then rebase to it.
rpm-ostree status --json > status.json
checksum=$(jq -r '.deployments[0].checksum' < status.json)
v0=$(jq -r '.deployments[0].version' < status.json)
imgref=$(jq -r '.deployments[0]["container-image-reference"]' < status.json)
rm ${image_dir} -rf
encapsulate_args=()
# A hack...if we're booted into a container, then we need to fake things out
# for the merge commit to turn it back into an image. What we *really* want
# here obviously is seamless support for re-serializing a container from
# the ostree storage, but right now we're not doing the tar-split stuff.
if [[ "$imgref" != null ]]; then
encapsulate_args+=("--label" "ostree.bootable=true")
fi
# Since we're switching OS update stream, turn off zincati
systemctl mask --now zincati
ostree container encapsulate "${encapsulate_args[@]}" --repo=/ostree/repo ${checksum} "${image}"
# This one keeps --experimental, but we also test without it below
rpm-ostree rebase --experimental "$image_pull"
ostree container image list --repo=/ostree/repo | tee imglist.txt
# Test rebasing back to ostree https://github.com/coreos/rpm-ostree/issues/3677
rpm-ostree rebase "$checksum"
rpm-ostree rebase "$image_pull"
/tmp/autopkgtest-reboot 1
;;
1)
# Setup
# copy the OCI dir to containers-storage for a local build
skopeo copy $image containers-storage:localhost/fcos
rm "${image_dir}" -rf
td=$(mktemp -d)
cd ${td}
version=$(rpm-ostree --version | grep Version)
cat > Dockerfile << EOF
FROM localhost/fcos
RUN rpm-ostree cliwrap install-to-root /
RUN rpm-ostree override replace \
https://koji.fedoraproject.org/koji/buildinfo?buildID=2178613 && \
ostree container commit
EOF
# Older podman found in RHEL8 blows up without /etc/resolv.conf
# which happens in our qemu path.
touched_resolv_conf=0
if test '!' -f /etc/resolv.conf; then
podmanv=$(podman --version)
case "${podmanv#podman version }" in
3.*) touched_resolv_conf=1; touch /etc/resolv.conf;;
esac
fi
podman build --net=host -t localhost/fcos-derived --squash .
if test "${touched_resolv_conf}" -eq 1; then
rm -vf /etc/resolv.conf
fi
derived=oci:$image_dir:derived
skopeo copy containers-storage:localhost/fcos-derived $derived
rpm-ostree --version
rpm-ostree rebase ostree-unverified-image:$derived
ostree container image list --repo=/ostree/repo
rm $image_dir -rf
/tmp/autopkgtest-reboot 2
;;
2)
un=$(uname -r)
if test "$un" != "$kver"; then
echo "Expected kernel $kver but found $un"
exit 1
fi
test -f /usr/lib/modules/$kver/initramfs.img
test -f /usr/lib/modules/$kver/vmlinuz
esac