From 0f08f82e6af1c73e4bea5d6de2e772dd9f4b4b3c Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 20 Jan 2023 11:06:19 -0300 Subject: [PATCH] Add libexec/portzap/install-directory --- bin/portzap | 9 +++++---- libexec/portzap/install-directory | 6 ++++++ libexec/portzap/install-port | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100755 libexec/portzap/install-directory diff --git a/bin/portzap b/bin/portzap index 232f1ee..15b29f2 100755 --- a/bin/portzap +++ b/bin/portzap @@ -8,6 +8,7 @@ source_url="https://git.hardenedbsd.org/hardenedbsd/ports.git" transient_dir="/home/_portzap/ports" rest_dir="/usr/ports/" libexec_dir=$(realpath $(dirname $0)/../libexec/portzap/) +group="_portzap" ## # Default masks @@ -17,7 +18,7 @@ pull_mask=007 ## # Default modes -install_mode="u=rwX,g=rX,o=rX" +install_mode="u=rwX,g=rX,o=" ## # Utils @@ -108,9 +109,9 @@ install() { exit 1 fi cd $transient_dir - find . -maxdepth 1 -type f -exec install -m $install_mode {} $rest_dir \; - find . -maxdepth 1 -type d -exec mkdir -p -m $install_mode $rest_dir/{} \; - find . -depth 2 -type d -exec $libexec_dir/install-port {} $rest_dir $install_mode \; + find . -maxdepth 1 -type f -exec install -g $group -m $install_mode {} $rest_dir \; + find . -maxdepth 1 -type d -exec $libexec_dir/install-directory {} $rest_dir/{} \; + find . -depth 2 -type d -exec $libexec_dir/install-port {} $rest_dir $install_mode $libexec_dir \; } case $1 in diff --git a/libexec/portzap/install-directory b/libexec/portzap/install-directory new file mode 100755 index 0000000..55dce38 --- /dev/null +++ b/libexec/portzap/install-directory @@ -0,0 +1,6 @@ +#!/bin/sh +src=$1 +dest=$2 +group=_portzap +mode=u=rwx,g=rx,o= +install -d -g $group -m $mode $src $dest diff --git a/libexec/portzap/install-port b/libexec/portzap/install-port index 189585c..6d0175c 100755 --- a/libexec/portzap/install-port +++ b/libexec/portzap/install-port @@ -2,14 +2,15 @@ src=$1 dest=$2/${src} mode=$3 +libexec_dir=$4 group=_portzap install_args="-m $mode" -mkdir -m $mode -p $dest +$libexec_dir/install-directory $src $dest find $src -maxdepth 1 -type f -execdir install $install_args {} $dest/{} \; if [ -d "$src/files" ]; then - mkdir -m $mode -p $dest/files + $libexec_dir/install-directory $src/files $dest/files find $src/files -maxdepth 1 -type f -execdir install $install_args {} $dest/files \; fi echo Install $(realpath $dest)