Skip to content

Commit 7caefb3

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 <jackabt@amazon.com>
1 parent 606d6dc commit 7caefb3

File tree

3 files changed

+85
-10
lines changed

3 files changed

+85
-10
lines changed

resources/hiding_ci/build_and_install_kernel.sh

Lines changed: 51 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,41 @@ 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 \
126+
--title="Secret Hiding" \
127+
--initrd=/boot/initramfs-$KERNEL_VERSION.img --copy-default
128+
grubby --set-default /boot/vmlinux-$KERNEL_VERSION
129+
}
130+
131+
update_boot_config() {
132+
case "$USERSPACE" in
133+
UBUNTU) ubuntu_update_boot ;;
134+
AL2023) al2023_update_boot ;;
135+
*)
136+
echo "Unknown userspace"
137+
exit 1
138+
;;
139+
esac
140+
}
141+
99142
KERNEL_URL=$(cat kernel_url)
100143
KERNEL_COMMIT_HASH=$(cat kernel_commit_hash)
101144
KERNEL_PATCHES_DIR=$(pwd)/patches
@@ -155,16 +198,14 @@ echo "New kernel version:" $KERNEL_VERSION
155198
confirm "$@"
156199

157200
check_root
158-
check_ubuntu
201+
check_userspace
159202

160203
echo "Installing kernel modules..."
161204
make INSTALL_MOD_STRIP=1 modules_install
162205
echo "Installing kernel..."
163206
make INSTALL_MOD_STRIP=1 install
164-
echo "Update initramfs"
165-
update-initramfs -c -k $KERNEL_VERSION
166-
echo "Updating GRUB..."
167-
update-grub
207+
208+
update_boot_config
168209

169210
echo "Kernel built and installed successfully!"
170211

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)