dist.src/install.sh

Sat, 20 Jan 2024 15:47:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 20 Jan 2024 15:47:39 +0100
changeset 105
4b3e655339cb
parent 50
d26da280c934
child 111
cb128bae1161
permissions
-rwxr-xr-x

improve toolchain detection

relates to #347

#!/bin/sh

PREFIX=/usr/local

# help text
printhelp()
{
	echo "Usage: $0 [PREFIX=<path>]"
	echo
	echo "Default PREFIX: /usr/local"
}

# error function
exit_on_error()
{
  echo "$1"
  exit 1
}

#
# parse arguments 
#
for arg in "$@"
do
    case "$arg" in
		"PREFIX="*)         PREFIX=${arg#PREFIX=} ;;
		"--help"*)          printhelp; exit 1 ;;
		"-"*) echo "unknown option: $arg"; exit 1 ;;
	esac
done

#
# create install dir
#
echo "mkdir -p $PREFIX/lib/uwproj $PREFIX/bin"
mkdir -p "$PREFIX/lib/uwproj" "$PREFIX/bin" \
  || exit_on_error "Creating install directory failed."

#
# install the JAR file
#
echo "cp ../target/uwproj-${project.version}-jar-with-dependencies.jar $PREFIX/lib/uwproj/uwproj-${project.version}.jar"
cp "../target/uwproj-${project.version}-jar-with-dependencies.jar" "$PREFIX/lib/uwproj/uwproj-${project.version}.jar" \
  || exit_on_error "Installing JAR file failed."

#
# create a run script in the bin dir
#
echo "cp bin/uwproj $PREFIX/bin"
sed "s:%%PREFIX%%:$PREFIX:g" "bin/uwproj" > "$PREFIX/bin/uwproj" \
  || exit_on_error "Creating run script failed."

echo "chmod 0555 $PREFIX/bin/uwproj"
chmod 0755 "$PREFIX/bin/uwproj" \
  || exit_on_error "Changing permissions for run script failed."

echo
echo "uwproj has been successfully installed."

mercurial