From 0287a4b0e256288c311bbfbc390de774d2f66d35 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 21 Apr 2026 01:23:28 +0100 Subject: feat: 'just undeclared' now considers only active (≥50%) groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A package only listed in unadopted groups (e.g. steam in gaming on a non-gaming machine) now counts as undeclared. Extracts a hidden _active-packages helper so pkg-drift and undeclared share the same 'active list' logic. --- justfile | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/justfile b/justfile index e6ddca9..3760d9a 100644 --- a/justfile +++ b/justfile @@ -50,20 +50,7 @@ status: pkg-drift dotfile-drift # Show package drift: missing packages in adopted groups + undeclared installed packages pkg-drift: #!/bin/sh - active_file=$(mktemp) - trap 'rm -f "$active_file"' EXIT - for file in meta/*.txt; do - pkgs=$(grep -v '^\s*#' "$file" | grep -v '^\s*$') - total=$(echo "$pkgs" | wc -l) - installed=0 - for pkg in $pkgs; do - pacman -Qi "$pkg" >/dev/null 2>&1 && installed=$((installed + 1)) - done - if [ $((installed * 2)) -ge "$total" ]; then - echo "$pkgs" >> "$active_file" - fi - done - active=$(sort -u "$active_file") + active=$(just _active-packages) echo "=== Package drift ===" echo "$active" | while read -r pkg; do [ -z "$pkg" ] && continue @@ -80,9 +67,9 @@ dotfile-drift: # Print undeclared packages one per line, unindented (pipe to 'paru -Rs -' to remove them) undeclared: #!/bin/sh - declared=$(cat meta/*.txt | grep -v '^\s*#' | grep -v '^\s*$' | sort -u) + active=$(just _active-packages) pacman -Qqe | while read -r pkg; do - echo "$declared" | grep -qxF "$pkg" || echo "$pkg" + echo "$active" | grep -qxF "$pkg" || echo "$pkg" done # Show dotfile diffs; pass a path to limit to a single file (e.g. just diff .config/nvim/init.lua) @@ -177,3 +164,18 @@ _chezmoi-init: _install-hooks: git config core.hooksPath .githooks + +# Print packages from groups that are ≥50% installed (adopted), one per line +_active-packages: + #!/bin/sh + for file in meta/*.txt; do + pkgs=$(grep -v '^\s*#' "$file" | grep -v '^\s*$') + total=$(echo "$pkgs" | wc -l) + installed=0 + for pkg in $pkgs; do + pacman -Qi "$pkg" >/dev/null 2>&1 && installed=$((installed + 1)) + done + if [ $((installed * 2)) -ge "$total" ]; then + echo "$pkgs" + fi + done | sort -u -- cgit v1.2.3-70-g09d2