aboutsummaryrefslogtreecommitdiffstats
path: root/sbpull.bash
blob: cd488640bbbac7ea5f0540d62b7ce6dba85648ce (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
# sbpull: pull one overlay subtree into SBo-danix, then reconcile shadowing.
# Source from root's ~/.bashrc:  . /path/to/sbpull.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.

sbpull() {
    local repo_dir="/var/lib/sbopkg/SBo-danix"
    local target="$1"
    local prefix branch remote

    case "$target" in
        personal)
            prefix="personal"
            remote="my-slackbuilds"
            ;;
        pentesting)
            prefix="pentesting"
            remote="my-pentesting"
            ;;
        *)
            echo "sbpull: usage: sbpull {personal|pentesting}" >&2
            return 1
            ;;
    esac

    branch="main"

    pushd "$repo_dir" > /dev/null || return 1

    if git subtree pull --prefix="$prefix" "$remote" "$branch" --squash; then
        echo "sbpull: $target subtree updated."
        sbshadow
    else
        echo "sbpull: git subtree pull failed for $target, check output above." >&2
        popd > /dev/null
        return 1
    fi

    popd > /dev/null
}