Skip to content

Commit

Permalink
Support for user defined install MODE
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Jul 29, 2022
1 parent bb6bb9c commit 459c510
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -707,6 +709,7 @@ REDIRECT
EXPORT_MODULE
AUTO_SWAP
LMOD_CONFIG_DIR
MODE
EXACT_MATCH
HIDDEN_ITALIC
DYNAMIC_SPIDER_CACHE
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 459c510

Please sign in to comment.