Add $PORTZAP_BRANCH

This commit is contained in:
0x1eef 2024-04-17 16:37:16 -03:00
parent 93af7e94ec
commit a6c98489a7
5 changed files with 23 additions and 4 deletions

View file

@ -29,6 +29,10 @@ portzap is a utility that manages a local copy of the
The URL to a git repository. <br>
Default: https://git.hardenedbsd.org/hardenedbsd/ports.git.
* __$PORTZAP\_BRANCH__ <br>
The git branch to clone and pull updates from. <br>
Default: hardenedbsd/main.
* __$PORTZAP\_INSTALLDIR__ <br>
The directory where the ports collection will be installed. <br>
Default: /usr/ports/.

View file

@ -5,6 +5,7 @@
rootdir=$(dirname "$0")
gitdir="/home/_portzap/ports"
giturl="${PORTZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/ports.git}"
branch="${PORTZAP_BRANCH:-hardenedbsd/main}"
installdir="${PORTZAP_INSTALLDIR:-/usr/ports}"
revision="${installdir}/.portzap"
libexec=$(realpath "${rootdir}/../libexec/portzap")
@ -43,12 +44,12 @@ case $1 in
"clone")
require_dependency "git doas"
require_membership_of _portzap
doas -u _portzap "${libexec}"/portzap-clone "${giturl}" "${gitdir}"
doas -u _portzap "${libexec}"/portzap-clone "${giturl}" "${gitdir}" "${branch}"
;;
"pull")
require_dependency "git doas"
require_membership_of _portzap
doas -u _portzap "${libexec}"/portzap-pull "${gitdir}"
doas -u _portzap "${libexec}"/portzap-pull "${gitdir}" "${branch}"
;;
"install")
require_root

View file

@ -4,6 +4,7 @@
# variables
giturl=$1
gitdir=$2
branch=$3
##
# main
@ -12,7 +13,11 @@ if [ -e "${gitdir}/.git" ]; then
echo "[-] Try 'portzap pull'"
exit 1
fi
umask u=rwX,g=rwX,o=
set -x
umask u=rwX,g=rwX,o=
git clone "${giturl}" "${gitdir}"
cd "${gitdir}"
set +x +e
echo "[-] Checkout ${branch}"
git checkout -t origin/"${branch}" > /dev/null 2>&1;
echo "[-] Done"

View file

@ -3,6 +3,7 @@
##
# variables
gitdir=$1
branch=$2
##
# main
@ -10,7 +11,7 @@ umask u=rwX,g=rwX,o=
if [ -e "${gitdir}/.git" ]; then
set -x
cd "${gitdir}"
git pull --rebase origin hardenedbsd/main
git pull --rebase origin "${branch}"
else
echo "[-] ${gitdir} is not a valid git repository."
echo "[-] Try 'portzap clone'"

View file

@ -51,11 +51,19 @@ The URL to a git repository.
.br
Default: https://git.hardenedbsd.org/hardenedbsd/ports.git
.sp
.Nm PORTZAP_BRANCH
.br
The git branch to clone and pull updates from.
.br
Default: hardenedbsd/main
.br
.sp
.Nm PORTZAP_INSTALLDIR
.br
The directory where the ports collection will be installed.
.br
Default: /usr/ports/
.sp
.Sh AUTHORS
The
.Nm portzap