Compare commits
4 commits
31b7d6ea98
...
892bce5773
Author | SHA1 | Date | |
---|---|---|---|
892bce5773 | |||
f7ac2e8697 | |||
b470001647 | |||
c6266e01df |
13 changed files with 65 additions and 63 deletions
|
@ -5,11 +5,11 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
gitdir="/home/_sourcezap/src"
|
repodir="/home/_sourcezap/src"
|
||||||
giturl="${SOURCEZAP_CLONEURL:-https://git.hardenedbsd.org/hardenedbsd/hardenedbsd.git}"
|
repourl="${SOURCEZAP_CLONEURL:-https://git.hardenedbsd.org/hardenedbsd/hardenedbsd.git}"
|
||||||
installdir="${SOURCEZAP_INSTALLDIR:-/usr/src}"
|
installdir="${SOURCEZAP_INSTALLDIR:-/usr/src}"
|
||||||
defaultbranch="hardenedbsd/main"
|
defaultbranch="hardenedbsd/main"
|
||||||
revfile="${installdir}"/.sourcezap
|
commitfile="${installdir}"/.sourcezap
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
|
@ -52,26 +52,26 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
"clone")
|
"clone")
|
||||||
require_dependency git doas
|
require_dependency git doas
|
||||||
"${libexec}"/commands/sourcezap-clone "${giturl}" "${gitdir}" "${defaultbranch}"
|
"${libexec}"/commands/sourcezap-clone "${repourl}" "${repodir}" "${defaultbranch}"
|
||||||
;;
|
;;
|
||||||
"pull")
|
"pull")
|
||||||
require_dependency git doas
|
require_dependency git doas
|
||||||
"${libexec}"/commands/sourcezap-pull "${gitdir}"
|
"${libexec}"/commands/sourcezap-pull "${repodir}"
|
||||||
;;
|
;;
|
||||||
"checkout")
|
"checkout")
|
||||||
require_dependency git doas
|
require_dependency git doas
|
||||||
"${libexec}"/commands/sourcezap-checkout "${gitdir}" "${2}"
|
"${libexec}"/commands/sourcezap-checkout "${repodir}" "${2}"
|
||||||
;;
|
;;
|
||||||
"sh")
|
"sh")
|
||||||
require_dependency doas
|
require_dependency doas
|
||||||
"${libexec}"/commands/sourcezap-sh "${gitdir}"
|
"${libexec}"/commands/sourcezap-sh "${repodir}"
|
||||||
;;
|
;;
|
||||||
"rm")
|
"rm")
|
||||||
"${libexec}"/commands/sourcezap-rm "${gitdir}" "${installdir}"
|
"${libexec}"/commands/sourcezap-rm "${repodir}" "${installdir}"
|
||||||
;;
|
;;
|
||||||
"install")
|
"install")
|
||||||
require_dependency git doas
|
require_dependency git doas
|
||||||
"${libexec}"/commands/sourcezap-install "${gitdir}" "${installdir}" "${revfile}"
|
"${libexec}"/commands/sourcezap-install "${repodir}" "${installdir}" "${commitfile}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "Usage: sourcezap COMMAND [OPTIONS]\n"
|
printf "Usage: sourcezap COMMAND [OPTIONS]\n"
|
||||||
|
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
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}"/utils/git/run
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
branch=$2
|
branch=$2
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -26,12 +26,12 @@ if ! "${libexec}"/utils/issourcezap-member; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "${gitdir}/.git" ]; then
|
if [ ! -e "${repodir}/.git" ]; then
|
||||||
printerr "try 'sourcezap clone' instead"
|
printerr "try 'sourcezap clone' instead"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
"${git}" fetch origin
|
"${git}" fetch origin
|
||||||
"${git}" checkout "${branch}" ||
|
"${git}" checkout "${branch}" ||
|
||||||
"${git}" checkout -t origin/"${branch}"
|
"${git}" checkout -t origin/"${branch}"
|
||||||
|
|
|
@ -6,8 +6,8 @@ set -e
|
||||||
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}"/utils/git/run
|
||||||
giturl=$1
|
repourl=$1
|
||||||
gitdir=$2
|
repodir=$2
|
||||||
branch=$3
|
branch=$3
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -27,13 +27,13 @@ if ! "${libexec}"/utils/issourcezap-member; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "${gitdir}/.git" ]; then
|
if [ -e "${repodir}/.git" ]; then
|
||||||
printerr "try 'sourcezap pull' instead"
|
printerr "try 'sourcezap pull' instead"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"${git}" clone "${giturl}" "${gitdir}"
|
"${git}" clone "${repourl}" "${repodir}"
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
"${git}" config core.filemode off
|
"${git}" config core.filemode off
|
||||||
"${git}" checkout -t origin/"${branch}" > /dev/null 2>&1 || true
|
"${git}" checkout -t origin/"${branch}" > /dev/null 2>&1 || true
|
||||||
printok "clone complete"
|
printok "clone complete"
|
||||||
|
|
|
@ -7,9 +7,9 @@ localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
git="${libexec}"/utils/git/run
|
git="${libexec}"/utils/git/run
|
||||||
mask=$("${libexec}"/utils/get-umask)
|
mask=$("${libexec}"/utils/get-umask)
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
revfile=$3
|
commitfile=$3
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
|
@ -23,14 +23,14 @@ if [ "$(id -u)" != "0" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
if [ -e "${revfile}" ]; then
|
if [ -e "${commitfile}" ]; then
|
||||||
##
|
##
|
||||||
# install update
|
# install update
|
||||||
rev=$(cat "${revfile}")
|
commit=$(cat "${commitfile}")
|
||||||
"${libexec}"/utils/install/run -d "${installdir}"
|
"${libexec}"/utils/install/run -d "${installdir}"
|
||||||
"${libexec}"/utils/install/update-deleted-files "${gitdir}" "${installdir}" "${rev}"
|
"${libexec}"/utils/install/update-deleted-files "${repodir}" "${installdir}" "${commit}"
|
||||||
"${libexec}"/utils/install/update-changed-files "${gitdir}" "${installdir}" "${rev}"
|
"${libexec}"/utils/install/update-changed-files "${repodir}" "${installdir}" "${commit}"
|
||||||
else
|
else
|
||||||
##
|
##
|
||||||
# install from scratch
|
# install from scratch
|
||||||
|
@ -52,5 +52,5 @@ else
|
||||||
-exec cp -Rpv {} "${installdir}" \;
|
-exec cp -Rpv {} "${installdir}" \;
|
||||||
chown -Rv root "${installdir}"
|
chown -Rv root "${installdir}"
|
||||||
fi
|
fi
|
||||||
"${git}" rev-parse HEAD > "${revfile}"
|
"${git}" rev-parse HEAD > "${commitfile}"
|
||||||
printok "install complete"
|
printok "install complete"
|
||||||
|
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
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}"/utils/git/run
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
|
@ -25,12 +25,12 @@ if ! "${libexec}"/utils/issourcezap-member; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "${gitdir}/.git" ]; then
|
if [ ! -e "${repodir}/.git" ]; then
|
||||||
printerr "try 'sourcezap clone' instead"
|
printerr "try 'sourcezap clone' instead"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
branch=$("${git}" branch --show-current)
|
branch=$("${git}" branch --show-current)
|
||||||
"${git}" pull --rebase origin "${branch}"
|
"${git}" pull --rebase origin "${branch}"
|
||||||
printok "pull complete"
|
printok "pull complete"
|
||||||
|
|
|
@ -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
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -36,19 +36,19 @@ if [ "$(id -u)" != "0" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "1 Remove the contents of %s\n" "${gitdir}"
|
printf "1 Remove the contents of %s\n" "${repodir}"
|
||||||
printf "2 Remove the contents of %s\n" "${installdir}"
|
printf "2 Remove the contents of %s\n" "${installdir}"
|
||||||
printf "3 Remove the contents of both (%s and %s)\n" "${gitdir}" "${installdir}"
|
printf "3 Remove the contents of both (%s and %s)\n" "${repodir}" "${installdir}"
|
||||||
printf "4 Do nothing\n"
|
printf "4 Do nothing\n"
|
||||||
printf "1-4: "
|
printf "1-4: "
|
||||||
while true; do
|
while true; do
|
||||||
read -r r
|
read -r r
|
||||||
if [ "${r}" = "1" ]; then
|
if [ "${r}" = "1" ]; then
|
||||||
erase "${gitdir}"
|
erase "${repodir}"
|
||||||
elif [ "${r}" = "2" ]; then
|
elif [ "${r}" = "2" ]; then
|
||||||
erase "${installdir}"
|
erase "${installdir}"
|
||||||
elif [ "${r}" = "3" ]; then
|
elif [ "${r}" = "3" ]; then
|
||||||
erase "${gitdir}"
|
erase "${repodir}"
|
||||||
erase "${installdir}"
|
erase "${installdir}"
|
||||||
elif [ "${r}" = "4" ]; then
|
elif [ "${r}" = "4" ]; then
|
||||||
break
|
break
|
||||||
|
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
user=_sourcezap
|
user=_sourcezap
|
||||||
gitdir="${1}"
|
repodir="${1}"
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
|
@ -25,12 +25,12 @@ if ! "${libexec}"/utils/issourcezap-member; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "${gitdir}" ]; then
|
if [ ! -e "${repodir}" ]; then
|
||||||
printerr "try 'sourcezap clone' instead"
|
printerr "try 'sourcezap clone' instead"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
doas -n \
|
doas -n \
|
||||||
-u "${user}" \
|
-u "${user}" \
|
||||||
/bin/sh
|
/bin/sh
|
||||||
|
|
|
@ -6,11 +6,11 @@ set -e
|
||||||
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}"/utils/git/run
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
commit=$2
|
commit=$2
|
||||||
|
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
"${git}" diff -l0 --name-only --diff-filter=A "${commit}" "HEAD"
|
"${git}" diff -l0 --name-only --diff-filter=A "${commit}" "HEAD"
|
||||||
"${git}" diff -l0 --name-only --diff-filter=M "${commit}" "HEAD"
|
"${git}" diff -l0 --name-only --diff-filter=M "${commit}" "HEAD"
|
||||||
|
|
|
@ -6,10 +6,10 @@ set -e
|
||||||
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}"/utils/git/run
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
commit=$2
|
commit=$2
|
||||||
|
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
"${git}" diff -l0 --name-only --diff-filter=D "${commit}" "HEAD"
|
"${git}" diff -l0 --name-only --diff-filter=D "${commit}" "HEAD"
|
||||||
|
|
|
@ -5,14 +5,14 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
rev=$3
|
commit=$3
|
||||||
|
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
files=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}")
|
files=$("${libexec}"/utils/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}")
|
||||||
|
|
|
@ -5,14 +5,14 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
gitdir=$1
|
repodir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
rev=$3
|
commit=$3
|
||||||
|
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
cd "${gitdir}"
|
cd "${repodir}"
|
||||||
files=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}")
|
files=$("${libexec}"/utils/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}")
|
||||||
|
|
|
@ -1,50 +1,52 @@
|
||||||
* vNEXT
|
# -*- mode: org -*-
|
||||||
|
|
||||||
** Add 'libexec/sourcezap/utils/get-umask'
|
* v1.1.0
|
||||||
|
|
||||||
|
**** Add 'libexec/sourcezap/utils/get-umask'
|
||||||
Add a single source of truth for the mask given to umask
|
Add a single source of truth for the mask given to umask
|
||||||
by git and sourcezap-install
|
by git and sourcezap-install
|
||||||
|
|
||||||
** Break up 'sourcezap-install' into multiple files
|
**** Break up 'sourcezap-install' into multiple files
|
||||||
'libexec/sourcezap/utils/install/' contains files that cover both
|
'libexec/sourcezap/utils/install/' contains files that cover both
|
||||||
a fresh install and applying an update
|
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
|
||||||
|
|
||||||
** Add libexec/sourcezap/setup/setup-user
|
**** Add libexec/sourcezap/setup/setup-user
|
||||||
setup-user sets up the '_sourcezap' user and environment
|
setup-user sets up the '_sourcezap' user and environment
|
||||||
|
|
||||||
** Recover from git-checkout failure
|
**** Recover from git-checkout failure
|
||||||
Recover gracefully from git-checkout failure in sourcezap-clone
|
Recover gracefully from git-checkout failure in sourcezap-clone
|
||||||
|
|
||||||
* v0.2.1
|
* v0.2.1
|
||||||
|
|
||||||
** Fix Makefile
|
**** Fix Makefile
|
||||||
The mandoc directory wasn't created properly.
|
The mandoc directory wasn't created properly.
|
||||||
It only became obvious when building the port
|
It only became obvious when building the port
|
||||||
into a temporary staging directory
|
into a temporary staging directory
|
||||||
|
|
||||||
* v0.2.0
|
* v0.2.0
|
||||||
|
|
||||||
** Remove git-diff limit
|
**** Remove git-diff limit
|
||||||
Remove file rename limit from git-diff
|
Remove file rename limit from git-diff
|
||||||
|
|
||||||
** Replace utils/gitexec with utils/git/run
|
**** Replace utils/gitexec with utils/git/run
|
||||||
Communicate with git via utils/git/run
|
Communicate with git via utils/git/run
|
||||||
|
|
||||||
** Add utils/git
|
**** Add utils/git
|
||||||
A dedicated directory for git-related scripts
|
A dedicated directory for git-related scripts
|
||||||
|
|
||||||
** Remove "set -x"
|
**** Remove "set -x"
|
||||||
Emit less output
|
Emit less output
|
||||||
|
|
||||||
** Remove scripts
|
**** Remove scripts
|
||||||
Remove utils/printok, utils/printerr, utils/git-rev
|
Remove utils/printok, utils/printerr, utils/git-rev
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
v1.0.0
|
v1.1.0
|
||||||
|
|
Loading…
Reference in a new issue