From 459c5103bb8e268b62179a65d061eb42587d2950 Mon Sep 17 00:00:00 2001 From: Robert McLay Date: Fri, 29 Jul 2022 15:32:15 -0500 Subject: [PATCH] Support for user defined install MODE --- Makefile.in | 3 +++ configure | 44 ++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/Makefile.in b/Makefile.in index 6e5f847f1..f5c9a6c7f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -102,6 +102,9 @@ LMOD_MF_SOURCE := $(patsubst %, $(srcdir)/%, MF/*.version.lua) SETTARG_SOURCE := $(patsubst %, $(srcdir)/%, settarg/*.lua settarg/targ.in) DATE_cmd := $(srcdir)/proj_mgmt/DATE_cmd.sh UNAME_S := $(shell uname -s) +MODE_X := @MODE_X@ +MODE_R := @MODE_R@ + ifeq ($(UNAME_S),Darwin) SED := gsed else diff --git a/configure b/configure index 81d43dcce..10bb2fd05 100755 --- a/configure +++ b/configure @@ -657,6 +657,8 @@ SYS_LUA_PATH FIND_PATH_TO_LUAC FIND_PATH_TO_LUA PATH_TO_TR +MODE_R +MODE_X PATH_TO_TCLSH PATH_TO_PAGER PATH_TO_HASHSUM @@ -707,6 +709,7 @@ REDIRECT EXPORT_MODULE AUTO_SWAP LMOD_CONFIG_DIR +MODE EXACT_MATCH HIDDEN_ITALIC DYNAMIC_SPIDER_CACHE @@ -1448,6 +1451,8 @@ Optional Packages: allow for Dynamic Spider Cache usage [[yes]] --with-hiddenItalic=ans Use italic for hidden module instead of faint[[no]] --with-exactMatch=ans require exact match, disable defaults [[no]] + --with-mode=ans Override executable install mode (755 or 750 or 700) + [[user_default]] --with-lmodConfigDir=ans Location of Lmod Config Dir [[/etc/lmod]] --with-autoSwap=ans Allow auto swapping of compiler etc. [[yes]] @@ -3626,6 +3631,27 @@ fi +# Check whether --with-colorize was given. +if test ${with_colorize+y} +then : + withval=$with_colorize; MODE="$withval" + MODE=`echo $MODE | tr '[:upper:]' '[:lower:]'` + VALID_YN $MODE "--with-mode=ans: ans must be yes or no" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: MODE=$with_mode" >&5 +printf "%s\n" "MODE=$with_mode" >&6; } + printf "%s\n" "#define MODE \"$with_mode\"" >>confdefs.h + +else $as_nop + withval="user_default" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: MODE=$withval" >&5 +printf "%s\n" "MODE=$withval" >&6; } + MODE="$withval" + printf "%s\n" "#define MODE \"$withval\"" >>confdefs.h + +fi + + + # Check whether --with-lmodConfigDir was given. if test ${with_lmodConfigDir+y} then : @@ -4552,6 +4578,24 @@ PATH_TO_SRC=$SRCDIR + + +if test $MODE = "user_default" ; then + uid=$(id -u) + umask=$(umask) + if test $uid -lt 500; then + umask=022 + fi + MODE_X=$(( ( ~ $umask ) & 0777 )) +else + MODE_X=$MODE +fi +MODE_R=$(( 0666 & $MODE_X )) +MODE_X=$(echo "ibase=10; obase=8; $MODE_X" | bc ) +MODE_R=$(echo "ibase=10; obase=8; $MODE_R" | bc ) +echo MODE_X: $MODE_X +echo MODE_R: $MODE_R + # Extract the first word of "ps", so it can be a program name with args. set dummy ps; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 diff --git a/configure.ac b/configure.ac index 829e61661..952bcf63d 100644 --- a/configure.ac +++ b/configure.ac @@ -165,6 +165,20 @@ AC_ARG_WITH(exactMatch, EXACT_MATCH="$withval" AC_DEFINE_UNQUOTED(EXACT_MATCH, "$withval"))dnl +AC_SUBST(MODE) +AC_ARG_WITH(colorize, + AS_HELP_STRING([--with-mode=ans],[Override executable install mode (755 or 750 or 700) [[user_default]]]), + MODE="$withval" + MODE=`echo $MODE | tr '@<:@:upper:@:>@' '@<:@:lower:@:>@'` + VALID_YN $MODE "--with-mode=ans: ans must be yes or no" + AC_MSG_RESULT([MODE=$with_mode]) + AC_DEFINE_UNQUOTED(MODE, "$with_mode")dnl + , + withval="user_default" + AC_MSG_RESULT([MODE=$withval]) + MODE="$withval" + AC_DEFINE_UNQUOTED(MODE, "$withval"))dnl + AC_SUBST(LMOD_CONFIG_DIR) AC_ARG_WITH(lmodConfigDir, AS_HELP_STRING([--with-lmodConfigDir=ans],[Location of Lmod Config Dir [[/etc/lmod]]]), @@ -706,6 +720,24 @@ AC_SUBST(PATH_TO_GIT) AC_SUBST(PATH_TO_HASHSUM) AC_SUBST(PATH_TO_PAGER) AC_SUBST(PATH_TO_TCLSH) +AC_SUBST(MODE_X) +AC_SUBST(MODE_R) + +if test $MODE = "user_default" ; then + uid=$(id -u) + umask=$(umask) + if test $uid -lt 500; then + umask=022 + fi + MODE_X=$(( ( ~ $umask ) & 0777 )) +else + MODE_X=$MODE +fi +MODE_R=$(( 0666 & $MODE_X )) +MODE_X=$(echo "ibase=10; obase=8; $MODE_X" | bc ) +MODE_R=$(echo "ibase=10; obase=8; $MODE_R" | bc ) +echo MODE_X: $MODE_X +echo MODE_R: $MODE_R AC_PATH_PROG(PS,ps, UNKNOWN_PS) if test "$PS" = "UNKNOWN_PS" ; then