Compare commits

...

2 commits

Author SHA1 Message Date
31b7d6ea98 Fix typo
Some checks failed
sourcezap / shellcheck (push) Has been cancelled
2024-08-20 01:06:56 -03:00
2730af0092 Update bin/sourcezap 2024-08-20 00:57:30 -03:00

View file

@ -5,11 +5,11 @@ set -e
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
defaultbranch="hardened/14-stable/master"
gitdir="/home/_sourcezap/src" gitdir="/home/_sourcezap/src"
giturl="${SOURCEZAP_CLONEURL:-https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git}" giturl="${SOURCEZAP_CLONEURL:-https://git.hardenedbsd.org/hardenedbsd/hardenedbsd.git}"
installdir="${SOURCEZAP_INSTALLDIR:-/usr/src}" installdir="${SOURCEZAP_INSTALLDIR:-/usr/src}"
revision="${installdir}"/.sourcezap defaultbranch="hardenedbsd/main"
revfile="${installdir}"/.sourcezap
## ##
# functions # functions
@ -18,8 +18,10 @@ revision="${installdir}"/.sourcezap
require_dependency() require_dependency()
{ {
deps=$1 # shellcheck disable=SC3043
for dep in $deps; do local dep
for i in $(seq 1 ${#}); do
eval "dep=\$${i}"
if ! which -s "$dep"; then if ! which -s "$dep"; then
printerr "${dep} wasn't found on \$PATH" printerr "${dep} wasn't found on \$PATH"
exit 1 exit 1
@ -49,27 +51,27 @@ case $1 in
"${libexec}"/commands/sourcezap-teardown "${libexec}"/commands/sourcezap-teardown
;; ;;
"clone") "clone")
require_dependency "git doas" require_dependency git doas
"${libexec}"/commands/sourcezap-clone "${giturl}" "${gitdir}" "${defaultbranch}" "${libexec}"/commands/sourcezap-clone "${giturl}" "${gitdir}" "${defaultbranch}"
;; ;;
"pull") "pull")
require_dependency "git doas" require_dependency git doas
"${libexec}"/commands/sourcezap-pull "${gitdir}" "${libexec}"/commands/sourcezap-pull "${gitdir}"
;; ;;
"checkout") "checkout")
require_dependency "git doas" require_dependency git doas
"${libexec}"/commands/sourcezap-checkout "${gitdir}" "${2}" "${libexec}"/commands/sourcezap-checkout "${gitdir}" "${2}"
;; ;;
"sh") "sh")
require_dependency "doas" require_dependency doas
"${libexec}"/commands/sourcezap-sh "${gitdir}" "${libexec}"/commands/sourcezap-sh "${gitdir}"
;; ;;
"rm") "rm")
"${libexec}"/commands/sourcezap-rm "${gitdir}" "${installdir}" "${libexec}"/commands/sourcezap-rm "${gitdir}" "${installdir}"
;; ;;
"install") "install")
require_dependency "git doas" require_dependency git doas
"${libexec}"/commands/sourcezap-install "${gitdir}" "${installdir}" "${revision}" "${libexec}"/commands/sourcezap-install "${gitdir}" "${installdir}" "${revfile}"
;; ;;
*) *)
printf "Usage: sourcezap COMMAND [OPTIONS]\n" printf "Usage: sourcezap COMMAND [OPTIONS]\n"