forked from 3Tissue/MRtrix3Tissue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_mrtrix
executable file
·100 lines (80 loc) · 3.15 KB
/
package_mrtrix
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
#!/bin/bash
cat <<EOF
This script collates all the executables and runtime dependencies needed for
MRtrix3, and creates a GZ compressed archive suitable for deployment on other
systems. It takes all executables found in the bin/ folder and the MRtrix3
library from the lib/ folder. It is up to the user to ./configure and ./build
the software first.
Stand-alone installation on systems without necessary dependencies
================================================================================
If the -standalone option is also supplied, this script will also attempt to
collate system libraries from the current system, allowing you to install onto
a target system without the necessary dependencies. This is particularly useful
for installation on HPC systems and other centrally managed systems that often
run older distributions, and where users have little or no control over the
installation of required packages.
$ ./configure
$ ./build
$ ./package_mrtrix [-standalone]
EOF
echo -n "Press enter to proceed (or Ctrl-C to abort)..."
read
(
echo - collating MRtrix3 executables and library...
set -e
mkdir -p _package/mrtrix3/
cp -r bin/ _package/mrtrix3/
cp -r lib/ _package/mrtrix3/
cp -r share/ _package/mrtrix3/
[ ${1:-"x"} == "-standalone" ] && (
cat > _package/mrtrix3/launcher <<"EOF"
#!/bin/bash
PREFIX="$(dirname $0)/.."
COMMAND="$(basename $0)"
"$PREFIX"/lib/ld-*.so* "$PREFIX"/exe/"$COMMAND" "$@"
EOF
chmod a+x _package/mrtrix3/launcher
mkdir -p _package/mrtrix3/exe
(
cd _package/mrtrix3/bin
for n in *; do
file $n | grep -q script || (
mv $n ../exe
ln -s ../launcher $n
)
done
)
echo - collating dependent system libraries...
LIBS=$(for n in bin/*; do ldd $n; done | sed 's/(.*)$//g' | sed 's/^.*=>//g' | sort | uniq | grep -v 'mrtrix\|vdso\|libGL.so\|libEGL.so\|nvidia\|fglrx' | xargs)
echo ' libraries identified:'
for n in $LIBS; do
if [ -e $n ]; then
echo ' '$n;
cp $n _package/mrtrix3/lib/
fi
done
QTCORE=$(for n in $LIBS; do echo $n; done | grep 'libQt.*Core')
[[ $QTCORE ]] && ( # sort out Qt:
QTPLUGDIR=/usr/lib/qt/plugins/ #$(strings $QTCORE | sed -n 's/qt_plugpath=\(.*\)$/\1/p')
echo ' Qt plugins in' $QTPLUGDIR
LDD_PATTERN='^[[:space:]]*[[:graph:]]*[[:space:]]*=>[[:space:]]*\([[:graph:]]*\)[[:space:]]*([[:graph:]]*)$'
QTLIBS=$(find $QTPLUGDIR -name '*.so' -print0 | xargs -n 1 -0 ldd | sed -n 's/'"$LDD_PATTERN"'/\1/p' | sort | uniq | grep -v 'libGL.so\|libEGL.so\|nvidia\|fglrx' )
echo ' additional libraries required for Qt:'
for n in $QTLIBS; do echo ' '$n; done
cp $QTLIBS _package/mrtrix3/lib/
cp -r $QTPLUGDIR _package/mrtrix3/lib/
cat > _package/mrtrix3/lib/qt.conf << EOF
[Paths]
Prefix = .
EOF
)
)
) && cat <<EOF
You can now copy the folder _package/mrtrix3 over to your target systems.
For example packing it up using:
$ cd _package
$ tar cfz mrtrix3.tar.gz mrtrix3
On your target system, unpack mrtrix3.tar.gz using:
$ tar xfz mrtrix3.tar.gz
You should also add the mrtrix3/bin to your PATH to finalise the installation.
EOF