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
2 changes: 1 addition & 1 deletion .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: ShellCheck
run: |
shellcheck -x install-scripts/*.sh install-scripts/lib/*.sh config/sets/basic/tmux/scripts/*.sh scripts/*
shellcheck -x install-scripts/*.sh install-scripts/lib/*.sh config/sets/*/apply.sh config/sets/basic/tmux/scripts/*.sh scripts/*

- name: Fish syntax check
run: |
Expand Down
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ config/
gitignore # Linked to ~/.config/git/ignore
identity # Copied to ~/.config/git/identity, per-machine
apply.sh
kde/ # KDE Plasma keyboard repeat settings
gentoo/ # The gentoo-kernel-upgrade helper
description
manifest
os # "Linux" — hidden from `make picky` elsewhere
apply.sh
gnome/ # GNOME settings (`gsettings`)
description
manifest
os # "Linux" — hidden from `make picky` elsewhere
apply.sh
kde/ # KDE Plasma settings (`kwriteconfig5`/`6`)
description
manifest
os # "Linux" — hidden from `make picky` elsewhere
Expand Down Expand Up @@ -102,8 +112,22 @@ Config files are grouped into **sets** under `config/sets/<name>/`:
`~/.config/git/local` file rather than `git config --global`, since with
no `~/.gitconfig` yet that resolves to the tracked `~/.config/git/config`
symlink
- **`kde`** — sets the KDE Plasma keyboard repeat rate to 50/s with a 250ms
delay (via `kwriteconfig5`/`6` on `kcminputrc`)
- **`gentoo`** — installs `scripts/gentoo-kernel-upgrade` into `/usr/bin`: a
guided, confirm-every-step walkthrough of a `gentoo-kernel-bin` upgrade
(emerge, `eselect kernel`, back up the EFI boot files, regenerate the
initramfs, copy the new image across), plus a cleanup pass over superseded
kernels in `/boot`. It works out on its own whether this system's kernel
images are named `vmlinuz-<version>` or `kernel-<version>`; set
`KERNEL_PREFIX` to override that
- **`gnome`** — the GNOME settings that differ from stock, applied via
`gsettings`: keyboard repeat rate 50/s with a 250ms delay, Caps Lock as
Escape, screen locking and idle display dim/off disabled, device
automounting disabled, an editable path bar in GTK file dialogs, and a
dark color scheme
- **`kde`** — the KDE Plasma equivalents, applied via `kwriteconfig5`/`6`:
the same keyboard repeat rate and Caps Lock as Escape, screen locking and
idle display dim/off disabled, the device automounter disabled, Dolphin's
menu bar hidden with an editable path bar, and the Breeze Dark theme
- **`macos`** — the macOS system settings that differ from stock, applied via
`defaults write`: fastest keyboard repeat rate with the shortest delay, all
automatic text substitution off, text replacements, the input-source and
Expand All @@ -125,11 +149,17 @@ Config files are grouped into **sets** under `config/sets/<name>/`:
configures **Kitty** as the default terminal

Each set is independent and additive — enabling `kde` or `macos` doesn't
disturb `basic`. `kde`, `macos` and `xfce` each declare an `os` file
restricting them to their platform, so `make picky` only offers `kde` and
`xfce` on Linux and `macos` on macOS in the first place; if one somehow ends
up enabled on the wrong OS anyway (e.g. a shared `sets.conf`), it's skipped
with a warning at deploy time instead of failing.
disturb `basic`. Every set except `basic` and `git` declares an `os` file
restricting it to its platform, so `make picky` only offers `gentoo`,
`gnome`, `kde` and `xfce` on Linux and `macos` on macOS in the first place;
if one somehow ends up enabled on the wrong OS anyway (e.g. a shared
`sets.conf`), it's skipped with a warning at deploy time instead of failing.

An `os` file is only as specific as `uname -s`, so the Linux sets are offered
on *every* Linux. Each one checks for what it actually needs at deploy time —
`gsettings`, `kwriteconfig`, `xfconf-query`, `/etc/gentoo-release` — and
warns and exits 0 if it isn't there, so picking `gentoo` on Debian is
harmless rather than fatal.

A bare `make` (or `make picky`, the same target by name) gives you an
interactive checklist (space to toggle, enter to confirm) of every set found
Expand Down Expand Up @@ -290,7 +320,6 @@ Completes the setup:
- Adds Fish to `/etc/shells`
- Changes the default shell to Fish
- Creates `~/bin` for personal scripts
- On Gentoo, installs the appropriate kernel-upgrade helper (OpenRC or systemd)
- On Arch, enables the cron daemon and installs an hourly `sudo pacman -Syy`
cron job for the current user; if that user isn't root, grants them
passwordless sudo (`/etc/sudoers.d/99-<user>-nopasswd`) so the unattended
Expand Down
24 changes: 24 additions & 0 deletions config/sets/gentoo/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail

# Installs the Gentoo kernel upgrade helper (scripts/gentoo-kernel-upgrade)
# into /usr/bin, mirroring config/sets/xfce/apply.sh's install_kitty.
#
# This used to live in install-scripts/07-last-touches.sh, where it ran on
# every Gentoo install and had to stop and ask which init system was in use
# — which blocked unattended installs. The helper works its own kernel
# naming out at runtime now, so this is a plain copy, and it's opt-in via
# `make picky` rather than automatic.

if [ ! -f /etc/gentoo-release ]; then
echo "Warning: /etc/gentoo-release not found (not a Gentoo system?); skipping Gentoo settings." >&2
exit 0
fi

REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"

# install(1) rather than cp so the mode is set explicitly, and so an
# already-running copy of the script isn't rewritten underneath itself.
sudo install -m 755 "$REPO/scripts/gentoo-kernel-upgrade" /usr/bin/gentoo-kernel-upgrade

echo "Installed /usr/bin/gentoo-kernel-upgrade"
4 changes: 4 additions & 0 deletions config/sets/gentoo/description
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Gentoo: the gentoo-kernel-upgrade helper installed to /usr/bin — a guided,
confirm-every-step walkthrough of a gentoo-kernel-bin upgrade (emerge, eselect
kernel, back up the EFI boot files, regenerate the initramfs, copy the new
image across) plus cleanup of superseded kernels in /boot
3 changes: 3 additions & 0 deletions config/sets/gentoo/manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See config/sets/basic/manifest for the full manifest format reference.

run apply.sh
1 change: 1 addition & 0 deletions config/sets/gentoo/os
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Linux
16 changes: 2 additions & 14 deletions install-scripts/07-last-touches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,8 @@ fi
# create local bin directory
mkdir -p ~/bin

# Gentoo specific kernel script
if [ -f /etc/gentoo-release ]; then
init_system=openrc
echo "Gentoo detected, need clarification on which init system is used."
echo -e "Which init system?\n\n1> openrc\n2> systemd"
read -p "[1]/2: " -n 1;
echo
if [ "$REPLY" == "2" ]; then
init_system=systemd
fi

sudo cp scripts/gentoo-kernel-upgrade-$init_system /usr/bin/gentoo-kernel-upgrade

fi
# (The Gentoo kernel-upgrade helper used to be installed here, unconditionally
# on every Gentoo box. It's an opt-in config set now — config/sets/gentoo/.)

# Arch specific: keep the local package database fresh via an hourly cron job
if [ -f /etc/arch-release ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ NC='\033[0m' # No Color
EFI_DIR="/boot/efi"
BOOT_DIR="/boot"

# Gentoo's installkernel names the kernel image in /boot differently
# depending on the layout it was configured for: the traditional one uses
# vmlinuz-<version>, the systemd/UAPI one uses kernel-<version>. That naming
# was the *only* difference between the two copies of this script this file
# replaces, so it's detected at runtime instead. Set KERNEL_PREFIX to
# override.
KERNEL_PREFIX="${KERNEL_PREFIX:-}"

# Print functions
info() { echo -e "${BLUE}==>${NC} ${BOLD}$1${NC}"; }
warn() { echo -e "${YELLOW}WARNING:${NC} $1"; }
Expand Down Expand Up @@ -48,6 +56,44 @@ get_current_version() {
uname -r
}

# Work out whether this system's kernel images are named vmlinuz-<version>
# or kernel-<version>, and set KERNEL_PREFIX accordingly.
detect_kernel_prefix() {
# An explicit KERNEL_PREFIX from the environment always wins.
if [[ -n "$KERNEL_PREFIX" ]]; then
return 0
fi

local running prefix
running=$(get_current_version)

# Strongest signal: whichever name the *running* kernel is installed
# under, since that's the one this system's installkernel actually used.
for prefix in vmlinuz kernel; do
if [[ -f "${BOOT_DIR}/${prefix}-${running}" ]]; then
KERNEL_PREFIX="$prefix"
return 0
fi
done

# Next best: whichever name anything else in /boot uses (the running
# kernel may already have been cleaned up, or /boot only just mounted).
for prefix in vmlinuz kernel; do
if ls "${BOOT_DIR}/${prefix}"-* >/dev/null 2>&1; then
KERNEL_PREFIX="$prefix"
return 0
fi
done

# Nothing in /boot to go on. Fall back to the init system, which is what
# the layout was chosen for in the first place.
if [[ -d /run/systemd/system ]]; then
KERNEL_PREFIX="kernel"
else
KERNEL_PREFIX="vmlinuz"
fi
}

# Get the latest installed kernel version from /usr/src
get_latest_installed_version() {
local latest
Expand Down Expand Up @@ -185,7 +231,7 @@ generate_initramfs() {
# Copy new kernel to EFI partition
copy_kernel() {
local version="$1"
local kernel_source="${BOOT_DIR}/vmlinuz-${version}"
local kernel_source="${BOOT_DIR}/${KERNEL_PREFIX}-${version}"

info "Copying new kernel to EFI partition..."
echo
Expand Down Expand Up @@ -219,15 +265,13 @@ cleanup_old_versions() {
local initramfs_to_delete=()
local kernels_to_delete=()



while IFS= read -r f; do
initramfs_to_delete+=("$f")
done < <(ls ${BOOT_DIR}/initramfs-*.img 2>/dev/null | grep -v "$current_version" || true)

while IFS= read -r f; do
kernels_to_delete+=("$f")
done < <(ls ${BOOT_DIR}/vmlinuz-* 2>/dev/null | grep -v "$current_version" || true)
done < <(ls ${BOOT_DIR}/"${KERNEL_PREFIX}"-* 2>/dev/null | grep -v "$current_version" || true)

# Check if there's anything to delete
if [[ ${#initramfs_to_delete[@]} -eq 0 ]] && [[ ${#kernels_to_delete[@]} -eq 0 ]]; then
Expand Down Expand Up @@ -298,6 +342,9 @@ main() {
local current_version
current_version=$(get_current_version)
info "Currently running kernel: ${current_version}"

detect_kernel_prefix
info "Kernel images in ${BOOT_DIR} are named: ${KERNEL_PREFIX}-<version>"
echo

# Check for updates
Expand Down
Loading
Loading