aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--sbpull.bash12
-rwxr-xr-xsbshadow22
3 files changed, 34 insertions, 10 deletions
diff --git a/README.md b/README.md
index ab7a7b1..075c5b6 100644
--- a/README.md
+++ b/README.md
@@ -22,9 +22,13 @@ upstream tree), so the overlay version wins.
carried in an overlay, and restores (unshadows) upstream packages no longer
carried, from the pristine `current` branch. Asks once before changing
anything, commits, then runs `mkhint -F` to regenerate phantom-dep hintfiles.
-- `sbpull.bash`: `sbpull {personal|pentesting}` shell function. Pulls one
- overlay subtree and runs `sbshadow`, to carry overlay changes without a full
- rebuild. Source it from root's `~/.bashrc`.
+ `--yes` applies without asking, `--no` only shows the plan (for
+ non-interactive callers such as sb-builder). `SBO_REPO` overrides the repo
+ path.
+- `sbpull.bash`: `sbpull {personal|pentesting} [--yes|--no]` shell function.
+ Pulls one overlay subtree and runs `sbshadow` (passing the flag on), to
+ carry overlay changes without a full rebuild. Source it from root's
+ `~/.bashrc`.
## Install
diff --git a/sbpull.bash b/sbpull.bash
index cd48864..a390e38 100644
--- a/sbpull.bash
+++ b/sbpull.bash
@@ -1,4 +1,5 @@
# sbpull: pull one overlay subtree into SBo-danix, then reconcile shadowing.
+# Usage: sbpull {personal|pentesting} [--yes|--no], the flag goes to sbshadow.
# Source from root's ~/.bashrc: . /path/to/sbpull.bash
#
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
@@ -9,7 +10,7 @@
sbpull() {
local repo_dir="/var/lib/sbopkg/SBo-danix"
- local target="$1"
+ local target="$1" flag="${2:-}"
local prefix branch remote
case "$target" in
@@ -22,7 +23,7 @@ sbpull() {
remote="my-pentesting"
;;
*)
- echo "sbpull: usage: sbpull {personal|pentesting}" >&2
+ echo "sbpull: usage: sbpull {personal|pentesting} [--yes|--no]" >&2
return 1
;;
esac
@@ -33,12 +34,13 @@ sbpull() {
if git subtree pull --prefix="$prefix" "$remote" "$branch" --squash; then
echo "sbpull: $target subtree updated."
- sbshadow
+ sbshadow ${flag:+"$flag"}
+ local rc=$?
+ popd > /dev/null
+ return "$rc"
else
echo "sbpull: git subtree pull failed for $target, check output above." >&2
popd > /dev/null
return 1
fi
-
- popd > /dev/null
}
diff --git a/sbshadow b/sbshadow
index b928df1..25cf923 100755
--- a/sbshadow
+++ b/sbshadow
@@ -13,10 +13,24 @@
# phantom-dep hintfiles with mkhint -F.
#
# Called by slackrepo_setup_SBo-danix.sh and by sbpull after a subtree pull.
+#
+# Usage: sbshadow [--yes|--no]
+# no flag show the plan and ask before changing anything
+# --yes apply the plan without asking
+# --no show the plan only, tree unchanged (preview)
+# SBO_REPO overrides the repo path (used to test against a throwaway repo).
set -euo pipefail
-REPO="/var/lib/sbopkg/SBo-danix"
+answer=""
+case "${1:-}" in
+ --yes) answer=y ;;
+ --no) answer=n ;;
+ "") ;;
+ *) echo "usage: sbshadow [--yes|--no]" >&2; exit 2 ;;
+esac
+
+REPO="${SBO_REPO:-/var/lib/sbopkg/SBo-danix}"
UPSTREAM="current"
cd "$REPO"
@@ -47,7 +61,11 @@ else
(( ${#to_restore[@]} )) && printf 'unshadow: %s\n' "${to_restore[@]}"
echo
- read -rp "Proceed? [y/N] " confirm
+ if [[ -n $answer ]]; then
+ confirm=$answer
+ else
+ read -rp "Proceed? [y/N] " confirm
+ fi
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "sbshadow: aborted, tree unchanged."
else