aboutsummaryrefslogtreecommitdiffstats
path: root/sbshadow
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-25 20:44:38 +0200
committerDanilo M. <danix@danix.xyz>2026-09-25 20:44:38 +0200
commitc92bdd69fe19dca126469bb1c0bc3a598917af9d (patch)
treec1a9051bfa92b73a3068d857306d7ac00148577d /sbshadow
downloadslackrepo_setup-c92bdd69fe19dca126469bb1c0bc3a598917af9d.tar.gz
slackrepo_setup-c92bdd69fe19dca126469bb1c0bc3a598917af9d.zip
Initial import: SBo-danix repo setup, sbshadow, sbpull
slackrepo_setup_SBo-danix.sh rebuilds the personal SBo-danix repo from upstream plus the personal and pentesting subtree overlays. Shadowing is delegated to sbshadow, which reconciles both ways against the pristine current branch (shadow packages now carried in an overlay, restore those no longer carried) and then runs mkhint -F. sbpull.bash provides the sbpull shell function that pulls one overlay subtree and runs sbshadow. Licensed GPLv2 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'sbshadow')
-rwxr-xr-xsbshadow70
1 files changed, 70 insertions, 0 deletions
diff --git a/sbshadow b/sbshadow
new file mode 100755
index 0000000..b928df1
--- /dev/null
+++ b/sbshadow
@@ -0,0 +1,70 @@
+#! /bin/bash
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation. See the LICENSE file for details.
+
+# sbshadow: reconcile upstream shadowing against personal/ and pentesting/.
+#
+# Shadow: upstream package whose name matches a personal/pentesting package is
+# git rm'd. Unshadow: upstream package no longer carried there is restored from
+# the pristine $UPSTREAM branch that danix-current was cut from. Then regenerates
+# phantom-dep hintfiles with mkhint -F.
+#
+# Called by slackrepo_setup_SBo-danix.sh and by sbpull after a subtree pull.
+
+set -euo pipefail
+
+REPO="/var/lib/sbopkg/SBo-danix"
+UPSTREAM="current"
+
+cd "$REPO"
+
+# packages carried in the overlays
+declare -A mine=()
+for d in personal/*/ pentesting/*/; do
+ p=$(basename "$d")
+ [[ -f "$d$p.SlackBuild" ]] && mine[$p]=1
+done
+
+# category/pkg for every real package in pristine upstream
+to_rm=() to_restore=()
+while IFS= read -r path; do
+ if [[ -n "${mine[${path#*/}]:-}" ]]; then
+ [[ -d "$path" ]] && to_rm+=("$path")
+ else
+ [[ -d "$path" ]] || to_restore+=("$path")
+ fi
+done < <(git ls-tree -r --name-only "$UPSTREAM" \
+ | grep -E '^[^/]+/([^/]+)/\1\.SlackBuild$' | xargs -r -n1 dirname)
+
+if (( ${#to_rm[@]} + ${#to_restore[@]} == 0 )); then
+ echo "sbshadow: nothing to shadow or unshadow."
+else
+ echo
+ (( ${#to_rm[@]} )) && printf 'shadow: %s\n' "${to_rm[@]}"
+ (( ${#to_restore[@]} )) && printf 'unshadow: %s\n' "${to_restore[@]}"
+ echo
+
+ read -rp "Proceed? [y/N] " confirm
+ if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
+ echo "sbshadow: aborted, tree unchanged."
+ else
+ (( ${#to_rm[@]} )) && git rm -rq -- "${to_rm[@]}"
+ (( ${#to_restore[@]} )) && git checkout "$UPSTREAM" -- "${to_restore[@]}"
+ git commit -qm "shadow: reconcile upstream against personal/pentesting"
+ echo "sbshadow: shadowed ${#to_rm[@]}, unshadowed ${#to_restore[@]}."
+ fi
+fi
+
+# ── regenerate phantom-dep hintfiles (mkhint owns them) ───────────────────────
+# Always runs: a subtree pull can change REQUIRES even with nothing to shadow.
+# mkhint reads ~/.config/mkhint/phantom-deps; missing tool = harmless skip.
+if command -v mkhint >/dev/null 2>&1; then
+ echo
+ echo "Regenerating phantom-dep hintfiles (mkhint -F)..."
+ mkhint -F
+else
+ echo "NOTE: mkhint not found; skipping hintfile regen. Run 'mkhint -F' manually." >&2
+fi