-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_app
More file actions
169 lines (146 loc) · 4.54 KB
/
Copy pathsetup_app
File metadata and controls
169 lines (146 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#Script to set up a directory and modulefile
#for a custom software installation
#usage info
function printUsage {
echo "setup_app: Setup directory/modulefile for custom software installation"
echo "Usage: setup_app package version"
echo
echo "Options:"
#echo " --user Set up for personal (home directory) installation"
echo " --base dir,--base=dir Specify other directory for installation"
echo " --help,-h Print this usage message"
echo
echo "Examples:"
echo " setup_app R 4.0.2-foss-2020b #home directory install"
echo " setup_app --base=/projects/myproject R 4.0.2-foss-2020b #install to /projects/myproject"
}
#e.g., tinkercliffs-rome
sysdir=$( basename $EASYBUILD_INSTALLPATH_MODULES )
#defaults for home-based installations
appbase="$HOME/apps/${sysdir}"
modbase="$HOME/easybuild/modules/${sysdir}/all"
#parse input options
app=""
ver=""
base=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--help)
printUsage
exit
;;
-h)
printUsage
exit
;;
--user)
echo "Ignoring deprecated option --user (home directory install is now the default)..."
shift
;;
--base)
base=$2
shift 2
;;
--base=*)
base=${key#*=}
shift
;;
-*)
echo "ERROR: Unrecognized flag: $key"
echo "Printing usage information..."
printUsage
exit 1
;;
*) #process positional arguments: app first, then ver
[[ -z $app ]] && app=$1 || ver=$1
shift
;;
esac
done
#if they specified --base, set the directories
if [[ ! -z $base ]]; then
appbase="${base}/apps/${sysdir}"
modbase="${base}/modules/${sysdir}/all" #No real reason to include "easybuild" in directory path
fi
#if the user didn't provide an app and a version, print usage info and exit
if [[ -z $app || -z $ver ]]; then
printUsage
exit 1
else
#slashes in version numbers can cause problems, so replace them with -
ver=$( echo $ver | sed 's|/|-|g' )
appdir="${appbase}/${app}/${ver}"
moddir="${modbase}/${app}"
modfl="${moddir}/${ver}.lua"
#get user confirmation before we change anything
read -p "Create directories $appdir and $moddir? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo
#create directories
mkdir -p $appdir
mkdir -p $moddir
cat >$modfl <<EOF
whatis("Name: $app")
whatis("Version: $ver")
whatis("Description: SOFTWAREDESCRIPTION")
whatis("URL: SOFTWAREURL")
help([[
SOFTWAREDESCRIPTION
Define Environment Variables:
\$EBROOTSOFTWARE - root
\$SOFTWARE_DIR - root
\$SOFTWARE_BIN - binaries
\$SOFTWARE_INC - includes
\$SOFTWARE_LIB - libraries
\$SOFTWARE_LIB64 - libraries
Prepend Environment Variables:
PATH += \$SOFTWARE_BIN
MANPATH += \$SOFTWARE_DIR/share/man
INCLUDE += \$SOFTWARE_INC
LD_LIBRARY_PATH += \$SOFTWARE_LIB
LD_LIBRARY_PATH += \$SOFTWARE_LIB64
]])
setenv("EBROOTSOFTWARE", "$appdir")
setenv("SOFTWARE_DIR", "$appdir")
setenv("SOFTWARE_BIN", "$appdir/bin")
setenv("SOFTWARE_INC", "$appdir/include")
setenv("SOFTWARE_LIB", "$appdir/lib64")
prepend_path("PATH", "$appdir/bin")
prepend_path("MANPATH", "$appdir/share/man")
prepend_path("INCLUDE", "$appdir/include")
prepend_path("LD_LIBRARY_PATH", "$appdir/lib")
prepend_path("LD_LIBRARY_PATH", "$appdir/lib64")
load("foss/2024a")
EOF
#try to guess a variable name ("ju l-i/a" -> "JULIA")
varnm=$( echo ${app^^} | sed 's/[- \/]//g' )
#set variable name in the modulefile
sed -i "s/SOFTWARE/$varnm/g" $modfl
echo "Done. To finish your build:"
echo " 1. Install your app in $appdir/"
echo " - Document the installation so we know how you did it"
echo " 2. Edit the modulefile in $modfl"
echo " - Set or remove modules to load in the load() line"
echo " - Edit description and URL"
echo " - Check the variable names"
echo " - Edit paths (some packages don't have, e.g., an include/)"
#if they specified --base, print an additional message
if [[ ! -z $base ]]; then
echo
echo "Note: You specified a non-standard directory. You will need to add"
echo "${modbase}"
echo "to MODULEPATH to be able to load the module."
echo "This can be done by adding, e.g.,"
echo " export MODULEPATH=\"${modbase}:\$MODULEPATH\""
echo "to your ~/.bashrc"
fi
echo
echo "Note: You may need to refresh the cache, e.g.,"
echo " module --ignore_cache spider $app"
echo "to find the module the first time."
else
echo
fi
fi