Add improvements related to changes in recent commits

This commit is contained in:
0x1eef 2023-01-15 22:08:27 -03:00 committed by Robert
parent f5997e36bd
commit 7708211b7f

View file

@ -4,18 +4,21 @@
# A shell script that takes care of keeping up to date with # A shell script that takes care of keeping up to date with
# the HardenedBSD ports collection. # the HardenedBSD ports collection.
##
# Configuration
source="https://git.hardenedbsd.org/hardenedbsd/ports.git" source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
stage_dir="/home/_portzap/ports" transient_dir="/home/_portzap/ports"
clone_mode=007 final_dir="/usr/ports/"
pull_mode=007
##
# Default modes
init_mode=707
clone_mode=007 clone_mode=007
pull_mode=007 pull_mode=007
init_mode=707 unpack_mode=022
## ##
# Utils # Utils
exit_on_missing_deps() { exit_on_missing_deps() {
deps="git" deps="git"
for dep in $deps; do for dep in $deps; do
@ -41,12 +44,12 @@ has_portzap_access() {
user_is_not_root() { user_is_not_root() {
user_id=$(id -u $(whoami)) user_id=$(id -u $(whoami))
return $(test $user_id -ne "0") result=$(test $user_id -ne "0")
return $result
} }
## ##
# Commands # Commands
help() { help() {
echo "Usage: portzap init|clone|pull|unpack" echo "Usage: portzap init|clone|pull|unpack"
} }
@ -65,26 +68,26 @@ init() {
clone() { clone() {
if has_portzap_access if has_portzap_access
then then
if [ -e "$stage_dir/.git" ]; if [ -e "$transient_dir/.git" ];
then then
echo "$stage_dir has already been cloned." echo "$transient_dir has already been cloned."
echo "Run 'portzap pull' instead." echo "Run 'portzap pull' instead."
exit 1 exit 1
fi fi
umask $clone_mode umask $clone_mode
git clone --depth 1 $source $stage_dir git clone --depth 1 $source $transient_dir
else else
echo "Permission denied" echo "Permission denied."
fi fi
} }
pull() { pull() {
if has_portzap_access if has_portzap_access
then then
if [ -e "$stage_dir/.git" ]; if [ -e "$transient_dir/.git" ];
then then
umask $pull_mode umask $pull_mode
cd $stage_dir cd $transient_dir
git pull --rebase origin hardenedbsd/main git pull --rebase origin hardenedbsd/main
else else
echo "Run 'portzap clone' first." echo "Run 'portzap clone' first."
@ -102,7 +105,8 @@ unpack() {
echo "The unpack command should be run as root." echo "The unpack command should be run as root."
exit 1 exit 1
fi fi
cp -Rfv /tmp/ports /usr/ umask $unpack_mode
cp -Rfv "$transient_dir/." $final_dir
} }
case $1 in case $1 in