diff --git a/pkg/de-p1st-installer/PKGBUILD b/pkg/de-p1st-installer/PKGBUILD index 30bb12c..446bdd8 100644 --- a/pkg/de-p1st-installer/PKGBUILD +++ b/pkg/de-p1st-installer/PKGBUILD @@ -2,8 +2,8 @@ _pkgname=installer _reponame=arch pkgname="de-p1st-$_pkgname" -pkgver=0.1.0 -pkgrel=2 +pkgver=0.1.1 +pkgrel=1 pkgdesc="Bash script to install Arch Linux" arch=('any') url="https://codeberg.org/privacy1st/${_reponame}" diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index b44dcf3..0b93848 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -152,6 +152,25 @@ function run_pacstrap() { ;; esac + # If CPU_VENDOR is not empty, then + if [ -n "${CPU_VENDOR}" ]; then + case "${CPU_VENDOR}" in + amd) + PKGS+=('de-p1st-ucode-amd') + ;; + intel) + PKGS+=('de-p1st-ucode-intel') + ;; + none) + PKGS+=('de-p1st-ucode-placeholder') + ;; + *) + echo "Invalid option '${CPU_VENDOR}'!" + return 1 + ;; + esac + fi + local args=() if [ "${PACSTRAP_INTERACTIVE}" = "1" ]; then args+=('-i') # run interactively @@ -286,6 +305,9 @@ function main() { check_network || return $? # out: BIOS_TYPE, FS, HOSTNAME, USERNAME, USER_PWD, LUKS_PWD get_user_input || return $? + # in: CPU_VENDOR (optional) + # out: CPU_VENDOR + get_cpu_vendor || return $? # in: FS # out: FS_DEFAULT_MOUNT_OPTIONS diff --git a/pkg/de-p1st-installer/installer.cfg b/pkg/de-p1st-installer/installer.cfg index d8d46da..5c67d44 100644 --- a/pkg/de-p1st-installer/installer.cfg +++ b/pkg/de-p1st-installer/installer.cfg @@ -19,8 +19,8 @@ FS=BTRFS FS_CHOSEN_MOUNT_OPTIONS=('noatime') # If not booted into the target system, these values should be set: -# CPU_VENDOR: "amd", "intel" or "none" -CPU_VENDOR=none +# CPU_VENDOR: "autodetect", "amd", "intel" or "none" +CPU_VENDOR=autodetect BIOS_TYPE=uefi # If set to "1", then the data, boot and luks partitions diff --git a/pkg/de-p1st-installer/lib/util.sh b/pkg/de-p1st-installer/lib/util.sh index 46e5f6f..7eb55c0 100644 --- a/pkg/de-p1st-installer/lib/util.sh +++ b/pkg/de-p1st-installer/lib/util.sh @@ -52,22 +52,31 @@ function space_separated_to_array() { } function get_cpu_vendor() { + # @pre + # CPU_VENDOR ("", "autodetect") # @post - # CPU_VENDOR ("amd", "intel", "none") + # CPU_VENDOR ("amd", "intel", "none", "") - if [ -z "${CPU_VENDOR}" ]; then - # if CPU_VENDOR has no value yet, ask user for input! + if [[ -z "${CPU_VENDOR}" ]] || [[ "${CPU_VENDOR}" == "autodetect" ]]; then - local vendor_id - vendor_id=$(cat /proc/cpuinfo | grep vendor_id | head -1 | sed 's|vendor_id\s*:\s*||') + # If run virtual environment (e.g. VirtualBox) then no CPU microcode is required + if cat /proc/cpuinfo | grep '^flags.*hypervisor'; then + echo "Detected virtual environment." + CPU_VENDOR="none" - if [ "$vendor_id" = "AuthenticAMD" ]; then - CPU_VENDOR="amd" - elif [ "$vendor_id" = "GenuineIntel" ]; then - CPU_VENDOR="intel" else - echo "Unknown CPU vendor: $vendor_id" - return 1 + local vendor_id + vendor_id=$(cat /proc/cpuinfo | grep vendor_id | head -1 | sed 's|vendor_id\s*:\s*||') + + if [ "$vendor_id" = "AuthenticAMD" ]; then + CPU_VENDOR="amd" + elif [ "$vendor_id" = "GenuineIntel" ]; then + CPU_VENDOR="intel" + else + echo "Unknown CPU vendor" + return 1 + fi fi + fi }