SimplePanoramaViewer/utility.sh

99 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
print_help()
{
echo "SimplePanoramaViewer utility script"
echo
echo "Use:"
echo " bash utility.sh OPTION [PATH_TO_INSTALL_DIR]"
echo
echo "Options:"
echo " -i, --install Install SimplePanoramaViewer in PATH_TO_INSTALL_DIR"
echo " -u, --uninstall Uninstall SimplePanoramaViewer from PATH_TO_INSTALL_DIR"
echo " -p, --package Generate a package for SimplePanoramaViewer"
}
check_dir()
{
if [ -z "$1" ]; then
echo "You need to pass a directory"
exit
fi
}
install()
{
DESTDIR=$1
check_dir "$DESTDIR"
if [ -z "$2" ]; then
PREFIX=$DESTDIR
else
PREFIX="$2"
DESTDIR=$DESTDIR$PREFIX
echo $DESTDIR
fi
mkdir -p "$DESTDIR/bin/"
mkdir -p "$DESTDIR/share/applications"
cp install/SimplePanoramaViewer.desktop "$DESTDIR/share/applications"
cp target/release/simple_panorama_viewer "$DESTDIR/bin"
chmod a+x "$DESTDIR/bin/simple_panorama_viewer"
}
uninstall()
{
DIR=$1
check_dir "$DIR"
rm "$DIR/bin/simple_panorama_viewer"
rm "$DIR/share/applications/SimplePanoramaViewer.desktop"
}
package()
{
DIR="/tmp/SimplePanoramaViewer"
mkdir "$DIR"
cp target/release/simple_panorama_viewer "$DIR"
cp LICENSE.md "$DIR"
cp README.md "$DIR"
chmod a+x "$DIR/simple_panorama_viewer"
mkdir -p dist
cd /tmp || exit
tar --zstd -cf "SimplePanoramaViewer.tar.zst" "SimplePanoramaViewer"
cd - || exit
cp -f "$DIR.tar.zst" dist
rm -r "$DIR"
rm "$DIR.tar.zst"
}
build()
{
cargo build --release
strip target/release/simple_panorama_viewer
}
case "$1" in
"-h" | "--help")
print_help
;;
"-i" | "--install")
install "$2" "$3"
;;
"-u" | "--uninstall")
uninstall "$2"
;;
"-p" | "--package")
package
;;
"-b" | "--build")
build
;;
*)
print_help
;;
esac