0x1eef
3168b47a45
This commit reduces the number of doas.conf rules to 4. libexec/ scripts now query access permissions rather than bin/portzap doing it.
64 lines
1.7 KiB
Bash
Executable file
64 lines
1.7 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
##
|
|
# variables
|
|
localbase="${LOCALBASE:-/usr/local}"
|
|
gitdir="/home/_portzap/ports"
|
|
giturl="${PORTZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/ports.git}"
|
|
branch="${PORTZAP_BRANCH:-hardenedbsd/main}"
|
|
installdir="${PORTZAP_INSTALLDIR:-/usr/ports}"
|
|
revision="${installdir}"/.portzap
|
|
libexec="${localbase}"/libexec/portzap
|
|
|
|
##
|
|
# functions
|
|
require_dependency() {
|
|
deps=$1
|
|
for dep in $deps; do
|
|
if ! which -s "$dep"; then
|
|
echo "[-] This command requires ${dep}, but ${dep} wasn't found"
|
|
exit 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
##
|
|
# main
|
|
i=1
|
|
while [ "${i}" -le "$#" ]; do
|
|
eval "_portzap_option=\$${i}"
|
|
# shellcheck disable=SC2154
|
|
if [ "${_portzap_option}" = "-v" ]; then
|
|
cat "${localbase}"/share/portzap/VERSION
|
|
exit 0
|
|
fi
|
|
# shellcheck disable=SC2003
|
|
i=$(expr "${i}" + 1);
|
|
done
|
|
|
|
case $1 in
|
|
"clone")
|
|
require_dependency "git doas"
|
|
"${libexec}"/portzap-clone "${giturl}" "${gitdir}" "${branch}"
|
|
;;
|
|
"pull")
|
|
require_dependency "git doas"
|
|
"${libexec}"/portzap-pull "${gitdir}" "${branch}"
|
|
;;
|
|
"erase")
|
|
"${libexec}"/portzap-erase "${gitdir}" "${installdir}"
|
|
;;
|
|
"install")
|
|
require_dependency "git doas"
|
|
"${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}"
|
|
;;
|
|
*)
|
|
printf "Usage: portzap COMMAND [OPTIONS]\n"
|
|
printf "\n"
|
|
printf "Commands:\n"
|
|
printf " clone Clone the hardenedbsd ports tree.\n"
|
|
printf " pull Pull updates from the hardenedbsd ports tree.\n"
|
|
printf " erase Erase /usr/ports/ and /home/_portzap/ports/.\n"
|
|
printf " install Install the ports tree into /usr/ports/.\n"
|
|
;;
|
|
esac
|