Skip to content

Commit 7de4894

Browse files
committed
Change the install script so that the version is read from the VERSION file
1 parent 55b63bd commit 7de4894

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

install_kraken2.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Copyright 2013-2023, Derrick Wood <[email protected]>
44
#
55
# This file is part of the Kraken 2 taxonomic sequence classification system.
66

77
set -e
88

9-
VERSION="2.1.3"
9+
SCRIPT="$(realpath "$0")"
10+
ROOT=$(dirname "$SCRIPT")
11+
VERSION="$(cat "$ROOT/VERSION")"
12+
13+
cd "$ROOT"
1014

1115
if [ -z "$1" ] || [ -n "$2" ]
1216
then
13-
echo "Usage: $(basename $0) KRAKEN2_DIR"
17+
echo "Usage: $(basename "$SCRIPT") KRAKEN2_DIR"
1418
exit 64
1519
fi
1620

@@ -23,19 +27,21 @@ fi
2327

2428
# Perl cmd used to canonicalize dirname - "readlink -f" doesn't work
2529
# on OS X.
26-
export KRAKEN2_DIR=$(perl -MCwd=abs_path -le 'print abs_path(shift)' "$1")
30+
export KRAKEN2_DIR
31+
KRAKEN2_DIR=$(perl -MCwd=abs_path -le 'print abs_path(shift)' "$1")
2732

2833
mkdir -p "$KRAKEN2_DIR"
2934
make -C src install
3035
for file in scripts/*
3136
do
37+
destination_file="$KRAKEN2_DIR/$(basename "$file")"
3238
perl -pl -e 'BEGIN { while (@ARGV) { $_ = shift; ($k,$v) = split /=/, $_, 2; $H{$k} = $v } }'\
3339
-e 's/#####=(\w+)=#####/$H{$1}/g' \
3440
"KRAKEN2_DIR=$KRAKEN2_DIR" "VERSION=$VERSION" \
35-
< "$file" > "$KRAKEN2_DIR/$(basename $file)"
41+
< "$file" > "$destination_file"
3642
if [ -x "$file" ]
3743
then
38-
chmod +x "$KRAKEN2_DIR/$(basename $file)"
44+
chmod +x "$destination_file"
3945
fi
4046
done
4147

@@ -44,7 +50,7 @@ echo "Kraken 2 installation complete."
4450
echo
4551
echo "To make things easier for you, you may want to copy/symlink the following"
4652
echo "files into a directory in your PATH:"
47-
for file in $KRAKEN2_DIR/kraken2*
53+
for file in "$KRAKEN2_DIR"/kraken2*
4854
do
4955
if [ -x "$file" ]
5056
then

0 commit comments

Comments
 (0)