Make ./install something you could hand a stranger

The audit's third tier: everything between this installer and a fresh machine
it has never met.

The one path that could cost a person their display: the interview probes
Secure Boot with mokutil, which install-packages had not installed yet, so on
a minimal base the MOK question silently never fired -- and install-hardware
still installed akmod-nvidia and blacklisted nouveau, arming a reboot into an
unloadable driver with its fallback disabled. The probe tools (pciutils,
mokutil, fwupd) now bootstrap beside gum, and install-hardware re-checks
Secure Boot for itself and refuses the driver rather than the display.

Secrets leave the checkout: the personal environment moves to
~/.config/panama/env at mode 600 by migration, and .bashrc sources it with a
permission check that quietly re-tightens drift. change-settings no longer
overwrites /etc/dnf/dnf.conf -- two performance keys are set additively, the
defaultyes=True that made every `dnf remove` treat Enter as yes is gone, and
a migration strips it from machines that already received it.

Package installation survives the world changing: the initial and desktop
lists run with --skip-unavailable and a report_missing pass that names what
was skipped (resolved through --whatprovides, so capability names like awk
do not cry wolf); the openh264, appstream and core-group extras go through
soft; RustDesk resolves its RPM for the machine's own architecture; and the
Claude Desktop repository script is fetched to a kept file and run, never
piped from the network into root.

The hardware predicates stop guessing: a wireless mouse's scope=Device
battery no longer turns a tower into a laptop, USB-PD-only machines read
their power state from the battery's own status instead of being permanently
"on AC", the lid falls back to logind's LidClosed where ACPI is silent, and
charge limits reach every pack of a two-battery machine in one authorization
-- with the reported percentage summed across packs.

And the parsers stop assuming this machine: snapper is read through
--machine-readable csv with named columns instead of a localized box-drawing
table, and reports whether snapshots are even possible so ext4 and
unconfigured-btrfs stop looking identical; fprintd is parsed under LC_ALL=C;
the hypridle drop-in resolves the binary it points at; the recorder's render
node became an "auto" token resolved at record time; update-grub writes the
config its firmware actually boots; the nvm prompt hook and the SSH tmux
takeover are guarded; hipblas and rocm-opencl move to an opt-in gpu-compute
category; and the two interactive python tools' libraries are declared.

Claude-Session: https://claude.ai/code/session_01Epx9ZC1gwm81K3jm9x9CKh
This commit is contained in:
Gabriel Brown
2026-08-23 12:10:03 -04:00
parent 44124d72fa
commit 153554b5df
22 changed files with 331 additions and 87 deletions
+33 -12
View File
@@ -38,28 +38,37 @@ is_laptop() {
[[ "$PORTABLE_CHASSIS" == *" $chassis "* ]]
}
# The first battery, or nothing. Named rather than assumed to be BAT0: the
# second battery in a ThinkPad is BAT1, and a machine with only BAT1 exists.
# The first SYSTEM battery, or nothing. Named rather than assumed to be BAT0:
# the second battery in a ThinkPad is BAT1, and a machine with only BAT1
# exists. The scope check is what keeps a desktop a desktop: a wireless mouse
# or a game controller publishes type=Battery with scope=Device, and counting
# one turned a tower into a "laptop" whose battery readout was the mouse's.
battery_path() {
local supply type
local supply type scope
for supply in "$SYS"/class/power_supply/*; do
[[ -r "$supply/type" ]] || continue
type="$(cat "$supply/type" 2>/dev/null)"
if [[ "$type" == "Battery" ]]; then
printf '%s\n' "$supply"
return 0
fi
[[ "$type" == "Battery" ]] || continue
scope="$(cat "$supply/scope" 2>/dev/null || echo System)"
[[ "$scope" == "Device" ]] && continue
printf '%s\n' "$supply"
return 0
done
return 1
}
has_battery() { battery_path >/dev/null; }
# On wall power. A machine with no mains supply at all is a desktop, and a
# desktop is always on wall power -- answering "no" there would make every
# battery-aware timing apply to a machine that cannot run out of power.
# On wall power. A machine with no mains supply at all and no system battery
# is a desktop, and a desktop is always on wall power -- answering "no" there
# would make every battery-aware timing apply to a machine that cannot run
# out of power. But "no Mains" alone is not "desktop": hardware charged only
# over USB-PD exposes type=USB supplies and no Mains at all, and reading that
# as permanently-on-AC meant its battery timings never engaged while it ran
# down. When no Mains exists but a system battery does, the battery's own
# status is the answer: Discharging means battery, everything else means fed.
on_ac() {
local supply type online found=1
local supply type online found=1 battery status
for supply in "$SYS"/class/power_supply/*; do
[[ -r "$supply/type" ]] || continue
type="$(cat "$supply/type" 2>/dev/null)"
@@ -70,16 +79,28 @@ on_ac() {
done
# Mains exists and none of it is online: genuinely on battery.
(( found == 0 )) && return 1
if battery="$(battery_path)"; then
status="$(cat "$battery/status" 2>/dev/null || echo Unknown)"
[[ "$status" == "Discharging" ]] && return 1
fi
return 0
}
# ACPI first, logind second. Some platforms expose the lid only as an evdev
# switch with no /proc/acpi/button entry; logind watches the switch either
# way, so its LidClosed property is the fallback that keeps clamshell
# detection honest there. No logind (a container, a test tree) means the
# fallback quietly answers open, which is the safe direction.
lid_closed() {
local state
for state in "$ACPI"/button/lid/*/state; do
[[ -r "$state" ]] || continue
grep -qi closed "$state" && return 0
return 1
done
return 1
[[ -d "$ACPI/button/lid" ]] && return 1
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
org.freedesktop.login1.Manager LidClosed 2>/dev/null | grep -q 'b true'
}
# A connected output that is not the built-in panel. eDP, LVDS and DSI are the