aboutsummaryrefslogtreecommitdiffstats
path: root/slackrepo_setup_SBo-danix.sh
blob: f54e9479a7151688f39965f331a155950f58f5e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /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.

# 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"