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> The URL to a git repository. <br>
Default: https://git.hardenedbsd.org/hardenedbsd/ports.git. 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> * __$PORTZAP\_INSTALLDIR__ <br>
The directory where the ports collection will be installed. <br> The directory where the ports collection will be installed. <br>
Default: /usr/ports/. Default: /usr/ports/.

View file

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

View file

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

View file

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