forked from 3Tissue/MRtrix3Tissue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_mrtrix
executable file
·117 lines (95 loc) · 4.08 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-2022 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
MRtrix3Tissue, 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 MRtrix3Tissue executables and mrtrix3 library...
set -e
mkdir -p _package/MRtrix3Tissue/
cp -r bin/ _package/MRtrix3Tissue/
cp -r lib/ _package/MRtrix3Tissue/
cp -r share/ _package/MRtrix3Tissue/
[ ${1:-"x"} == "-standalone" ] && (
cat > _package/MRtrix3Tissue/launcher <<"EOF"
#!/bin/bash
PREFIX="$(dirname $0)/.."
COMMAND="$(basename $0)"
"$PREFIX"/lib/ld-*.so* "$PREFIX"/exe/"$COMMAND" "$@"
EOF
chmod a+x _package/MRtrix3Tissue/launcher
mkdir -p _package/MRtrix3Tissue/exe
(
cd _package/MRtrix3Tissue/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/MRtrix3Tissue/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/MRtrix3Tissue/lib/
cp -r $QTPLUGDIR _package/MRtrix3Tissue/lib/
cat > _package/MRtrix3Tissue/lib/qt.conf << EOF
[Paths]
Prefix = .
EOF
)
)
) && cat <<EOF
You can now copy the folder _package/MRtrix3Tissue over to your target systems.
For example packing it up using:
$ cd _package
$ tar cfz MRtrix3Tissue.tar.gz MRtrix3Tissue
On your target system, unpack MRtrix3Tissue.tar.gz using:
$ tar xfz MRtrix3Tissue.tar.gz
You should also add the MRtrix3Tissue/bin to your PATH to finalise the installation.
EOF