Compare commits
5 commits
245fe9957a
...
1b1bab8a1c
Author | SHA1 | Date | |
---|---|---|---|
1b1bab8a1c | |||
|
3c994da3cb | ||
bc0553aabd | |||
d2f900f440 | |||
2c13017d7b |
9 changed files with 103 additions and 64 deletions
|
@ -35,4 +35,4 @@ cd "${gitdir}"
|
||||||
"${git}" fetch origin
|
"${git}" fetch origin
|
||||||
"${git}" checkout "${branch}" ||
|
"${git}" checkout "${branch}" ||
|
||||||
"${git}" checkout -t origin/"${branch}"
|
"${git}" checkout -t origin/"${branch}"
|
||||||
printok "${branch} checked out"
|
printok "checkout complete"
|
||||||
|
|
|
@ -5,7 +5,6 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
mode=u=rwX,g=rX,o=
|
|
||||||
git="${libexec}"/utils/git/run
|
git="${libexec}"/utils/git/run
|
||||||
gitdir=$1
|
gitdir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
|
@ -16,35 +15,26 @@ revfile=$3
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "${libexec}"/functions/print.sh
|
. "${libexec}"/functions/print.sh
|
||||||
|
|
||||||
perform_update()
|
##
|
||||||
{
|
# main
|
||||||
rev=$(cat "${revfile}")
|
if [ "$(id -u)" != "0" ]; then
|
||||||
add=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}")
|
printerr "you must be root"
|
||||||
del=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}")
|
exit 1
|
||||||
for file in ${del}; do
|
fi
|
||||||
target="${installdir}/${file}"
|
|
||||||
parent=$(dirname "${target}")
|
|
||||||
echo "rm ${target}"
|
|
||||||
rm -f "${target}"
|
|
||||||
find "${parent}" -type d -maxdepth 0 -empty -delete
|
|
||||||
done
|
|
||||||
for file in ${add}; do
|
|
||||||
target="${installdir}/${file}"
|
|
||||||
parent=$(dirname "${target}")
|
|
||||||
parents=""
|
|
||||||
while [ ! -e "${parent}" ]; do
|
|
||||||
parents="${parent} ${parents}"
|
|
||||||
parent=$(dirname "${parent}")
|
|
||||||
done
|
|
||||||
for dir in ${parents}; do
|
|
||||||
run_install "-d" "${dir}"
|
|
||||||
done
|
|
||||||
run_install "${file}" "${target}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
perform_install()
|
cd "${gitdir}"
|
||||||
{
|
if [ -e "${revfile}" ]; then
|
||||||
|
##
|
||||||
|
# install update
|
||||||
|
rev=$(cat "${revfile}")
|
||||||
|
"${libexec}"/utils/install/run -d "${installdir}"
|
||||||
|
"${libexec}"/utils/install/update-deleted-files "${gitdir}" "${installdir}" "${rev}"
|
||||||
|
"${libexec}"/utils/install/update-changed-files "${gitdir}" "${installdir}" "${rev}"
|
||||||
|
else
|
||||||
|
##
|
||||||
|
# install from scratch
|
||||||
|
umask u=rwX,g=rX,o=
|
||||||
|
"${libexec}"/utils/install/run -d "${installdir}"
|
||||||
find -s . \
|
find -s . \
|
||||||
-maxdepth 1 \
|
-maxdepth 1 \
|
||||||
! -name "." \
|
! -name "." \
|
||||||
|
@ -60,28 +50,6 @@ perform_install()
|
||||||
! -name ".arcconfig" \
|
! -name ".arcconfig" \
|
||||||
-exec cp -Rpv {} "${installdir}" \;
|
-exec cp -Rpv {} "${installdir}" \;
|
||||||
chown -Rv root "${installdir}"
|
chown -Rv root "${installdir}"
|
||||||
}
|
|
||||||
|
|
||||||
run_install()
|
|
||||||
{
|
|
||||||
install -o root -g _sourcezap -m "${mode}" -v "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
# main
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
|
||||||
printerr "you must be root"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
umask "${mode}"
|
|
||||||
cd "${gitdir}"
|
|
||||||
run_install "-d" "${installdir}"
|
|
||||||
chmod ${mode} "${installdir}"
|
|
||||||
if [ -e "${revfile}" ]; then
|
|
||||||
perform_update
|
|
||||||
else
|
|
||||||
perform_install
|
|
||||||
fi
|
fi
|
||||||
"${git}" rev-parse HEAD > "${revfile}"
|
"${git}" rev-parse HEAD > "${revfile}"
|
||||||
printok "install complete"
|
printok "install complete"
|
||||||
|
|
|
@ -15,6 +15,8 @@ installdir=$2
|
||||||
|
|
||||||
erase()
|
erase()
|
||||||
{
|
{
|
||||||
|
# shellcheck disable=SC3043
|
||||||
|
local dir
|
||||||
dir="${1}"
|
dir="${1}"
|
||||||
printf "%s " "${dir}"
|
printf "%s " "${dir}"
|
||||||
find "${dir}" \
|
find "${dir}" \
|
||||||
|
|
|
@ -16,6 +16,7 @@ libexec="${localbase}"/libexec/sourcezap
|
||||||
if [ "$(id -u)" = "0" ]; then
|
if [ "$(id -u)" = "0" ]; then
|
||||||
"${libexec}"/setup/setup-user
|
"${libexec}"/setup/setup-user
|
||||||
"${libexec}"/setup/setup-doas
|
"${libexec}"/setup/setup-doas
|
||||||
|
printok "setup complete"
|
||||||
else
|
else
|
||||||
printerr "you must be root"
|
printerr "you must be root"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -15,10 +15,10 @@ user=_sourcezap
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
if [ "$(id -u)" = "0" ]; then
|
if [ "$(id -u)" = "0" ]; then
|
||||||
pw userdel -n "${user}" || true
|
pw userdel -n "${user}" > /dev/null 2>&1 || true
|
||||||
pw groupdel -n "${user}" || true
|
pw groupdel -n "${user}" > /dev/null 2>&1 || true
|
||||||
rm -rf /home/"${user:?}"/ || true
|
rm -rf /home/"${user:?}"/ > /dev/null 2>&1 || true
|
||||||
printok "done"
|
printok "teardown complete"
|
||||||
else
|
else
|
||||||
printerr "you must be root"
|
printerr "you must be root"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
14
libexec/sourcezap/utils/install/run
Executable file
14
libexec/sourcezap/utils/install/run
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
##
|
||||||
|
# variables
|
||||||
|
mode=u=rwX,g=rX,o=
|
||||||
|
|
||||||
|
##
|
||||||
|
# main
|
||||||
|
install -o root \
|
||||||
|
-g _sourcezap \
|
||||||
|
-m "${mode}" \
|
||||||
|
-v \
|
||||||
|
"${@}"
|
28
libexec/sourcezap/utils/install/update-changed-files
Executable file
28
libexec/sourcezap/utils/install/update-changed-files
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
##
|
||||||
|
# variables
|
||||||
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
||||||
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
|
gitdir=$1
|
||||||
|
installdir=$2
|
||||||
|
rev=$3
|
||||||
|
|
||||||
|
##
|
||||||
|
# main
|
||||||
|
cd "${gitdir}"
|
||||||
|
files=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}")
|
||||||
|
for file in ${files}; do
|
||||||
|
target="${installdir}/${file}"
|
||||||
|
parent=$(dirname "${target}")
|
||||||
|
parents=""
|
||||||
|
while [ ! -e "${parent}" ]; do
|
||||||
|
parents="${parent} ${parents}"
|
||||||
|
parent=$(dirname "${parent}")
|
||||||
|
done
|
||||||
|
for dir in ${parents}; do
|
||||||
|
"${libexec}"/utils/install/run -d "${dir}"
|
||||||
|
done
|
||||||
|
"${libexec}"/utils/install/run "${file}" "${target}"
|
||||||
|
done
|
22
libexec/sourcezap/utils/install/update-deleted-files
Executable file
22
libexec/sourcezap/utils/install/update-deleted-files
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
##
|
||||||
|
# variables
|
||||||
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
||||||
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
|
gitdir=$1
|
||||||
|
installdir=$2
|
||||||
|
rev=$3
|
||||||
|
|
||||||
|
##
|
||||||
|
# main
|
||||||
|
cd "${gitdir}"
|
||||||
|
files=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}")
|
||||||
|
for file in ${files}; do
|
||||||
|
target="${installdir}/${file}"
|
||||||
|
parent=$(dirname "${target}")
|
||||||
|
echo "rm ${target}"
|
||||||
|
rm -f "${target}"
|
||||||
|
find "${parent}" -type d -maxdepth 0 -empty -delete
|
||||||
|
done
|
|
@ -1,13 +1,17 @@
|
||||||
* vNEXT
|
* vNEXT
|
||||||
|
|
||||||
|
** Break up 'sourcezap-install' into multiple files
|
||||||
|
'libexec/sourcezap/utils/install/' contains files that cover both
|
||||||
|
a fresh install and applying an update
|
||||||
|
|
||||||
** Add 'setup/setup-doas' improvements
|
** Add 'setup/setup-doas' improvements
|
||||||
More likely to do what's expected, but blind spots still exist
|
More likely to do what's expected, but blind spots still exist
|
||||||
|
|
||||||
** Add 'sourcezap setup', 'sourcezap teardown'
|
** Add 'sourcezap setup', 'sourcezap teardown'
|
||||||
Replaces and enhances 'setup-sourcezap'
|
Replaces and enhances 'setup-sourcezap'
|
||||||
|
|
||||||
** Add libexec/sourcezap/commands/sourcezap-sh
|
** Add 'libexec/sourcezap/commands/sourcezap-sh'
|
||||||
Runs /bin/sh within /home/_sourcezap/src/ as the '_sourcezap' user
|
Runs '/bin/sh' within '/home/_sourcezap/src/' as the '_sourcezap' user
|
||||||
|
|
||||||
* v1.0.0
|
* v1.0.0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue