Undo over-engineering (or try to anyway)
Some checks are pending
sourcezap / shellcheck (push) Waiting to run

This commit is contained in:
0x1eef 2024-09-10 00:24:19 -03:00
parent 892bce5773
commit 17d4e0f637
18 changed files with 47 additions and 30 deletions

View file

@ -5,7 +5,7 @@ set -e
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
repodir=$1 repodir=$1
branch=$2 branch=$2
@ -21,7 +21,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/utils/issourcezap-member; then if ! "${libexec}"/scripts/is-sourcezap-member; then
printerr "$(id -un) is not a member of _sourcezap" printerr "$(id -un) is not a member of _sourcezap"
exit 1 exit 1
fi fi

View file

@ -5,7 +5,7 @@ set -e
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
repourl=$1 repourl=$1
repodir=$2 repodir=$2
branch=$3 branch=$3
@ -22,7 +22,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/utils/issourcezap-member; then if ! "${libexec}"/scripts/is-sourcezap-member; then
printerr "$(id -un) is not a member of _sourcezap" printerr "$(id -un) is not a member of _sourcezap"
exit 1 exit 1
fi fi

View file

@ -5,8 +5,8 @@ set -e
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
mask=$("${libexec}"/utils/get-umask) mask=$("${libexec}"/scripts/get-default-umask)
repodir=$1 repodir=$1
installdir=$2 installdir=$2
commitfile=$3 commitfile=$3
@ -28,14 +28,14 @@ if [ -e "${commitfile}" ]; then
## ##
# install update # install update
commit=$(cat "${commitfile}") commit=$(cat "${commitfile}")
"${libexec}"/utils/install/run -d "${installdir}" "${libexec}"/scripts/install -d "${installdir}"
"${libexec}"/utils/install/update-deleted-files "${repodir}" "${installdir}" "${commit}" "${libexec}"/scripts/update-deleted-files "${repodir}" "${installdir}" "${commit}"
"${libexec}"/utils/install/update-changed-files "${repodir}" "${installdir}" "${commit}" "${libexec}"/scripts/update-changed-files "${repodir}" "${installdir}" "${commit}"
else else
## ##
# install from scratch # install from scratch
umask "${mask}" umask "${mask}"
"${libexec}"/utils/install/run -d "${installdir}" "${libexec}"/scripts/install -d "${installdir}"
find -s . \ find -s . \
-maxdepth 1 \ -maxdepth 1 \
! -name "." \ ! -name "." \

View file

@ -5,7 +5,7 @@ set -e
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
repodir=$1 repodir=$1
## ##
@ -20,7 +20,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/utils/issourcezap-member; then if ! "${libexec}"/scripts/is-sourcezap-member; then
printerr "$(id -un) is not a member of _sourcezap" printerr "$(id -un) is not a member of _sourcezap"
exit 1 exit 1
fi fi

View file

@ -14,8 +14,8 @@ libexec="${localbase}"/libexec/sourcezap
## ##
# main # main
if [ "$(id -u)" = "0" ]; then if [ "$(id -u)" = "0" ]; then
"${libexec}"/setup/setup-user "${libexec}"/scripts/setup-user
"${libexec}"/setup/setup-doas "${libexec}"/scripts/setup-doas
printok "setup complete" printok "setup complete"
else else
printerr "you must be root" printerr "you must be root"

View file

@ -20,7 +20,7 @@ if [ "$(id -u)" = "0" ]; then
exit 1 exit 1
fi fi
if ! "${libexec}"/utils/issourcezap-member; then if ! "${libexec}"/scripts/is-sourcezap-member; then
printerr "$(id -un) is not a member of _sourcezap" printerr "$(id -un) is not a member of _sourcezap"
exit 1 exit 1
fi fi

0
libexec/sourcezap/functions/print.sh Normal file → Executable file
View file

View file

@ -3,10 +3,10 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git=$(which git) git=$(which git)
mask=$("${libexec}"/utils/get-umask) mask=$("${libexec}"/scripts/get-default-umask)
## ##
# main # main

View file

@ -3,9 +3,9 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
repodir=$1 repodir=$1
commit=$2 commit=$2

View file

@ -3,9 +3,9 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
git="${libexec}"/utils/git/run git="${libexec}"/scripts/git
repodir=$1 repodir=$1
commit=$2 commit=$2

View file

@ -3,9 +3,9 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
mask=$("${libexec}"/utils/get-umask) mask=$("${libexec}"/scripts/get-default-umask)
## ##
# main # main

View file

@ -16,7 +16,8 @@ sharedir="${localbase}"/share/sourcezap
# main # main
src="${sharedir}"/doas.conf src="${sharedir}"/doas.conf
dest="${localbase}"/etc/doas.conf dest="${localbase}"/etc/doas.conf
while read -r line < "${src}"; do cat "${src}" |
while read -r line; do
if grep -q "${line}" "${dest}"; then if grep -q "${line}" "${dest}"; then
continue continue
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/sourcezap libexec="${localbase}"/libexec/sourcezap
repodir=$1 repodir=$1
installdir=$2 installdir=$2
@ -12,7 +12,7 @@ commit=$3
## ##
# main # main
cd "${repodir}" cd "${repodir}"
files=$("${libexec}"/utils/git/get-changed-files "${repodir}" "${commit}") files=$("${libexec}"/scripts/git-get-changed-files "${repodir}" "${commit}")
for file in ${files}; do for file in ${files}; do
target="${installdir}/${file}" target="${installdir}/${file}"
parent=$(dirname "${target}") parent=$(dirname "${target}")
@ -22,7 +22,7 @@ for file in ${files}; do
parent=$(dirname "${parent}") parent=$(dirname "${parent}")
done done
for dir in ${parents}; do for dir in ${parents}; do
"${libexec}"/utils/install/run -d "${dir}" "${libexec}"/scripts/install -d "${dir}"
done done
"${libexec}"/utils/install/run "${file}" "${target}" "${libexec}"/scripts/install "${file}" "${target}"
done done

View file

@ -3,7 +3,7 @@ set -e
## ##
# variables # variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap libexec="${localbase}"/libexec/sourcezap
repodir=$1 repodir=$1
installdir=$2 installdir=$2
@ -12,7 +12,7 @@ commit=$3
## ##
# main # main
cd "${repodir}" cd "${repodir}"
files=$("${libexec}"/utils/git/get-removed-files "${repodir}" "${commit}") files=$("${libexec}"/scripts/git/get-removed-files "${repodir}" "${commit}")
for file in ${files}; do for file in ${files}; do
target="${installdir}/${file}" target="${installdir}/${file}"
parent=$(dirname "${target}") parent=$(dirname "${target}")

View file

@ -1,5 +1,21 @@
# -*- mode: org -*- # -*- mode: org -*-
* vNEXT
**** Address ~libexec/sourcezap/scripts/setup-doas~ bug
This change addresses a bug in ~setup-doas~ that could hang
the ~sourcezap setup~ command
**** Collapse ~libexec/sourcezap/scripts~
This change does not try to organize script directories that
go beyond ~libexec/sourcezap/scripts~
**** Add ~libexec/sourcezap/scripts/setup~
This new directory replaces what was formerly known as ~libexec/sourcezap/setup~
**** Add ~libexec/sourcezap/scripts~
This new directory replaces what was formerly known as ~libexec/sourcezap/utils~
* v1.1.0 * v1.1.0
**** Add 'libexec/sourcezap/utils/get-umask' **** Add 'libexec/sourcezap/utils/get-umask'