Skip to content

icy-2.5.2: imageanalysis tool - add to repo #325

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
163 changes: 163 additions & 0 deletions icy-2.5.2-0.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#! /usr/bin/bash

set -eu

# ---------------------------------------------------------------- Preamble

PKG=icy
VERSION=2.5.2
BUILD=0

PREFIX=/pkg/icy-$VERSION-$BUILD
if [ -n "${TESTING:-}" ]; then PREFIX=/scratch/local2/$PKG-$VERSION-$BUILD ; fi

mkdir -p $PREFIX/bin
cd $PREFIX


cat > profile <<- EOF
PATH=$PREFIX/bin:\$PATH
if [ -d $PREFIX/.compatlibs ]; then export LD_LIBRARY_PATH=$PREFIX/.compatlibs\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH} ; fi
EOF

# ----------------------------------------------------------------- Install

mkdir -p app
cd app

# orig: https://icy.bioimageanalysis.org/wp-content/uploads/2024/02/icy_2.5.2.tar.gz
BEEHIVE=https://beehive.molgen.mpg.de/f94861acd15245b01b57e24fc36c39a4/icy_2.5.2.tar.gz
wget -O- -nv $BEEHIVE | tar -xz --strip-components=2 --exclude='._*' --exclude='.DS*' --no-xattrs -f- 2>/dev/null

# dump the 'updating' start wrapper
mv icy icy.dist; chmod -c -x icy.dist


# the vtk-libs seem a bit weird, so straighten out a bit ...
rm -vrf lib/unix32
cd lib/unix64
rm -vf vtk.zip # it is also unpacked here ...
mkdir vtk # this is needed
mv lib* vtk
cd vtk
# restore symlinks ... (who ever has created this archive, ...)
echo '# running ldconfig -xnv .'
ldconfig -xnv .


# ---------------------------------------------------------- Create startup

cd $PREFIX
sed -e "s,@PREFIX@,$PREFIX,g" > bin/icy <<- 'EOF'
#! /usr/bin/bash

set -eu

# ----------------------------------------------- Make libraries accessible

# Some vtk plugins refer to libawt.so
if [ -z "${LIBAWTPATH:-}" ]; then
LIBAWTPATH=$(java -XshowSettings:properties --version 2>&1 | grep sun.boot.library.path)
LIBAWTPATH=${LIBAWTPATH#*sun.boot.library.path = }
fi

test -e "$LIBAWTPATH/libawt.so" || LIBAWTPATH= # then not, at least we gave it a try ...

LD_LIBRARY_PATH=@PREFIX@/lib/unix64/vtk${LIBAWTPATH:+:$LIBAWTPATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
# echo $LD_LIBRARY_PATH | tr ':' '\n' | nl

export LD_LIBRARY_PATH

# --------------------------------------------- Prepare local icy directory

mkdir -pv $HOME/.local/Icy

cd $HOME/.local/Icy

# ----------------------------------------------- Handle possible leftovers

if [ $# -gt 0 ]; then
if [ $1 = clean ]; then
rm -vf icy.run
shift
fi
fi

if [ -e icy.run ]; then

cat << EOM
---------------------------------------------------------------------
Note:

EOM

cat icy.run

cat << EOM

So it may be already running somewhere else, and you need to
close the application before you can proceed.

If icy or the machine crashed, you may need to remove.
$PWD/icy.run

#> rm $PWD/icy.run

or start icy with

#> icy clean

---------------------------------------------------------------------
EOM

exit

fi

echo " icy started on host '$(hostname -s)', on $(date +%c)." >> icy.run


# ---------------------------------------------------- Prepare fuse overlay

# upper and workdir must be on the same file system (hmm, on NFS ...)

UPPER=icy_user
WORK=.fuse_transient
LOWER=@PREFIX@
MOUNTPOINT=icy_fmount

mkdir -pv $UPPER $MOUNTPOINT $WORK

if [ "$(stat -c %D $UPPER)" = "$(stat -c %D $MOUNTPOINT)" ] ; then
fuse-overlayfs \
-o lowerdir=$LOWER \
-o workdir=$WORK \
-o squash_to_uid=$UID \
-o squash_to_gid=$(id -g $UID) \
-o noacl \
-o upperdir=$UPPER \
$MOUNTPOINT
else
if [ ! -e $MOUNTPOINT/app/icy.jar ]; then
echo "# ERROR: Something is wrong, can not find 'icy.jar'."
exit 1
fi
fi

# --------------------------------------------------------- Finally run icy

cd icy_fmount/app
java -jar icy.jar "$@"

# ----------------------------------------------------------------- Tidy up

cd $HOME/.local/Icy
sleep 1
fusermount -u $MOUNTPOINT
rm icy.run || echo "# ERROR: Something is wrong, can not find 'icy.run' in $PWD."

EOF

chmod +x -c bin/icy

exit 0