From c2a91d70884deb57767fa4677ed59babaf3a2783 Mon Sep 17 00:00:00 2001 From: "Emanuele \"Lele\" Calo" Date: Mon, 3 Feb 2025 01:44:39 +0100 Subject: [PATCH] kernel: fix script #3 --- .scripts/linux/kernel_build.sh | 78 ++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/.scripts/linux/kernel_build.sh b/.scripts/linux/kernel_build.sh index 08154e4..f717b05 100755 --- a/.scripts/linux/kernel_build.sh +++ b/.scripts/linux/kernel_build.sh @@ -1,43 +1,57 @@ #!/usr/bin/env bash -set -e +set -eux TMPDIR="$(mktemp)" echo "cloning AMD SNP kernel in tmp directory ${TMPDIR}" -cd "${TMPDIR}" && - git clone \ - https://github.com/confidential-containers/linux \ - --single-branch \ - -b amd-snp-host-202402240000 && - cd linux +( + cd "${TMPDIR}" && + git clone \ + https://github.com/confidential-containers/linux \ + --single-branch \ + -b amd-snp-host-202402240000 && + cd linux +) >/dev/null 2>&1 VER="-snp-host" DATE="$(date +%Y-%m-%d-%H-%M)" -echo "building and installing kernel... this will take while" && - echo "Copying current config to new kernel" && - cp /boot/config-$(uname -r) .config && - echo "Patching new kernel" && +echo "building and installing kernel... this will take while" +echo "Copying current config to new kernel" +( + cp /boot/config-$(uname -r) .config +) >/dev/null 2>&1 + +echo "Patching new kernel" +( ./scripts/config --set-str LOCALVERSION "$VER-$DATE" && - ./scripts/config --disable LOCALVERSION_AUTO && - ./scripts/config --enable DEBUG_INFO && - ./scripts/config --enable DEBUG_INFO_REDUCED && - ./scripts/config --enable EXPERT && - ./scripts/config --enable AMD_MEM_ENCRYPT && - ./scripts/config --disable AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT && - ./scripts/config --enable KVM_AMD_SEV && - ./scripts/config --module CRYPTO_DEV_CCP_DD && - ./scripts/config --disable SYSTEM_TRUSTED_KEYS && - ./scripts/config --disable SYSTEM_REVOCATION_KEYS && - ./scripts/config --module SEV_GUEST && - ./scripts/config --disable IOMMU_DEFAULT_PASSTHROUGH && - echo "Building new kernel" && + ./scripts/config --disable LOCALVERSION_AUTO && + ./scripts/config --enable DEBUG_INFO && + ./scripts/config --enable DEBUG_INFO_REDUCED && + ./scripts/config --enable EXPERT && + ./scripts/config --enable AMD_MEM_ENCRYPT && + ./scripts/config --disable AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT && + ./scripts/config --enable KVM_AMD_SEV && + ./scripts/config --module CRYPTO_DEV_CCP_DD && + ./scripts/config --disable SYSTEM_TRUSTED_KEYS && + ./scripts/config --disable SYSTEM_REVOCATION_KEYS && + ./scripts/config --module SEV_GUEST && + ./scripts/config --disable IOMMU_DEFAULT_PASSTHROUGH +) >/dev/null 2>&1 + +echo "Building new kernel" +( yes "" | make olddefconfig && - make -j$(nproc) LOCAL_VERSION="$VER-$DATE" && - make -j$(nproc) modules_install && - make -j$(nproc) install && - echo "Kernel Built, configuring and updating GRUB" && + make -j$(nproc) LOCAL_VERSION="$VER-$DATE" && + make -j$(nproc) modules_install && + make -j$(nproc) install +) >/dev/null 2>&1 + +echo "Kernel Built, configuring and updating GRUB" +( sed -i 's/iommu=pt/iommu=nopt/g' /etc/default/grub && - update-grub && - rm -rf "${TMPDIR}" && - echo "cleaning kernel tmp directory ${TMPDIR}" && - echo "Work completed. You should now reboot." + update-grub && + rm -rf "${TMPDIR}" +) >/dev/null 2>&1 + +echo "cleaning kernel tmp directory ${TMPDIR}" +echo "Work completed. You should now reboot."