Compare commits

...

3 commits

Author SHA1 Message Date
cd1e504643 Fix a few bugs
Some checks are pending
sourcezap / shellcheck (push) Waiting to run
2024-07-19 03:44:16 -03:00
f65748c533 Inline utils/printerr, utils/printok 2024-07-19 03:32:46 -03:00
19c465d6be Add functions.sh
Replace repetitive code
2024-07-19 03:32:46 -03:00
11 changed files with 29 additions and 106 deletions

View file

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

View file

@ -10,20 +10,7 @@ branch=$2
##
# functions
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
. "${libexec}"/functions.sh
##
# main
@ -42,9 +29,7 @@ if [ ! -e "${gitdir}/.git" ]; then
exit 1
fi
set -x
cd "${gitdir}"
git fetch origin
git checkout "${branch}" || git checkout -t origin/"${branch}"
set +x
printok "${branch} checked out"

View file

@ -11,20 +11,7 @@ branch=$3
##
# functions
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
. "${libexec}"/functions.sh
##
# main

View file

@ -12,6 +12,8 @@ revfile=$3
##
# functions
. "${libexec}"/functions.sh
perform_update()
{
rev=$(cat "${revfile}")
@ -63,21 +65,6 @@ run_install()
install -o root -g _sourcezap -m "${mode}" -v "$@"
}
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
##
# main
if [ "$(id -u)" != "0" ]; then
@ -85,16 +72,14 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
set -x
umask ${mode}
cd "${gitdir}"
run_install "-d" "${installdir}"
chmod ${mode} "${installdir}"
set +x
if [ -e "${revfile}" ]; then
perform_update
else
perform_install
fi
"${libexec}"/utils/git/run rev-parse HEAD > "${revfile}"
git rev-parse HEAD > "${revfile}"
printok "install complete"

View file

@ -9,20 +9,7 @@ gitdir=$1
##
# functions
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
. "${libexec}"/functions.sh
##
# main

View file

@ -10,6 +10,8 @@ installdir=$2
##
# functions
. "${libexec}"/functions.sh
erase()
{
dir="${1}"
@ -24,11 +26,6 @@ erase()
echo
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
##
# main
if [ "$(id -u)" != "0" ]; then

View file

@ -0,0 +1,16 @@
#!/bin/sh
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
printf "ok: %s\n" "${@}" > /dev/stdout
}
printerr()
{
printf "error: %s\n" "${@}" > /dev/stderr
}

View file

@ -3,17 +3,14 @@ set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
libexec="${localbase}"/libexec/sourcezap
gitdir=$1
commit=$2
##
# functions
git()
{
"${libexec}"/utils/git/run "${@}"
}
. "${libexec}"/functions.sh
##
# main

View file

@ -3,17 +3,14 @@ set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
libexec="${localbase}"/libexec/sourcezap
gitdir=$1
commit=$2
##
# functions
git()
{
"${libexec}"/utils/git/run "${@}"
}
. "${libexec}"/functions.sh
##
# main

View file

@ -1,10 +0,0 @@
#!/bin/sh
set -e
##
# variables
err="${1}"
##
# main
printf "error: %s\n" "${err}" > /dev/stderr

View file

@ -1,10 +0,0 @@
#!/bin/sh
set -e
##
# variables
msg="${1}"
##
# main
printf "ok: %s\n" "${msg}" > /dev/stdout