#!/bin/sh -e # ---------------------------------------------------------------------- # FPP installer # ---------------------------------------------------------------------- # To pass flags to sbt, set the environment variable # FPP_SBT_FLAGS # # To override the java command and/or set java flags, set the # environment variable # FPP_INSTALL_JAVA # ---------------------------------------------------------------------- # 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_INSTALL_JAVA" then java=$FPP_INSTALL_JAVA else java=java fi 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 $FPP_SBT_FLAGS 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