forked from 3Tissue/MRtrix3Tissue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_mrtrix
executable file
·115 lines (92 loc) · 4.1 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
108
109
110
111
112
113
114
#!/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 release/bin/ _package/mrtrix3/
cp -r scripts _package/mrtrix3/
mkdir -p _package/mrtrix3/lib
cp release/lib/libmrtrix* _package/mrtrix3/lib/ || echo "error: no shared library found"
[ ${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 -p _package/mrtrix3/bin
(
cd _package/mrtrix3/bin
for n in ../exe/*; do ln -s ../launcher $(basename $n); done
)
echo - collating dependent system libraries...
echo `pwd`
LIBS=$(for n in release/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 "warning: not all executables have dynamic libraries. Possibly skipping dependent libraries for some commands. This is expected if you built with -static";
else
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=$(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 and mrtrix3/scripts folders to your PATH to finalise
the installation.
EOF