Skip to content

Commit

Permalink
macos: Install older kernel
Browse files Browse the repository at this point in the history
Because of crc-org/vfkit#11 we need to use an
older kernel with our macOS bundles.
This is fixed in macOS 13, but we want to keep compatibility with macOS
12 for a while.
With the changes made in the previous commits, this is relatively
straightforward to add.
This uses the latest 5.18 fedora kernel on M1, and latest 5.19 fedora
kernel on Intel macbooks.
  • Loading branch information
cfergeau committed Dec 20, 2022
1 parent e799efe commit 696c1fc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
17 changes: 17 additions & 0 deletions createdisk-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,23 @@ function install_additional_packages() {
fi
}

function downgrade_kernel() {
# workaround https://github.com/crc-org/vfkit/issues/11 on macOS
local vm_ip=$1
local arch=$2
case $arch in
amd64)
${SSH} core@${vm_ip} "curl -L -O https://kojipkgs.fedoraproject.org/packages/kernel/5.19.17/300.fc37/x86_64/kernel-5.19.17-300.fc37.x86_64.rpm -L -O https://kojipkgs.fedoraproject.org/packages/kernel/5.19.17/300.fc37/x86_64/kernel-core-5.19.17-300.fc37.x86_64.rpm -L -O https://kojipkgs.fedoraproject.org/packages/kernel/5.19.17/300.fc37/x86_64/kernel-modules-5.19.17-300.fc37.x86_64.rpm"
;;
arm64)
${SSH} core@${vm_ip} "curl -L -O https://kojipkgs.fedoraproject.org//packages/kernel/5.18.19/200.fc36/aarch64/kernel-5.18.19-200.fc36.aarch64.rpm -L -O https://kojipkgs.fedoraproject.org//packages/kernel/5.18.19/200.fc36/aarch64/kernel-core-5.18.19-200.fc36.aarch64.rpm -L -O https://kojipkgs.fedoraproject.org//packages/kernel/5.18.19/200.fc36/aarch64/kernel-modules-extra-5.18.19-200.fc36.aarch64.rpm"
;;
esac

${SSH} core@${vm_ip} "sudo rpm-ostree override -C replace *.rpm"
${SSH} core@${vm_ip} "rm *.rpm"
}

function prepare_cockpit() {
local vm_ip=$1

Expand Down
13 changes: 11 additions & 2 deletions createdisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fi
# the content of $libvirtDestDir
if [ -n "${SNC_GENERATE_MACOS_BUNDLE}" ]; then
start_vm ${CRC_VM_NAME} ${VM_IP}
downgrade_kernel ${VM_IP} ${yq_ARCH}
cleanup_vm_image ${CRC_VM_NAME} ${VM_IP}

# Get the rhcos kernel release
Expand All @@ -80,8 +81,16 @@ if [ -n "${SNC_GENERATE_MACOS_BUNDLE}" ]; then
# Get the rhcos ostree Hash ID
ostree_hash=$(echo ${kernel_cmd_line} | grep -oP "(?<=${BASE_OS}-).*(?=/vmlinuz)")

# SCP the vmlinuz/initramfs from VM to Host in provided folder.
${SCP} -r core@${VM_IP}:/boot/ostree/${BASE_OS}-${ostree_hash}/* $INSTALL_DIR
# Copy kernel/initramfs
# A temporary location is needed as the initramfs cannot be directly read
# by the 'core' user
${SSH} core@${VM_IP} -- 'bash -x -s' <<EOF
mkdir /tmp/kernel
sudo cp -r /boot/ostree/${BASE_OS}-${ostree_hash}/*${kernel_release}* /tmp/kernel
sudo chmod 644 /tmp/kernel/initramfs*
EOF
${SCP} -r core@${VM_IP}:/tmp/kernel/* $INSTALL_DIR
${SSH} core@${VM_IP} -- "sudo rm -fr /tmp/kernel"

vfkitDestDir="crc_podman_vfkit_${destDirSuffix}"
generate_vfkit_bundle "$libvirtDestDir" "$vfkitDestDir" "$INSTALL_DIR" "$kernel_release" "$kernel_cmd_line"
Expand Down

0 comments on commit 696c1fc

Please sign in to comment.