From 7bf64d5abc8bfcce9e7c15c76bff08ba550f5ce2 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 23 May 2024 01:51:21 -0300 Subject: [PATCH] Add libexec/portzap/utils/gitexec --- libexec/portzap/commands/portzap-checkout | 5 +---- libexec/portzap/commands/portzap-clone | 5 +---- libexec/portzap/commands/portzap-pull | 5 +---- libexec/portzap/utils/git-changed-files | 7 +++---- libexec/portzap/utils/git-removed-files | 7 +++---- libexec/portzap/utils/git-rev | 7 +++---- libexec/portzap/utils/gitexec | 13 +++++++++++++ 7 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 libexec/portzap/utils/gitexec diff --git a/libexec/portzap/commands/portzap-checkout b/libexec/portzap/commands/portzap-checkout index 16d4f1d..b67c91e 100644 --- a/libexec/portzap/commands/portzap-checkout +++ b/libexec/portzap/commands/portzap-checkout @@ -5,8 +5,6 @@ set -e # variables localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap -git=$(which git) -mode=u=rwX,g=rX,o= gitdir="$1" branch="$2" @@ -14,8 +12,7 @@ branch="$2" # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } printok() { diff --git a/libexec/portzap/commands/portzap-clone b/libexec/portzap/commands/portzap-clone index a55661c..b853359 100755 --- a/libexec/portzap/commands/portzap-clone +++ b/libexec/portzap/commands/portzap-clone @@ -5,8 +5,6 @@ set -e # variables localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap -git=$(which git) -mode=u=rwX,g=rX,o= giturl=$1 gitdir=$2 branch=$3 @@ -15,8 +13,7 @@ branch=$3 # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } printok() { diff --git a/libexec/portzap/commands/portzap-pull b/libexec/portzap/commands/portzap-pull index ca3d2be..e2df98f 100755 --- a/libexec/portzap/commands/portzap-pull +++ b/libexec/portzap/commands/portzap-pull @@ -5,16 +5,13 @@ set -e # variables localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap -git=$(which git) -mode=u=rwX,g=rX,o= gitdir=$1 ## # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } printok() { diff --git a/libexec/portzap/utils/git-changed-files b/libexec/portzap/utils/git-changed-files index 58f6fcb..5ad2991 100644 --- a/libexec/portzap/utils/git-changed-files +++ b/libexec/portzap/utils/git-changed-files @@ -3,8 +3,8 @@ set -e ## # variables -git=$(which git) -mode=u=rwX,g=rX,o= +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} +libexec="${localbase}"/libexec/portzap gitdir=$1 commit=$2 @@ -12,8 +12,7 @@ commit=$2 # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } ## diff --git a/libexec/portzap/utils/git-removed-files b/libexec/portzap/utils/git-removed-files index 8a779e5..44cbdeb 100644 --- a/libexec/portzap/utils/git-removed-files +++ b/libexec/portzap/utils/git-removed-files @@ -3,8 +3,8 @@ set -e ## # variables -git=$(which git) -mode=u=rwX,g=rX,o= +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} +libexec="${localbase}"/libexec/portzap gitdir=$1 commit=$2 @@ -12,8 +12,7 @@ commit=$2 # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } ## diff --git a/libexec/portzap/utils/git-rev b/libexec/portzap/utils/git-rev index 2a49568..045e4bd 100644 --- a/libexec/portzap/utils/git-rev +++ b/libexec/portzap/utils/git-rev @@ -3,16 +3,15 @@ set -e ## # variables -git=$(which git) -mode=u=rwX,g=rX,o= +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} +libexec="${localbase}"/libexec/portzap gitdir=$1 ## # functions gitexec() { - doas -n -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + "${libexec}"/utils/gitexec "${1}" } ## diff --git a/libexec/portzap/utils/gitexec b/libexec/portzap/utils/gitexec new file mode 100644 index 0000000..228245b --- /dev/null +++ b/libexec/portzap/utils/gitexec @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +## +# variables +git=$(which git) +mode=u=rwx,g=rx,o= + +## +# main +doas -n \ + -u _portzap \ + /bin/sh -c "umask ${mode}; ${git} ${1}"