chore: Move to using arrays in bazzite-hardware-setup

This commit is contained in:
Kyle Gospodnetich 2023-10-21 00:56:11 -07:00
parent 1e05d4fd19
commit d36b72065f

View File

@ -7,7 +7,7 @@ BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO)
FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO)
# SCRIPT VERSION
HWS_VER=11
HWS_VER=12
HWS_VER_FILE="/etc/bazzite/hws_version"
HWS_VER_RAN=$(cat $HWS_VER_FILE)
@ -36,27 +36,34 @@ fi
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
GPU_ID=$(lspci -k | grep -A 3 -E "(VGA|3D)")
KARGS=$(rpm-ostree kargs)
NEEDED_KARGS=""
NEEDED_KARGS=()
INITRAMFS=$(rpm-ostree initramfs)
NEEDED_INITRAMFS="/etc/crypttab"
NEEDED_INITRAMFS=("/etc/crypttab")
NEEDS_INITRAMFS_APPLICATION=false
# INITRAMFS
echo "Current initramfs: $INITRAMFS"
if [[ $IMAGE_FLAVOR =~ "nvidia" ]]; then
NEEDED_INITRAMFS="$NEEDED_INITRAMFS /etc/modprobe.d/nvidia.conf"
NEEDED_INITRAMFS+=("/etc/modprobe.d/nvidia.conf")
else
NEEDED_INITRAMFS="$NEEDED_INITRAMFS /etc/modprobe.d/amdgpu.conf"
NEEDED_INITRAMFS+=("/etc/modprobe.d/amdgpu.conf")
fi
if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then
NEEDED_INITRAMFS="$NEEDED_INITRAMFS /etc/modprobe.d/deck-blacklist.conf"
NEEDED_INITRAMFS+=("/etc/modprobe.d/deck-blacklist.conf")
fi
if [[ ! $INITRAMFS =~ "$NEEDED_INITRAMFS" ]]; then
echo "Found needed initramfs changes, applying the following: $NEEDED_INITRAMFS"
for INITRAMFS_ARG in ${NEEDED_INITRAMFS[@]}; do
if [[ ! $INITRAMFS =~ "$INITRAMFS_ARG" ]]; then
NEEDS_INITRAMFS_APPLICATION=true
fi
done
if $NEEDS_INITRAMFS_APPLICATION; then
echo "Found needed initramfs changes, applying the following: ${NEEDED_INITRAMFS[*]}"
plymouth display-message --text="Updating initramfs - Please wait, this may take a while" || true
rpm-ostree initramfs --enable --arg="-I ${NEEDED_INITRAMFS}"
rpm-ostree initramfs --enable --arg="-I ${NEEDED_INITRAMFS[*]}"
else
echo "No initramfs changes needed"
fi
@ -68,36 +75,36 @@ if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then
echo "Checking for needed karg changes (Jupiter)"
if [[ ! $KARGS =~ "amd_pstate" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amd_pstate=active"
NEEDED_KARGS+=("--append-if-missing=amd_pstate=active")
fi
if [[ ! $KARGS =~ "amd_iommu" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amd_iommu=off"
NEEDED_KARGS+=("--append-if-missing=amd_iommu=off")
fi
if [[ ! $KARGS =~ "amdgpu.gttsize" ]]; then
if [[ "$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo)" == "31664740" ]]; then
echo "32GB RAM Steam Deck detected"
NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.gttsize=16256"
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=16256")
else
NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=amdgpu.gttsize=8128"
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=8128")
fi
fi
if [[ ! $KARGS =~ "initcall_blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append-if-missing=initcall_blacklist=simpledrm_platform_driver_init"
NEEDED_KARGS+=("--append-if-missing=initcall_blacklist=simpledrm_platform_driver_init")
fi
fi
if [[ $KARGS =~ "nomodeset" ]]; then
echo "Removing nomodeset"
NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=nomodeset"
NEEDED_KARGS+=("--delete-if-present=nomodeset")
fi
if [[ -n "$NEEDED_KARGS" ]]; then
echo "Found needed karg changes, applying the following: $NEEDED_KARGS"
echo "Found needed karg changes, applying the following: ${NEEDED_KARGS[*]}"
plymouth display-message --text="Updating kargs - Please wait, this may take a while" || true
rpm-ostree kargs ${NEEDED_KARGS} --reboot || exit 1
rpm-ostree kargs ${NEEDED_KARGS[*]} --reboot || exit 1
else
echo "No karg changes needed"
fi