Perform incremental updates (via doas)
This commit is contained in:
parent
ea6a5e46e5
commit
73ec936871
5 changed files with 80 additions and 9 deletions
14
libexec/portzap/git-changed-files
Normal file
14
libexec/portzap/git-changed-files
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
##
|
||||
# variables
|
||||
gitdir=$1
|
||||
commit=$2
|
||||
|
||||
##
|
||||
# main
|
||||
cd ${gitdir}
|
||||
add=$(git diff --name-only --diff-filter=A ${commit} HEAD)
|
||||
mod=$(git diff --name-only --diff-filter=M ${commit} HEAD)
|
||||
echo ${add}
|
||||
echo ${mod}
|
11
libexec/portzap/git-removed-files
Normal file
11
libexec/portzap/git-removed-files
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
##
|
||||
# variables
|
||||
gitdir=$1
|
||||
commit=$2
|
||||
|
||||
##
|
||||
# main
|
||||
cd ${gitdir}
|
||||
git diff --name-only --diff-filter=D ${commit} HEAD
|
10
libexec/portzap/git-rev
Normal file
10
libexec/portzap/git-rev
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
##
|
||||
# variables
|
||||
gitdir=$1
|
||||
|
||||
##
|
||||
# main
|
||||
cd ${gitdir}
|
||||
git rev-parse HEAD
|
|
@ -4,16 +4,47 @@
|
|||
# variables
|
||||
gitdir=$1
|
||||
installdir=$2
|
||||
excludes=".git .gitignore .hooks .arcconfig"
|
||||
revfile=$3
|
||||
artifacts=".git .gitignore .hooks .arcconfig"
|
||||
libexec=/usr/local/libexec/portzap
|
||||
|
||||
##
|
||||
# main
|
||||
cd "${gitdir}"
|
||||
# functions
|
||||
perform_update()
|
||||
{
|
||||
rev=$(cat "${revfile}")
|
||||
add=$(doas -u _portzap ${libexec}/git-changed-files "${gitdir}" "${rev}")
|
||||
del=$(doas -u _portzap ${libexec}/git-removed-files "${gitdir}" "${rev}")
|
||||
set -x
|
||||
for file in ${del}; do
|
||||
target="${installdir}/${file}"
|
||||
rm "${target}"
|
||||
done
|
||||
for file in ${add}; do
|
||||
target="${installdir}/${file}"
|
||||
cp "${file}" "${target}"
|
||||
chown root:_portzap "${target}"
|
||||
chmod u=rw,g=rw,o= "${target}"
|
||||
done
|
||||
}
|
||||
|
||||
perform_install()
|
||||
{
|
||||
find -s . -maxdepth 1 \
|
||||
-exec cp -Rfv {} "${installdir}" \; \
|
||||
-exec chown -R root:_portzap "${installdir}/{}" \; \
|
||||
-exec chmod -R u=rwX,g=rwX,o= "${installdir}/{}" \;
|
||||
cd "${installdir}"
|
||||
for exclude in ${excludes}; do
|
||||
rm -rf "${exclude}"
|
||||
for path in ${artifacts}; do
|
||||
rm -rf "${installdir}/${path}"
|
||||
done
|
||||
}
|
||||
|
||||
##
|
||||
# main
|
||||
cd "${gitdir}"
|
||||
if [ -e "${revfile}" ]; then
|
||||
perform_update
|
||||
else
|
||||
perform_install
|
||||
fi
|
||||
echo $(doas -u _portzap ${libexec}/git-rev ${gitdir}) > ${revfile}
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
##
|
||||
# portzap
|
||||
permit nopass :_portzap as _portzap cmd /usr/local/libexec/portzap/portzap-clone
|
||||
permit nopass :_portzap as _portzap cmd /usr/local/libexec/portzap/portzap-pull
|
||||
permit nopass root as _portzap cmd /usr/local/libexec/portzap/git-changed-files
|
||||
permit nopass root as _portzap cmd /usr/local/libexec/portzap/git-removed-files
|
||||
permit nopass root as _portzap cmd /usr/local/libexec/portzap/git-rev
|
||||
|
|
Loading…
Reference in a new issue