-
Notifications
You must be signed in to change notification settings - Fork 181
/
package_mrtrix
executable file
·117 lines (95 loc) · 3.95 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
115
116
#!/bin/bash
# Copyright (c) 2008-2024 the MRtrix3 contributors.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Covered Software is provided under this License on an "as is"
# basis, without warranty of any kind, either expressed, implied, or
# statutory, including, without limitation, warranties that the
# Covered Software is free of defects, merchantable, fit for a
# particular purpose or non-infringing.
# See the Mozilla Public License v. 2.0 for more details.
#
# For more details, see http://www.mrtrix.org/.
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:
[[ -z $QTPLUGDIR ]] && QTPLUGDIR=$(strings $QTCORE | sed -n 's/qt_plugpath=\(.*\)$/\1/p')
[[ ! -d "$QTPLUGDIR" ]] && echo "could not find Qt plugins in $QTPLUGDIR, try 'export QTPLUGDIR=/usr/lib/qt/plugins/; package_mrtrix -standalone'" && exit 1
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