aboutsummaryrefslogtreecommitdiffstats
path: root/slackrepo_setup_SBo-danix.sh
diff options
context:
space:
mode:
Diffstat (limited to 'slackrepo_setup_SBo-danix.sh')
-rw-r--r--slackrepo_setup_SBo-danix.sh47
1 files changed, 28 insertions, 19 deletions
diff --git a/slackrepo_setup_SBo-danix.sh b/slackrepo_setup_SBo-danix.sh
index be2b1dd..f54e947 100644
--- a/slackrepo_setup_SBo-danix.sh
+++ b/slackrepo_setup_SBo-danix.sh
@@ -5,45 +5,54 @@
# under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation. See the LICENSE file for details.
+# Rebuild the SBo-danix tree: fresh clone of upstream plus the personal and
+# pentesting subtrees, built beside the live tree and swapped in, then shadowed.
+# Run by sb-builder as the rebuild-tree job (no stdin).
+# SBO_REPO overrides the repo path (used to test against a throwaway repo).
set -euo pipefail
-REPO="/var/lib/sbopkg/SBo-danix"
+REPO="${SBO_REPO:-/var/lib/sbopkg/SBo-danix}"
+NEW="$REPO.new"
+OLD="$REPO.old"
+export SBO_REPO="$REPO" # sbshadow reads the same override
# ── safety guard ──────────────────────────────────────────────────────────────
-if [[ -z "$REPO" ]]; then
- echo "ERROR: REPO is unset or empty. Aborting." >&2
+if [[ -z "$REPO" || "$REPO" == / ]]; then
+ echo "ERROR: REPO is unset, empty or /. Aborting." >&2
exit 1
fi
-# ── clean slate ───────────────────────────────────────────────────────────────
-if [[ -d "$REPO" ]]; then
- echo "Removing existing repo at $REPO..."
- rm -rf "$REPO"
-fi
-
-# ── clone and branch ──────────────────────────────────────────────────────────
-echo "Cloning upstream SBo repository..."
-git clone https://github.com/Ponce/slackbuilds.git "$REPO" || {
- echo "ERROR: git clone failed. Aborting." >&2
- exit 1
-}
+# ── build the new tree beside the live one ────────────────────────────────────
+# A failure here leaves $REPO untouched.
+rm -rf "$NEW"
+echo "Cloning upstream SBo repository into $NEW..."
+git clone https://github.com/Ponce/slackbuilds.git "$NEW"
-cd "$REPO"
+cd "$NEW"
git checkout current
git checkout -b danix-current
-# ── add subtrees ──────────────────────────────────────────────────────────────
echo "Adding personal subtrees..."
git remote add my-slackbuilds https://github.com/danixland/my-slackbuilds.git
git remote add my-pentesting https://github.com/danixland/Slackware-Pentesting-Suite.git
git subtree add --prefix=personal my-slackbuilds main --squash
git subtree add --prefix=pentesting my-pentesting main --squash
+cd /
+
+# ── swap ──────────────────────────────────────────────────────────────────────
+rm -rf "$OLD"
+if [[ -d "$REPO" ]]; then
+ mv "$REPO" "$OLD"
+fi
+mv "$NEW" "$REPO"
# ── shadow upstream packages + regen hintfiles (sbshadow owns both) ──────────
-# sbshadow must be on PATH (deployed next to this script on the build system).
-sbshadow
+# --yes: as a job stdin is /dev/null, so a prompt would read "no".
+# If it fails, set -e keeps $OLD for a manual rollback (mv it back).
+sbshadow --yes
+rm -rf "$OLD"
echo
echo "Done. Repository ready at $REPO"