diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-21 10:32:12 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-21 10:32:12 +0200 |
| commit | b3c5d50c293b16ab1ce6e8ba25fedbfcdb493daf (patch) | |
| tree | c27dbb94232aed3d36c2042c92e97c2e3de2af41 /slackrepo_setup_SBo-danix.sh | |
| parent | f2293db643a726631b2a054bd5c76e367bb2567f (diff) | |
| download | slackrepo_setup-b3c5d50c293b16ab1ce6e8ba25fedbfcdb493daf.tar.gz slackrepo_setup-b3c5d50c293b16ab1ce6e8ba25fedbfcdb493daf.zip | |
A failed clone no longer leaves the VM without a tree: the new tree is
built in $REPO.new and swapped in only when clone and subtree adds
succeed. sbshadow runs with --yes, since sb-builder runs this script as
a job with no stdin and the bare prompt would read EOF as "no". The old
tree is deleted once shadowing succeeds and kept as $REPO.old if it
fails. SBO_REPO overrides the path, as in sbshadow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'slackrepo_setup_SBo-danix.sh')
| -rw-r--r-- | slackrepo_setup_SBo-danix.sh | 47 |
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" |
