Skip to content

Commit f3e5f0d

Browse files
JackThomson2roypat
authored andcommitted
ci: Update script to install for AL23
Update the build script to allow us to install the secret hidden kernels onto Amazon Linux 2023 instances. We have to as part of this include a script to download and install ena drivers for the instance to allow us to boot. Signed-off-by: Jack Thomson <[email protected]>
1 parent cfd4d8b commit f3e5f0d

File tree

3 files changed

+83
-10
lines changed

3 files changed

+83
-10
lines changed

resources/hiding_ci/build_and_install_kernel.sh

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ check_root() {
1313
fi
1414
}
1515

16-
check_ubuntu() {
17-
# Currently this script only works on Ubuntu instances
18-
if ! grep -qi 'ubuntu' /etc/os-release; then
19-
echo "This script currently only works on Ubuntu."
20-
exit 1
16+
check_userspace() {
17+
# Currently this script only works on Ubuntu and AL2023
18+
if grep -qi 'ubuntu' /etc/os-release; then
19+
USERSPACE="UBUNTU"
20+
return 0
21+
fi
22+
23+
if grep -qi 'al2023' /etc/os-release; then
24+
USERSPACE="AL2023"
25+
return 0
2126
fi
27+
28+
echo "This script currently only works on Ubuntu and Amazon Linux 2023."
29+
exit 1
2230
}
2331

2432
tidy_up() {
@@ -96,6 +104,39 @@ check_override_presence() {
96104
echo "All overrides correctly applied.."
97105
}
98106

107+
ubuntu_update_boot() {
108+
echo "Update initramfs"
109+
update-initramfs -c -k $KERNEL_VERSION
110+
echo "Updating GRUB..."
111+
update-grub
112+
}
113+
114+
al2023_update_boot() {
115+
echo "Installing ENA driver for AL2023"
116+
$START_DIR/install_ena.sh $KERNEL_VERSION $START_DIR/dkms.conf
117+
118+
# Just ensure we are back in the build dir
119+
cd $TMP_BUILD_DIR
120+
121+
echo "Creating the new ram disk"
122+
dracut --kver $KERNEL_VERSION -f -v
123+
124+
echo "Updating GRUB..."
125+
grubby --grub2 --add-kernel /boot/vmlinux-$KERNEL_VERSION --title="Secret Hiding" --initrd=/boot/initramfs-$KERNEL_VERSION.img --copy-default
126+
grubby --set-default /boot/vmlinux-$KERNEL_VERSION
127+
}
128+
129+
update_boot_config() {
130+
case "$USERSPACE" in
131+
UBUNTU) ubuntu_update_boot ;;
132+
AL2023) al2023_update_boot ;;
133+
*)
134+
echo "Unknown userspace"
135+
exit 1
136+
;;
137+
esac
138+
}
139+
99140
KERNEL_URL=$(cat kernel_url)
100141
KERNEL_COMMIT_HASH=$(cat kernel_commit_hash)
101142
KERNEL_PATCHES_DIR=$(pwd)/patches
@@ -155,16 +196,14 @@ echo "New kernel version:" $KERNEL_VERSION
155196
confirm "$@"
156197

157198
check_root
158-
check_ubuntu
199+
check_userspace
159200

160201
echo "Installing kernel modules..."
161202
make INSTALL_MOD_STRIP=1 modules_install
162203
echo "Installing kernel..."
163204
make INSTALL_MOD_STRIP=1 install
164-
echo "Update initramfs"
165-
update-initramfs -c -k $KERNEL_VERSION
166-
echo "Updating GRUB..."
167-
update-grub
205+
206+
update_boot_config
168207

169208
echo "Kernel built and installed successfully!"
170209

resources/hiding_ci/dkms.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PACKAGE_NAME="ena"
2+
PACKAGE_VERSION="1.0.0"
3+
CLEAN="make -C kernel/linux/ena clean"
4+
MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=${kernelver}"
5+
BUILT_MODULE_NAME[0]="ena"
6+
BUILT_MODULE_LOCATION="kernel/linux/ena"
7+
DEST_MODULE_LOCATION[0]="/updates"
8+
DEST_MODULE_NAME[0]="ena"
9+
REMAKE_INITRD="yes"
10+
AUTOINSTALL="yes"

resources/hiding_ci/install_ena.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# # SPDX-License-Identifier: Apache-2.0
4+
5+
# fail if we encounter an error, uninitialized variable or a pipe breaks
6+
set -eu -o pipefail
7+
8+
AMZN_DRIVER_VERSION="2.13.3"
9+
KERNEL_VERSION=$1
10+
DKMS_CONF_LOCATION=$2
11+
START_DIR=$(pwd)
12+
13+
cd /tmp/
14+
15+
git clone --depth=1 https://github.com/amzn/amzn-drivers.git
16+
mv amzn-drivers /usr/src/amzn-drivers-${AMZN_DRIVER_VERSION}
17+
18+
cp $DKMS_CONF_LOCATION /usr/src/amzn-drivers-${AMZN_DRIVER_VERSION}
19+
20+
dkms add -m amzn-drivers -v ${AMZN_DRIVER_VERSION}
21+
dkms build -k ${KERNEL_VERSION} -m amzn-drivers -v ${AMZN_DRIVER_VERSION}
22+
dkms install -k ${KERNEL_VERSION} -m amzn-drivers -v ${AMZN_DRIVER_VERSION}
23+
24+
cd $START_DIR

0 commit comments

Comments
 (0)