portzap/libexec/portzap/portzap-clone
0x1eef 105b4f6594 Alter default umask / mode
'/home/_portzap/ports/' and '/usr/ports/' have reduced permissions for
members of the '_portzap' group, who now possess read-only permissions
for both directories.

The 'portzap erase' command must be run by root, since members of the
'_portzap' group can't delete contents of either of those directories
anymore.
2024-04-20 02:23:20 -03:00

39 lines
818 B
Bash
Executable file

#!/bin/sh -e
##
# variables
localbase=${LOCALBASE:-/usr/local}
libexec=$(dirname "$0")
git="${localbase}"/bin/git
giturl=$1
gitdir=$2
branch=$3
mode="u=rwX,g=rX,o="
##
# main
if ! "${libexec}"/isportzap-member; then
echo "[-] This command must be run by a member of the '_portzap' group"
exit 1
fi
if [ -e "${gitdir}/.git" ]; then
echo "[-] ${gitdir} exists."
echo "[-] Try 'portzap pull'"
exit 1
fi
set -x
umask ${mode}
doas -u _portzap "${git}" clone "${giturl}" "${gitdir}"
cd "${gitdir}"
set +x
echo "[-] Adjust filemode. This might take a while"
doas -u _portzap "${git}" config core.filemode off
doas -u root /bin/chmod -R ${mode} "${gitdir}"
echo "[-] git checkout ${branch}"
doas -u _portzap "${git}" \
checkout -t \
origin/"${branch}" \
> /dev/null 2>&1
echo "[-] Done"