mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 18:14:03 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
122 lines
3.5 KiB
Bash
Executable File
122 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Package-installation helpers for the fresh-install run.
|
|
#
|
|
# Sourced by main.sh, which owns the ordering of the top-level steps; this
|
|
# file defines functions only, so sourcing it has no side effects.
|
|
|
|
# Function to play a sound on error
|
|
play_error_sound() {
|
|
#pactl set-sink-volume @DEFAULT_SINK@ +50%
|
|
for _ in 1 2 3; do
|
|
paplay /usr/share/sounds/freedesktop/stereo/dialog-error.oga
|
|
done
|
|
#pactl set-sink-volume @DEFAULT_SINK@ -50%
|
|
}
|
|
|
|
install_from_aur() {
|
|
local repo_url pkg_name repo_dir
|
|
repo_url="$1"
|
|
pkg_name="$2"
|
|
|
|
mkdir -p "$HOME/aur"
|
|
cd "$HOME/aur" || return 1
|
|
repo_dir="$(basename "$repo_url" .git)"
|
|
|
|
if [ ! -d "$repo_dir" ]; then
|
|
git clone "$repo_url"
|
|
else
|
|
echo "Repository $repo_dir already cloned; updating"
|
|
(cd "$repo_dir" && git fetch --all -q && git reset --hard origin/HEAD -q || git pull --ff-only || true)
|
|
fi
|
|
cd "$repo_dir" || return 1
|
|
|
|
if pacman -Qi "$pkg_name" > /dev/null 2>&1; then
|
|
echo "$pkg_name is already installed"
|
|
return 0
|
|
fi
|
|
|
|
echo "Cleaning old package artifacts to avoid duplicate -U targets"
|
|
find . -maxdepth 1 -type f -name '*.pkg.tar.*' -delete 2> /dev/null || true
|
|
|
|
echo "Building $pkg_name (clean build)"
|
|
# -c (clean up work dirs after) -C (clean build - remove src/ and pkg/ first)
|
|
if ! yes | makepkg -s -c -C --noconfirm --nocheck --skipchecksums --skipinteg --skippgpcheck --needed; then
|
|
echo "Build failed for $pkg_name" >&2
|
|
return 1
|
|
fi
|
|
|
|
# Collect only the freshly built packages (should now be only current version)
|
|
mapfile -t built_pkgs < <(find . -maxdepth 1 -type f -name '*.pkg.tar.zst' -printf './%f\n')
|
|
if [ ${#built_pkgs[@]} -eq 0 ]; then
|
|
echo "No package files produced for $pkg_name" >&2
|
|
return 1
|
|
fi
|
|
|
|
echo "Installing built package(s): ${built_pkgs[*]}"
|
|
if ! yes | sudo pacman -U --noconfirm "${built_pkgs[@]}"; then
|
|
echo "Installation failed for $pkg_name" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Helper: try to install from AUR and log result to done.txt/failed.txt
|
|
try_aur_install() {
|
|
local repo_url="$1"
|
|
local pkg_name="$2"
|
|
if install_from_aur "$repo_url" "$pkg_name"; then
|
|
echo "$pkg_name" >> done.txt
|
|
else
|
|
echo "$pkg_name" >> failed.txt
|
|
fi
|
|
}
|
|
|
|
process_packages() {
|
|
local file_path
|
|
file_path="$1"
|
|
: > failed.txt
|
|
: > done.txt
|
|
|
|
while IFS= read -r pkg_name; do
|
|
if [ -z "$pkg_name" ]; then
|
|
continue
|
|
fi
|
|
|
|
local repo_url repo_dir
|
|
repo_url="https://aur.archlinux.org/${pkg_name}-git.git"
|
|
repo_dir="${pkg_name}-git"
|
|
|
|
git clone "$repo_url"
|
|
if [ -d "$repo_dir" ] && [ -z "$(ls -A "$repo_dir")" ]; then
|
|
echo "Repository $repo_dir is empty, trying without -git suffix"
|
|
repo_url="https://aur.archlinux.org/${pkg_name}.git"
|
|
repo_dir="${pkg_name}"
|
|
|
|
git clone "$repo_url"
|
|
if [ -d "$repo_dir" ] && [ -z "$(ls -A "$repo_dir")" ]; then
|
|
echo "Repository $repo_dir is empty, trying to install with pacman"
|
|
if sudo pacman -Sy --noconfirm "$pkg_name"; then
|
|
echo "$pkg_name" >> done.txt
|
|
else
|
|
echo "$pkg_name" >> failed.txt
|
|
fi
|
|
else
|
|
try_aur_install "$repo_url" "$pkg_name"
|
|
fi
|
|
else
|
|
try_aur_install "$repo_url" "$pkg_name"
|
|
fi
|
|
done < "$file_path"
|
|
}
|
|
|
|
# Helper: Check if all subpackages are installed
|
|
# Returns 0 if ALL subpackages are installed, 1 otherwise
|
|
all_subpackages_installed() {
|
|
local -n sub_pkgs_ref=$1
|
|
for subpkg in "${sub_pkgs_ref[@]}"; do
|
|
if ! pacman -Qi "$subpkg" &> /dev/null; then
|
|
return 1
|
|
fi
|
|
done
|
|
return 0
|
|
}
|