forked from MRtrix3/mrtrix3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_mrtrix
executable file
·108 lines (84 loc) · 3.76 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
100
101
102
103
104
105
106
107
#!/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.
WARNING
================================================================================
By default, configure will generate a configuration suitable for building
executables to run on your native CPU. This will result in code that may not
run on other (older) systems with different instruction sets, resulting in
'illegal instruction' runtime errors. If you intend to run MRtrix3 on a variety
of different systems with a range of CPUs, it is safest to specify a generic
architecture when building MRtrix3, before running this script. For example,
assuming a 64-bit build is required:
$ ARCH='x86-64' ./configure
$ ./build
$ ./package_mrtrix [-standalone]
For a 32-bit build, ARCH='i686' or similar should suffice.
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/
mkdir -p _package/mrtrix3/lib
cp lib/libmrtrix* _package/mrtrix3/lib/
[ ${1:-"x"} == "-standalone" ] && (
mv _package/mrtrix3/{bin,exe}
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 _package/mrtrix3/bin
(
cd _package/mrtrix3/bin
for n in ../exe/*; do ln -s ../launcher $(basename $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 echo ' '$n; done
cp $LIBS _package/mrtrix3/lib/
QTCORE=$(for n in $LIBS; do echo $n; done | grep 'libQt.*Core')
[[ $QTCORE ]] && ( # sort out Qt:
QTPLUGDIR=$(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 folder to your PATH to finalise the
installation.
EOF