Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 38 additions & 20 deletions bin/omarchy-pkg-add
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,47 @@ if [[ ${OMARCHY_PKG_DEFER:-} == "1" && -n ${OMARCHY_PKG_QUEUE_FILE:-} ]]; then
fi

flushed_queue=0
queued_missing=0
packages=()
declare -A seen=()

if (( $# > 0 )); then
# When every requested package is already installed, leave any deferred queue
# intact for the final flush instead of running pacman mid-pass.
omarchy-pkg-missing "$@" || exit 0

missing_args=()
for pkg in "$@"; do
[[ -n $pkg && -z ${seen[$pkg]+x} ]] || continue
seen[$pkg]=1
if omarchy-pkg-missing "$pkg"; then
missing_args+=("$pkg")
fi
done

if (( ${#missing_args[@]} == 0 )); then
exit 0
fi

seen=()
fi

if [[ -n ${OMARCHY_PKG_QUEUE_FILE:-} && -s $OMARCHY_PKG_QUEUE_FILE ]]; then
flushed_queue=1
declare -A seen=()
while IFS= read -r pkg; do
[[ -n $pkg && -z ${seen[$pkg]+x} ]] || continue
seen[$pkg]=1
if ! pacman -Q -- "$pkg" &>/dev/null; then
packages+=("$pkg")
queued_missing=1
fi
done <"$OMARCHY_PKG_QUEUE_FILE"
fi

for pkg in "$@"; do
if (( $# > 0 )); then
for pkg in "${missing_args[@]}"; do
[[ -z ${seen[$pkg]+x} ]] || continue
seen[$pkg]=1
packages+=("$pkg")
done
else
packages=("$@")
fi

if (( ${#packages[@]} == 0 )); then
Expand All @@ -42,22 +62,20 @@ if (( ${#packages[@]} == 0 )); then
exit 0
fi

if (( queued_missing )) || omarchy-pkg-missing "${packages[@]}"; then
if (( EUID == 0 )); then
pacman -S --noconfirm --needed -- "${packages[@]}" || exit 1
else
sudo pacman -S --noconfirm --needed -- "${packages[@]}" || exit 1
fi

for pkg in "${packages[@]}"; do
# Secondary check to handle states where pacman doesn't actually register an error
if ! pacman -Q -- "$pkg" &>/dev/null; then
echo -e "\033[31mError: Package '$pkg' did not install\033[0m" >&2
exit 1
fi
done
if (( EUID == 0 )); then
pacman -S --noconfirm --needed -- "${packages[@]}" || exit 1
else
sudo pacman -S --noconfirm --needed -- "${packages[@]}" || exit 1
fi

for pkg in "${packages[@]}"; do
# Secondary check to handle states where pacman doesn't actually register an error
if ! pacman -Q -- "$pkg" &>/dev/null; then
echo -e "\033[31mError: Package '$pkg' did not install\033[0m" >&2
exit 1
fi
done

if (( flushed_queue )); then
: >"$OMARCHY_PKG_QUEUE_FILE" || exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions install/hardware/n1x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bios_version=$(cat /sys/class/dmi/id/bios_version 2>/dev/null || true)
rm -f /etc/modprobe.d/nvidia.conf /etc/mkinitcpio.conf.d/nvidia.conf /etc/modprobe.d/omarchy-n1x-nvidia-disable.conf
if [[ ! $bios_version =~ ^0\. ]]; then
echo "N1x firmware $bios_version: GPU drives the panel"
omarchy-pkg-add linux-omarchy-nvidia-open nvidia-utils libva-nvidia-driver nvidia-container-toolkit
OMARCHY_PKG_DEFER=1 omarchy-pkg-add linux-omarchy-nvidia-open nvidia-utils libva-nvidia-driver nvidia-container-toolkit
cat > /etc/modprobe.d/nvidia.conf <<'CONF'
options nvidia_drm modeset=1 fbdev=1
CONF
Expand Down Expand Up @@ -193,4 +193,4 @@ fi

# omarchy-n1x-probe collects hardware and boot evidence on demand and uses
# lspci.
omarchy-pkg-add pciutils
OMARCHY_PKG_DEFER=1 omarchy-pkg-add pciutils
6 changes: 5 additions & 1 deletion install/hardware/set-wireless-regdom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ if [[ ! $country =~ ^[A-Z]{2}$ && -n $timezone && -f $zone_tab ]]; then
fi

if [[ $country =~ ^[A-Z]{2}$ ]]; then
echo "WIRELESS_REGDOM=\"$country\"" | sudo tee -a "$regdom_file" >/dev/null
if (( EUID == 0 )); then
printf 'WIRELESS_REGDOM="%s"\n' "$country" >>"$regdom_file"
else
printf 'WIRELESS_REGDOM="%s"\n' "$country" | sudo tee -a "$regdom_file" >/dev/null
fi
fi
86 changes: 56 additions & 30 deletions install/helpers/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,64 @@ stop_install_log() {
fi
}

omarchy_is_aarch64_leaf() {
omarchy_leaf_platform() {
local -n _platform_out="$2"

case "$1" in
hardware/gb10/sleep.sh | \
hardware/gb10/cpuidle.sh | \
hardware/gb10/memory-watermark.sh | \
hardware/gb10/nvidia-memory-pools.sh | \
hardware/nvidia/dgx-spark-boot.sh | \
hardware/n1x.sh | \
hardware/asus/fix-asus-zenbook-a16-speakers.sh | \
hardware/asus/fix-asus-zenbook-14-ux3480qa-audio.sh | \
hardware/asus/fix-asus-proart-pz13-speakers.sh | \
hardware/intel/* | \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 ARM skips Intel Wi-Fi fix

hardware/intel/* includes fix-wifi7-eht.sh, which fixes Intel BE200/BE211 Wi-Fi cards, not Intel CPUs. If an ARM machine uses one of these PCIe cards, this mapping skips the fix before its device check can run. The card keeps the broken Wi-Fi 7 mode, leaving Wi-Fi unusably slow.

Keep this leaf outside the x86-only mapping so its device check still runs.

hardware/apple/* | \
hardware/asus-rog.sh | \
hardware/framework16.sh | \
hardware/framework/qmk-hid.sh | \
hardware/surface.sh | \
hardware/dell-xps13-ptl-speaker-firmware.sh | \
hardware/dell-xps13-sidecar-amps.sh | \
hardware/asus/fix-asus-ptl-display-backlight.sh | \
hardware/asus/fix-asus-ptl-b9406-display.sh | \
hardware/asus/fix-asus-ptl-b9406-touchpad.sh | \
hardware/asus/fix-z13-touchpad.sh | \
hardware/hp/fix-hp-zbook-ultra-g3a-sleep.sh | \
hardware/hp/fix-hp-zbook-ultra-g3a-display.sh | \
hardware/lenovo/fix-yoga-pro7-bass-speakers.sh | \
hardware/fix-bcm43xx.sh | \
hardware/fix-surface-keyboard.sh | \
user/hardware/asus/fix-audio-mixer.sh | \
user/hardware/asus/fix-mic.sh | \
user/hardware/framework/fix-f13-amd-audio-input.sh | \
user/hardware/dell/xps13-text-scaling.sh)
_platform_out=x86
return 0
;;
hardware/gb10/* | \
hardware/nvidia/dgx-spark-boot.sh)
_platform_out=aarch64-gb10
return 0
;;
hardware/n1x.sh | \
hardware/fix-n1x-gpu-memory.sh | \
hardware/asus/fix-asus-proart-p14-speakers.sh)
_platform_out=aarch64-n1x
return 0
;;
hardware/raspberrypi/*)
_platform_out=aarch64
return 0
;;
hardware/qualcomm/* | \
hardware/acer/fix-acer-aspire-16-ai-speakers.sh | \
hardware/acer/fix-acer-aspire-16-ai-boot.sh | \
hardware/hp/fix-hp-omnibook-3-speakers.sh | \
hardware/asus/fix-asus-zenbook-a16-speakers.sh | \
hardware/asus/fix-asus-zenbook-a16-boot.sh | \
hardware/asus/fix-asus-zenbook-a16-firmware.sh | \
hardware/asus/fix-asus-zenbook-14-ux3480qa-audio.sh | \
hardware/asus/fix-asus-zenbook-14-ux3480qa-boot.sh | \
hardware/asus/fix-asus-zenbook-a14-boot.sh | \
hardware/asus/fix-asus-proart-pz13-speakers.sh | \
hardware/asus/fix-asus-vivobook-s15-boot.sh | \
hardware/asus/fix-asus-vivobook-s16-boot.sh | \
hardware/hp/fix-hp-omnibook-3-speakers.sh | \
hardware/hp/fix-hp-omnibook-x14-boot.sh | \
hardware/lenovo/fix-lenovo-ideacentre-mini-boot.sh | \
hardware/fix-n1x-gpu-memory.sh | \
hardware/raspberrypi/raspberry-pi-4.sh | \
hardware/qualcomm/dtb-uki.sh | \
hardware/qualcomm/kernel-params.sh | \
hardware/qualcomm/initramfs.sh | \
hardware/qualcomm/glymur-display.sh | \
hardware/qualcomm/hamoa-display.sh | \
hardware/asus/fix-asus-zenbook-a16-firmware.sh | \
hardware/qualcomm/oem-firmware.sh | \
hardware/qualcomm/firmware.sh | \
hardware/qualcomm/camera.sh | \
hardware/qualcomm/reboot-watchdog.sh | \
hardware/qualcomm/powerprofiles-floor.sh | \
hardware/lenovo/yoga-slim7x.sh | \
hardware/lenovo/thinkpad-t14s-camera.sh | \
hardware/lenovo/ideapad-slim-5x.sh | \
Expand All @@ -87,6 +111,7 @@ omarchy_is_aarch64_leaf() {
hardware/microsoft/surface-laptop8.sh | \
hardware/samsung/galaxy-book4-edge-14.sh | \
user/hardware/qualcomm/video-decode.sh)
_platform_out=aarch64-qualcomm
return 0
;;
*)
Expand All @@ -99,18 +124,19 @@ omarchy_skip_leaf() {
local install_root="${OMARCHY_INSTALL:-}"
[[ -n $install_root ]] || return 1
local rel="${1#"${install_root%/}/"}"
local required=""

omarchy_is_aarch64_leaf "$rel" || return 1
omarchy_leaf_platform "$rel" required || return 1

if [[ -z ${_omarchy_hw_is_aarch64:-} ]]; then
if omarchy-hw-aarch64; then
_omarchy_hw_is_aarch64=1
if [[ -z ${_omarchy_hw_platform:-} ]]; then
if ! omarchy-hw-aarch64; then
_omarchy_hw_platform=x86
else
_omarchy_hw_is_aarch64=0
_omarchy_hw_platform=$(omarchy-hw-platform 2>/dev/null || echo aarch64)
fi
fi

(( ! _omarchy_hw_is_aarch64 ))
[[ $_omarchy_hw_platform != "$required" ]]
}

run_logged() {
Expand Down
51 changes: 38 additions & 13 deletions test/shell.d/pkg-drop-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ PATH="$add_bin:$ROOT/bin:$PATH" TEST_TMP="$test_tmp" OMARCHY_PKG_QUEUE_FILE="$qu
"$ROOT/bin/omarchy-pkg-add" pkg-b pkg-c
[[ ! -e $test_tmp/pkg-add-calls ]] || fail "deferred pkg-add must not invoke pacman immediately"

# Calling omarchy-pkg-add without OMARCHY_PKG_DEFER=1 for already-installed
# packages must not flush the deferred queue early.
PATH="$add_bin:$ROOT/bin:$PATH" TEST_TMP="$test_tmp" OMARCHY_PKG_QUEUE_FILE="$queue_file" \
"$ROOT/bin/omarchy-pkg-add" pkg-d
"$ROOT/bin/omarchy-pkg-add" already-installed
[[ ! -e $test_tmp/pkg-add-calls ]] || fail "already-installed immediate pkg-add must not flush deferred queue early"
[[ -s $queue_file ]] || fail "already-installed immediate pkg-add must keep deferred queue intact"

PATH="$add_bin:$ROOT/bin:$PATH" TEST_TMP="$test_tmp" OMARCHY_PKG_QUEUE_FILE="$queue_file" \
"$ROOT/bin/omarchy-pkg-add" already-installed pkg-d
[[ $(<"$test_tmp/pkg-add-calls") == "-S --noconfirm --needed -- pkg-a pkg-b pkg-c pkg-d" ]] ||
fail "immediate pkg-add flushes deduplicated missing queued packages in one transaction" "$(<"$test_tmp/pkg-add-calls")"
[[ ! -s $queue_file ]] || fail "queue file must be empty after flush"
Expand Down Expand Up @@ -166,15 +173,19 @@ PATH="$add_bin:$ROOT/bin:$PATH" TEST_TMP="$test_tmp" \
[[ ! -s $queue_file && ! -s $service_queue ]] || fail "both queues are cleared when packages were already installed"
pass "flush-packages.sh enables queued services when packages are already installed"

# run_logged skips strictly ARM-only leaves on x86_64 at execution time while
# running all leaves on aarch64 and keeping hardware/all.sh pure run_logged lines
# so image builds enumerate the full ordered list.
hw_x86_bin="$test_tmp/uname-x86"
hw_arm_bin="$test_tmp/uname-arm"
mkdir -p "$hw_x86_bin" "$hw_arm_bin"
# run_logged skips leaves belonging to other platforms at execution time while
# keeping hardware/all.sh pure run_logged lines so image builds enumerate the
# full ordered list.
hw_x86_bin="$test_tmp/platform-x86"
hw_n1x_bin="$test_tmp/platform-n1x"
hw_qcom_bin="$test_tmp/platform-qcom"
mkdir -p "$hw_x86_bin" "$hw_n1x_bin" "$hw_qcom_bin"
printf '#!/bin/bash\n[[ ${1:-} == -m ]] && { echo x86_64; exit 0; }\nexec /usr/bin/uname "$@"\n' >"$hw_x86_bin/uname"
printf '#!/bin/bash\n[[ ${1:-} == -m ]] && { echo aarch64; exit 0; }\nexec /usr/bin/uname "$@"\n' >"$hw_arm_bin/uname"
chmod +x "$hw_x86_bin/uname" "$hw_arm_bin/uname"
printf '#!/bin/bash\n[[ ${1:-} == -m ]] && { echo aarch64; exit 0; }\nexec /usr/bin/uname "$@"\n' >"$hw_n1x_bin/uname"
printf '#!/bin/bash\necho aarch64-n1x\n' >"$hw_n1x_bin/omarchy-hw-platform"
printf '#!/bin/bash\n[[ ${1:-} == -m ]] && { echo aarch64; exit 0; }\nexec /usr/bin/uname "$@"\n' >"$hw_qcom_bin/uname"
printf '#!/bin/bash\necho aarch64-qualcomm\n' >"$hw_qcom_bin/omarchy-hw-platform"
chmod +x "$hw_x86_bin/uname" "$hw_n1x_bin/uname" "$hw_n1x_bin/omarchy-hw-platform" "$hw_qcom_bin/uname" "$hw_qcom_bin/omarchy-hw-platform"

list_hw_executed() {
local bin_dir=$1
Expand All @@ -196,18 +207,32 @@ list_hw_enumerated() {
}

hw_x86=$(list_hw_executed "$hw_x86_bin")
hw_arm=$(list_hw_executed "$hw_arm_bin")
hw_n1x=$(list_hw_executed "$hw_n1x_bin")
hw_qcom=$(list_hw_executed "$hw_qcom_bin")
hw_enum=$(list_hw_enumerated "$hw_x86_bin")

[[ $hw_arm == "$hw_enum" ]] || fail "aarch64 execution and image enumeration must match the full ordered hardware leaf list"
! grep -qx 'hardware/qualcomm/firmware.sh' <<<"$hw_x86" || fail "x86 execution must skip Qualcomm leaves"
! grep -qx 'hardware/qualcomm/hibernation.sh' <<<"$hw_x86" || fail "x86 execution must skip Qualcomm hibernation leaf"
! grep -qx 'hardware/gb10/sleep.sh' <<<"$hw_x86" || fail "x86 execution must skip GB10 leaves"
! grep -qx 'hardware/n1x.sh' <<<"$hw_x86" || fail "x86 execution must skip N1x leaf"
grep -qx 'hardware/nvidia.sh' <<<"$hw_x86" || fail "x86 execution must keep mixed nvidia.sh leaf"
grep -qx 'hardware/fix-fkeys.sh' <<<"$hw_x86" || fail "x86 execution must keep fix-fkeys.sh"
grep -qx 'hardware/apple/fix-brcmfmac-supplicant.sh' <<<"$hw_x86" || fail "x86 execution must keep mixed Apple Broadcom leaf"
grep -qx 'hardware/apple/fix-brcmfmac-supplicant.sh' <<<"$hw_x86" || fail "x86 execution must keep Intel Apple Broadcom leaf"
grep -qx 'hardware/qualcomm/firmware.sh' <<<"$hw_enum" || fail "image enumeration on x86 must include ARM leaves"
pass "run_logged skips strictly ARM-only leaves on x86 while preserving full image enumeration"

grep -qx 'hardware/n1x.sh' <<<"$hw_n1x" || fail "N1x execution must keep N1x leaf"
grep -qx 'hardware/dell-xps-touchpad-haptics.sh' <<<"$hw_n1x" || fail "N1x execution must keep Dell XPS haptic touchpad leaf"
! grep -qx 'hardware/intel/lpmd.sh' <<<"$hw_n1x" || fail "N1x execution must skip Intel leaves"
! grep -qx 'hardware/apple/fix-t2.sh' <<<"$hw_n1x" || fail "N1x execution must skip Intel Apple leaves"
! grep -qx 'hardware/qualcomm/firmware.sh' <<<"$hw_n1x" || fail "N1x execution must skip Qualcomm leaves"
! grep -qx 'hardware/gb10/sleep.sh' <<<"$hw_n1x" || fail "N1x execution must skip GB10 leaves"
! grep -qx 'hardware/raspberrypi/raspberry-pi-4.sh' <<<"$hw_n1x" || fail "N1x execution must skip Raspberry Pi leaves"

grep -qx 'hardware/qualcomm/firmware.sh' <<<"$hw_qcom" || fail "Qualcomm execution must keep Qualcomm leaves"
grep -qx 'hardware/qualcomm/hibernation.sh' <<<"$hw_qcom" || fail "Qualcomm execution must keep Qualcomm hibernation leaf"
! grep -qx 'hardware/n1x.sh' <<<"$hw_qcom" || fail "Qualcomm execution must skip N1x leaves"
! grep -qx 'hardware/intel/lpmd.sh' <<<"$hw_qcom" || fail "Qualcomm execution must skip Intel leaves"
pass "run_logged skips non-matching platform leaves while preserving full image enumeration"

# install/hardware/network.sh batches systemctl disable and falls back per-unit on error.
# Copy the script with /etc/systemd/network pointed at test_tmp so host files are never touched.
Expand Down