-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopulate_fiji.sh
executable file
·204 lines (178 loc) · 7.25 KB
/
populate_fiji.sh
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/sh
#
# populate_fiji.sh
#
# This script generates a local Fiji.app with SciView installed.
# -- Functions --
left() { echo "${1%$2*}"; }
right() { echo "${1##*$2}"; }
mid() { right "$(left "$1" "$3")" "$2"; }
die() {
echo "$@" 1>&2
exit 1
}
# Copies the given Maven coordinate to the specified output directory.
install() {
(set -x; mvn dependency:copy -Dartifact="$1" -DoutputDirectory="$2" > /dev/null) ||
die "Install failed"
}
# Copies the given Maven coordinate to the specified output directory, keeping the groupId
installWithGroupId() {
(set -x; mvn dependency:copy -Dartifact="$1" -DoutputDirectory="$2" -Dmdep.prependGroupId=true > /dev/null) ||
die "Install failed"
}
# Deletes the natives JAR with the given artifactId and classifier.
deleteNative() {
(set -x; rm -f $FijiDirectory/jars/$1-[0-9]*-$2.jar $FijiDirectory/jars/*/$1-[0-9]*-$2.jar) ||
die "Delete failed"
}
# Deletes all natives JARs with the given artifactId.
deleteNatives() {
(set -x; rm -f $FijiDirectory/jars/$1-[0-9]*-natives-*.jar $FijiDirectory/jars/*/$1-[0-9]*-natives-*.jar) ||
die "Delete failed"
}
# -- Check if we have a path given, in that case we do not download a new Fiji, but use the path given --
if [ -z "$1" ]
then
echo "--> Installing into pristine Fiji installation"
echo "--> If you want to install into a pre-existing Fiji installation, run as"
echo " $0 path/to/Fiji.app"
# -- Determine correct ImageJ launcher executable --
case "$(uname -s),$(uname -m)" in
Linux,x86_64) launcher=ImageJ-linux64 ;;
Linux,*) launcher=ImageJ-linux32 ;;
Darwin,*) launcher=Contents/MacOS/ImageJ-macosx ;;
MING*,*) launcher=ImageJ-win32.exe ;;
*) die "Unknown platform" ;;
esac
# -- Roll out a fresh Fiji --
if [ ! -f fiji-nojre.zip ]
then
echo
echo "--> Downloading Fiji"
curl --insecure -L -O https://downloads.imagej.net/fiji/latest/fiji-nojre.zip ||
die "Could not download Fiji"
fi
echo "--> Unpacking Fiji"
rm -rf Fiji.app
unzip fiji-nojre.zip || die "Could not unpack Fiji"
echo
echo "--> Updating Fiji"
Fiji.app/$launcher --update update-force-pristine
FijiDirectory=Fiji.app
else
echo "--> Installing into Fiji installation at $1"
FijiDirectory=$1
fi
echo
echo "--> Copying dependencies into Fiji installation"
#(set -x; mvn -Dimagej.app.directory=$FijiDirectory)
(set -x; mvn scijava:populate-app -Dscijava.app.directory=$FijiDirectory)
echo "--> Removing slf4j bindings"
(set -x; rm -f $FijiDirectory/jars/slf4j-simple-*.jar)
echo "--> Removing old joml"
(set -x; rm -f $FijiDirectory/jars/joml-1.9.24.jar)
echo "--> Fetching jide-oss"
(set -x; cx $FijiDirectory/jars && { curl --insecure -0 -L https://github.com/morphonets/SNT/raw/master/jars/jide-oss-3.7.7.jar ; cd -; } )
echo "--> Fetching hIPNAT"
(set -x; cx $FijiDirectory/jars && { curl --insecure -0 -L https://github.com/tferr/hIPNAT/releases/download/1.1.0/hIPNAT_-1.1.0.jar ; cd -; } )
## -- Put back jar/gluegen-rt and jar/jogl-all --
#echo
#echo "--> Reinstalling gluegen-rt, jogl-all, jocl, jinput, and ffmpeg"
#gluegenJar=$(echo $FijiDirectory/jars/gluegen-rt-main-*.jar)
#gluegenVersion=$(mid "$gluegenJar" "-" ".jar")
#install "org.jogamp.gluegen:gluegen-rt:$gluegenVersion" $FijiDirectory/jars
#
#joglJar=$(echo $FijiDirectory/jars/jogl-all-main-*.jar)
#joglVersion=$(mid "$joglJar" "-" ".jar")
#install "org.jogamp.jogl:jogl-all:$joglVersion" $FijiDirectory/jars
#
#joclGAV=$(mvn dependency:tree | grep jocl | awk -e '{print $NF}' | cut -d: -f1-4 | sed 's/:jar//g')
#installWithGroupId "$joclGAV" $FijiDirectory/jars
#
#jinputGAV=$(mvn dependency:tree | grep jinput | head -n1 | awk -e '{print $NF}' | cut -d: -f1-4 | sed 's/:jar//g' | sed 's/:compile//g')
#install "$jinputGAV" $FijiDirectory/jars
#
#ffmpegGAV=$(mvn dependency:tree | grep 'ffmpeg:jar' | head -n1 | awk -e '{print $NF}' | cut -d: -f1-4 | sed 's/:jar//g' | sed 's/:compile//g')
#installWithGroupId "$ffmpegGAV" $FijiDirectory/jars
#installWithGroupId "$ffmpegGAV:jar:windows-x86_64" $FijiDirectory/jars/win64
#installWithGroupId "$ffmpegGAV:jar:linux-x86_64" $FijiDirectory/jars/linux64
#installWithGroupId "$ffmpegGAV:jar:macosx-x86_64" $FijiDirectory/jars/macosx
#
## -- Get the latest imagej-launcher --
#
#echo
#echo "--> Getting launchers for all platforms"
#wget "https://maven.scijava.org/service/local/repositories/releases/content/net/imagej/imagej-launcher/5.0.2/imagej-launcher-5.0.2-linux64.exe" -O $FijiDirectory/ImageJ-linux64
#chmod +x $FijiDirectory/ImageJ-linux64
#wget "https://maven.scijava.org/service/local/repositories/releases/content/net/imagej/imagej-launcher/5.0.2/imagej-launcher-5.0.2-macosx.exe" -O $FijiDirectory/Contents/MacOS/ImageJ-macosx
#chmod +x $FijiDirectory/Contents/MacOS/ImageJ-macosx
#wget "https://maven.scijava.org/service/local/repositories/releases/content/net/imagej/imagej-launcher/5.0.2/imagej-launcher-5.0.2-win32.exe" -O $FijiDirectory/ImageJ-win32.exe
#chmod +x $FijiDirectory/ImageJ-win32.exe
#wget "https://maven.scijava.org/service/local/repositories/releases/content/net/imagej/imagej-launcher/5.0.2/imagej-launcher-5.0.2-win64.exe" -O $FijiDirectory/ImageJ-win64.exe
#chmod +x $FijiDirectory/ImageJ-win64.exe
#
#ls $FijiDirectory
#
## -- Get the list of native libraries --
#
## [NB] dependency:list emits G:A:P:C:V but dependency:copy needs G:A:V:P:C.
#echo
#echo "--> Extracting list of native dependencies"
#natives=$(mvn -B dependency:list |
# grep natives |
# sed -e 's/^\[INFO\] *\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):.*/\1:\2:\5:\3:\4/' |
# grep -v -- '-\(android\|armv6\|solaris\)' |
# sort)
#for gavpc in $natives
#do
# gavp=$(left "$gavpc" ':')
# gav=$(left "$gavp" ':')
# ga=$(left "$gav" ':')
# g=$(left "$ga" ':')
# a=$(right "$ga" ':')
# v=$(right "$gav" ':')
# p=$(right "$gavp" ':')
# c=$(right "$gavpc" ':')
# echo
# echo "[$a-$v-$c]"
# case "$g" in
# org.lwjgl|graphics.scenery)
# deleteNatives "$a"
# # [NB] Install all architectures manually; only one is a dependency.
# install "$gavp:natives-windows" $FijiDirectory/jars/win64
# install "$gavp:natives-macos" $FijiDirectory/jars/macosx
# install "$gavp:natives-linux" $FijiDirectory/jars/linux64
# ;;
# *)
# deleteNative "$a" "$c"
# case "$c" in
# natives-win*-i586) continue ;;
# natives-win*) platform=win64 ;;
# natives-linux*-i586) continue ;;
# natives-linux*) platform=linux64 ;;
# natives-osx|natives-mac*) platform=macosx ;;
# natives-all*) platform="" ;;
# *) die "Unsupported platform: $c" ;;
# esac
# install "$gavpc" "$FijiDirectory/jars/$platform"
# ;;
# esac
#done
# Move RadialSymmetryLocalization to plugins, and add an underscore
mv $FijiDirectory/jars/RadialSymmetryLocalization* $FijiDirectory/plugins
for j in $FijiDirectory/plugins/RadialSymmetryLocalization-*; do mv -- "$j" "${j%.jar}_.jar"; done
ls $FijiDirectory/jars
ls $FijiDirectory/plugins
# -- Now that we populated fiji, let's double check that it works --
echo
echo "--> Testing installation with command: sc.iview.commands.help.About"
OUT_TEST=$(Fiji.app/$launcher --headless --run sc.iview.commands.help.About)
echo $OUT_TEST
if [ -z "$OUT_TEST" ]
then
echo "Test failed"
exit 1
else
echo "Test passed"
fi