-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkDebMedModule.sh
executable file
·62 lines (52 loc) · 1.67 KB
/
mkDebMedModule.sh
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
#!/bin/bash -e
ml singularity
APP=$1
if [ -z "$DEBVERSION" ]
then
printf 'Error: $DEBVERSION is not set and exported\n'
exit 1
fi
printf "==== $APP ====\n"
MODROOT=/bucket/BioinfoUgrp/DebianMed/$DEBVERSION
DEBMEDIMAGE=$MODROOT/DebianMed_$DEBVERSION.sif
APPDIR=$MODROOT/modules/$APP
VER=$(singularity exec $DEBMEDIMAGE dpkg-query -W -f='${Version}' $APP | perl -pe 's/^.*?://')
PROGLIST=$($DEBMEDIMAGE dpkg -L $APP | grep -v -e 'package diverts' -e 'diverted by' | grep /bin/) || true
if [ -z "$PROGLIST" ]
then
printf "Module not created: package $APP has no executables\n"
exit 0
fi
printf " creating module in $APPDIR/$VER\n"
mkdir -p $APPDIR/$VER/bin
cd $APPDIR/$VER
for prog in $(basename -a $PROGLIST)
do
cat <<__END__ > bin/$prog
#!/bin/sh
LC_ALL=C singularity exec $DEBMEDIMAGE $prog "\$@"
__END__
chmod 775 bin/$prog
done
mkdir -p $MODROOT/modulefiles/$APP
cd $MODROOT/modulefiles/$APP
printf " creating modulefile $VER in $MODROOT/modulefiles/$APP\n"
cat <<__END__ > $VER.lua
-- Default settings
local modroot = "$MODROOT"
local appname = myModuleName()
local appversion = myModuleVersion()
local apphome = pathJoin(modroot, "modules", "$APP", appversion)
-- Package information
whatis("Name: "..appname)
whatis("Version: "..appversion)
whatis("URL: ".."https://github.com/oist/BioinfoUgrp")
whatis("Category: ".." bioinformatics")
whatis("Keywords: ".." Bioinformatics, Debian")
whatis("Description: ".." Module automatically generated by the Bioinfo user group.")
help([[This module runs from Singularity image of Debian Med.
Please contact the Bioinfo user group for details.]])
-- Package settings
depends_on("singularity")
prepend_path("PATH", apphome.."/bin")
__END__