Add libexec/portzap/{commands,utils}/

This commit is contained in:
0x1eef 2024-05-22 23:52:41 -03:00
parent 2b9707e89f
commit 4d791170a1
13 changed files with 30 additions and 30 deletions

View file

@ -24,7 +24,7 @@ require_dependency() {
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##
@ -44,22 +44,22 @@ done
case $1 in case $1 in
"clone") "clone")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/portzap-clone "${giturl}" "${gitdir}" "${defaultbranch}" "${libexec}"/commands/portzap-clone "${giturl}" "${gitdir}" "${defaultbranch}"
;; ;;
"pull") "pull")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/portzap-pull "${gitdir}" "${libexec}"/commands/portzap-pull "${gitdir}"
;; ;;
"checkout") "checkout")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/portzap-checkout "${gitdir}" "${2}" "${libexec}"/commands/portzap-checkout "${gitdir}" "${2}"
;; ;;
"rm") "rm")
"${libexec}"/portzap-rm "${gitdir}" "${installdir}" "${libexec}"/commands/portzap-rm "${gitdir}" "${installdir}"
;; ;;
"install") "install")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}" "${libexec}"/commands/portzap-install "${gitdir}" "${installdir}" "${revision}"
;; ;;
*) *)
printf "Usage: portzap COMMAND [OPTIONS]\n" printf "Usage: portzap COMMAND [OPTIONS]\n"

View file

@ -11,11 +11,11 @@ doas="${localbase}"/etc/doas.conf
## ##
# functions # functions
printok() { printok() {
"${libexec}"/printok "$1" "${libexec}"/utils/printok "$1"
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap libexec="${localbase}"/libexec/portzap
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
@ -19,7 +19,7 @@ gitexec()
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##
@ -29,7 +29,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/isportzap-member > /dev/null 2>&1; then if ! "${libexec}"/utils/isportzap-member > /dev/null 2>&1; then
printerr "$(id -un) is not a member of _portzap" printerr "$(id -un) is not a member of _portzap"
exit 1 exit 1
fi fi

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap libexec="${localbase}"/libexec/portzap
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
@ -20,11 +20,11 @@ gitexec()
} }
printok() { printok() {
"${libexec}"/printok "$1" "${libexec}"/utils/printok "$1"
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##
@ -34,7 +34,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/isportzap-member > /dev/null 2>&1; then if ! "${libexec}"/utils/isportzap-member > /dev/null 2>&1; then
printerr "$(id -un) is not a member of _portzap" printerr "$(id -un) is not a member of _portzap"
exit 1 exit 1
fi fi

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap libexec="${localbase}"/libexec/portzap
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
gitdir=$1 gitdir=$1
@ -16,8 +16,8 @@ revfile=$3
perform_update() perform_update()
{ {
rev=$(cat "${revfile}") rev=$(cat "${revfile}")
add=$("${libexec}"/git-changed-files "${gitdir}" "${rev}") add=$("${libexec}"/utils/git-changed-files "${gitdir}" "${rev}")
del=$("${libexec}"/git-removed-files "${gitdir}" "${rev}") del=$("${libexec}"/utils/git-removed-files "${gitdir}" "${rev}")
for file in ${del}; do for file in ${del}; do
target="${installdir}/${file}" target="${installdir}/${file}"
parent=$(dirname "${target}") parent=$(dirname "${target}")
@ -60,11 +60,11 @@ run_install()
} }
printok() { printok() {
"${libexec}"/printok "$1" "${libexec}"/utils/printok "$1"
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##
@ -85,5 +85,5 @@ if [ -e "${revfile}" ]; then
else else
perform_install perform_install
fi fi
"${libexec}"/git-rev "${gitdir}" > "${revfile}" "${libexec}"/utils/git-rev "${gitdir}" > "${revfile}"
printok "install complete" printok "install complete"

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap libexec="${localbase}"/libexec/portzap
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
@ -18,11 +18,11 @@ gitexec()
} }
printok() { printok() {
"${libexec}"/printok "$1" "${libexec}"/utils/printok "$1"
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##
@ -32,7 +32,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/isportzap-member > /dev/null 2>&1; then if ! "${libexec}"/utils/isportzap-member > /dev/null 2>&1; then
printerr "$(id -un) is not a member of _portzap" printerr "$(id -un) is not a member of _portzap"
exit 1 exit 1
fi fi

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap libexec="${localbase}"/libexec/portzap
gitdir=$1 gitdir=$1
installdir=$2 installdir=$2
@ -25,7 +25,7 @@ erase()
} }
printerr() { printerr() {
"${libexec}"/printerr "$1" "${libexec}"/utils/printerr "$1"
} }
## ##

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
gitdir=$1 gitdir=$1

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
gitdir=$1 gitdir=$1

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
git=$(which git) git=$(which git)
mode=u=rwX,g=rX,o= mode=u=rwX,g=rX,o=
gitdir=$1 gitdir=$1