#! /bin/bash # Copyright (C) 2026 Danilo M. # # 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. # 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="${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" || "$REPO" == / ]]; then echo "ERROR: REPO is unset, empty or /. Aborting." >&2 exit 1 fi # ── 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 "$NEW" git checkout current git checkout -b danix-current 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) ────────── # --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"