diff --git a/libexec/portzap/portzap-clone b/libexec/portzap/portzap-clone index 99a1d37..dd29706 100755 --- a/libexec/portzap/portzap-clone +++ b/libexec/portzap/portzap-clone @@ -20,13 +20,14 @@ if [ -e "${gitdir}/.git" ]; then echo "[-] ${gitdir} exists." echo "[-] Try 'portzap pull'" exit 1 -else - set -x - umask u=rwX,g=rwX,o= - doas -u _portzap "${git}" clone "${giturl}" "${gitdir}" - cd "${gitdir}" - set +x +e - echo "[-] Checkout ${branch}" - doas -u _portzap "${git}" checkout -t origin/"${branch}" > /dev/null 2>&1; - echo "[-] Done" fi + +set -x +umask u=rwX,g=rwX,o= +doas -u _portzap "${git}" clone "${giturl}" "${gitdir}" +cd "${gitdir}" +doas -u _portzap "${git}" config core.filemode off +set +x +e +echo "[-] Checkout ${branch}" +doas -u _portzap "${git}" checkout -t origin/"${branch}" > /dev/null 2>&1; +echo "[-] Done" diff --git a/libexec/portzap/portzap-install b/libexec/portzap/portzap-install index a3135c1..080d7f8 100755 --- a/libexec/portzap/portzap-install +++ b/libexec/portzap/portzap-install @@ -61,6 +61,7 @@ if [ "$(id -u)" != "0" ]; then echo "[-] This command must be run as root" exit 1 fi + set -x umask u=rwX,g=rwX,o= cd "${gitdir}" diff --git a/libexec/portzap/portzap-pull b/libexec/portzap/portzap-pull index 3893011..0134377 100755 --- a/libexec/portzap/portzap-pull +++ b/libexec/portzap/portzap-pull @@ -10,13 +10,6 @@ branch=$2 ## # functions -set_repository_permissions() -{ - gitdir=$1 - doas -u root /bin/chmod -R u=rwX,g=rwX,o= "${gitdir}/.git" - doas -u root /usr/sbin/chown -R _portzap:_portzap "${gitdir}/.git" -} - change_branch() { set +e @@ -26,7 +19,6 @@ change_branch() doas -u _portzap "${git}" fetch "${remote}" > /dev/null 2>&1 doas -u _portzap "${git}" checkout "${branch}" > /dev/null 2>&1 || doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1 - doas -u _portzap "${git}" reset HEAD --hard > /dev/null 2>&1 echo "[-] Done" set -e } @@ -38,19 +30,21 @@ if ! "${libexec}"/isportzap-member; then exit 1 fi -if [ -e "${gitdir}/.git" ]; then - umask u=rwX,g=rwX,o= - set_repository_permissions "${gitdir}" - cd "${gitdir}" - remote=$("${git}" remote | head -n1) - if [ "$(git branch --show-current)" != "${branch}" ]; then - change_branch "${remote}" "${branch}" - fi - set -x - doas -u _portzap "${git}" pull --rebase "${remote}" "${branch}" -else +if [ ! -e "${gitdir}/.git" ]; then set +x echo "[-] ${gitdir} is not a valid git repository." echo "[-] Try 'portzap clone'" exit 1 fi + +umask u=rwX,g=rwX,o= +doas -u root /bin/chmod -R u=rwX,g=rwX,o= "${gitdir}/.git" +doas -u root /usr/sbin/chown -R _portzap:_portzap "${gitdir}/.git" +cd "${gitdir}" +remote=$("${git}" remote | head -n1) +if [ "$(git branch --show-current)" != "${branch}" ]; then + change_branch "${remote}" "${branch}" + doas -u root /bin/chmod -R u=rwX,g=rwX,o= "${gitdir}" +fi +set -x +doas -u _portzap "${git}" pull --rebase "${remote}" "${branch}" diff --git a/share/portzap/doas.conf b/share/portzap/doas.conf index 8d7fb4c..5d0e9fa 100644 --- a/share/portzap/doas.conf +++ b/share/portzap/doas.conf @@ -2,5 +2,6 @@ # portzap permit nopass root as _portzap cmd /usr/local/bin/git permit nopass :_portzap as _portzap cmd /usr/local/bin/git +permit nopass :_portzap as root cmd /bin/chmod args -R u=rwX,g=rwX,o= /home/_portzap/ports permit nopass :_portzap as root cmd /bin/chmod args -R u=rwX,g=rwX,o= /home/_portzap/ports/.git permit nopass :_portzap as root cmd /usr/sbin/chown args -R _portzap:_portzap /home/_portzap/ports/.git