-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
pkgbootstrap.sh
executable file
·81 lines (64 loc) · 1.87 KB
/
pkgbootstrap.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2024 - The DanctNIX Contributors
if [ "$(id -u)" == 0 ]; then
echo "Do not run this script as root."
exit 1
fi
BASESCRIPT="$(realpath "$0")"
BASEPATH="$(dirname "$BASESCRIPT")"
_BUILDSCR_CHROOT_DIR="${_BUILDSCR_CHROOT_DIR:-/var/lib/danctnix-chroots}"
_BUILDSCR_LIB_DIR="$BASEPATH/lib"
_BUILDSCR_MISC_DIR="$BASEPATH/misc"
# shellcheck source=lib/mkpkg.bash
source "$_BUILDSCR_LIB_DIR/mkpkg.bash"
# shellcheck source=lib/repomgmt.bash
source "$_BUILDSCR_LIB_DIR/repomgmt.bash"
# shellcheck source=lib/loglevel.bash
source "$_BUILDSCR_LIB_DIR/loglevel.bash"
# shellcheck source=lib/chroot.bash
source "$_BUILDSCR_LIB_DIR/chroot.bash"
export REPODIR="${REPODIR:-$BASEPATH/repo}"
export SRCDEST="${SRCDEST:-$BASEPATH/sources}"
export SRCPKGDEST="${SRCPKGDEST:-$BASEPATH/sources/srcpkg}"
export LOGDEST="${LOGDEST:-$BASEPATH/logs}"
SUDO=
if ! SUDO=$(which sudo); then
pr_err "Can't find sudo. If you're using doas, there may be an alias package available."
exit 1
fi
if [ "$BASEPATH" != "$(pwd)" ]; then
pr_err "You must run this script inside it's own directory ($BASEPATH)."
exit 1
fi
build_script_usage() {
echo "Usage: $0 [COMMAND] [OPTIONS]
Command line tool for DanctNIX maintainers.
COMMANDS
build Build package in a clean chroot
chroot Manage chroot
repo Manipulate repository data
"
}
# Check if we're running Arch Linux or Arch Linux ARM.
#
# This should be removed in the future when we can figure out how
# to support non-Arch based distros.
OSREL_ID=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | tr -d '"')
if [[ ! "$OSREL_ID" =~ "arch" ]]; then
pr_warn "You're not running Arch Linux. This is not supported and you may encounter weird issues."
fi
case "$1" in
build)
pkg_build "${@:2}"
;;
chroot)
chrootcmd "${@:2}"
;;
repo)
repomgmt "${@:2}"
;;
*)
build_script_usage
;;
esac