fpp/compiler/install
2025-11-11 08:54:19 -08:00

101 lines
2.3 KiB
Bash
Executable File

#!/bin/sh -e
# ----------------------------------------------------------------------
# FPP installer
# ----------------------------------------------------------------------
# To select a version of java other than the system default,
# set the environment variable
# FPP_JAVA_HOME
#
# To pass flags to sbt, set the environment variable
# FPP_SBT_FLAGS
#
# To pass flags to java, set the environment variable
# FPP_JAVA_FLAGS
# ----------------------------------------------------------------------
# Check arguments
if test $# -gt 1
then
echo 'usage: install dest-dir' 1>&2
echo ' install' 1>&2
exit 1
fi
# Check for output directory
if test -n "$1"
then
# Convert to absolute path as the `cd` to 'compiler' will break relative paths passed in
mkdir -p "$1"
dest=`cd $1; pwd`
else
dest=bin
fi
# Go to the working directory, so that relative paths work as expected
wd=`dirname $0`
cd $wd
# Pull in the version info
. ../version.sh
scala_version="3.1.2"
if test -n "$FPP_JAVA_HOME"
then
sbt="sbt --java-home $FPP_JAVA_HOME $FPP_SBT_FLAGS"
java="$FPP_JAVA_HOME/bin/java $FPP_JAVA_FLAGS"
else
sbt="sbt $FPP_SBT_FLAGS"
java=java $FPP_JAVA_FLAGS
fi
echo "sbt command: $sbt"
echo "java command: $java"
dir=`dirname $dest`
dir=`cd $dir; pwd`
base=`basename $dest`
dest=$dir/$base
tools=`cat ./tools.txt`
if git describe --tags --always > /dev/null 2>&1
then
# Ask git for the current version, if it is available
version=`git describe --tags --always`
else
# Otherwise use the hard-coded version
version="$VERSION"
fi
util=lib/src/main/scala/util
echo "Updating version to $version"
sed -i.update.bak -e "s/val v = .*/val v = \"$version\"/" \
$util/Version.scala
echo "Building jar files"
cmd="$sbt assembly"
echo $cmd
$cmd
echo "Restoring Version.scala"
sed -i.restore.bak -e "s/val v = .*/val v = \"[unknown version]\"/" \
$util/Version.scala
mkdir -p $dest
echo "Installing fpp at $dest"
jar=`find tools/fpp -name "*$name*assembly*.jar" | grep "target/scala-$scala_version"`
echo " $jar"
cp $jar $dest/fpp.jar
echo '#!/bin/sh
'$java' -jar "`dirname $0`/'fpp'.jar" "$@"' > $dest/fpp
chmod +x $dest/fpp
echo "Installing tools at $dest"
for tool in $tools
do
echo '#!/bin/sh
'$java' -jar "`dirname $0`/'fpp'.jar" '$tool' "$@"' > $dest/fpp-$tool
chmod +x $dest/fpp-$tool
done