SimplePanoramaViewer/utility.sh

99 lines
1.7 KiB
Bash
Raw Normal View History

2018-11-18 16:35:34 +00:00
#!/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"
2018-11-18 16:56:37 +00:00
echo " -u, --uninstall Uninstall SimplePanoramaViewer from PATH_TO_INSTALL_DIR"
echo " -p, --package Generate a package for SimplePanoramaViewer"
2018-11-18 16:35:34 +00:00
}
check_dir()
{
if [ -z "$1" ]; then
echo "You need to pass a directory"
exit
fi
}
install()
{
2018-11-20 21:21:19 +00:00
DESTDIR=$1
check_dir "$DESTDIR"
if [ -z "$2" ]; then
PREFIX=$DESTDIR
else
PREFIX="$2"
DESTDIR=$DESTDIR$PREFIX
echo $DESTDIR
fi
2018-11-18 16:35:34 +00:00
2018-11-20 21:21:19 +00:00
mkdir -p "$DESTDIR/bin/"
mkdir -p "$DESTDIR/share/applications"
cp install/SimplePanoramaViewer.desktop "$DESTDIR/share/applications"
2022-09-05 19:06:36 +00:00
cp target/release/simple_panorama_viewer "$DESTDIR/bin"
chmod a+x "$DESTDIR/bin/simple_panorama_viewer"
2018-11-18 16:35:34 +00:00
}
uninstall()
{
DIR=$1
check_dir "$DIR"
2022-09-05 19:06:36 +00:00
rm "$DIR/bin/simple_panorama_viewer"
2018-11-18 16:35:34 +00:00
rm "$DIR/share/applications/SimplePanoramaViewer.desktop"
}
2018-11-18 16:56:37 +00:00
package()
{
DIR="/tmp/SimplePanoramaViewer"
mkdir "$DIR"
2022-09-05 19:06:36 +00:00
cp target/release/simple_panorama_viewer "$DIR"
cp LICENSE.md "$DIR"
cp README.md "$DIR"
chmod a+x "$DIR/simple_panorama_viewer"
2018-11-18 16:56:37 +00:00
mkdir -p dist
cd /tmp || exit
2022-09-05 19:06:36 +00:00
tar --zstd -cf "SimplePanoramaViewer.tar.zst" "SimplePanoramaViewer"
2018-11-18 16:56:37 +00:00
cd - || exit
2022-09-05 19:06:36 +00:00
cp -f "$DIR.tar.zst" dist
2018-11-18 16:56:37 +00:00
rm -r "$DIR"
2022-09-05 19:06:36 +00:00
rm "$DIR.tar.zst"
}
build()
{
cargo build --release
strip target/release/simple_panorama_viewer
2018-11-18 16:56:37 +00:00
}
2018-11-18 16:35:34 +00:00
case "$1" in
"-h" | "--help")
print_help
;;
"-i" | "--install")
2018-11-20 21:21:19 +00:00
install "$2" "$3"
2018-11-18 16:35:34 +00:00
;;
"-u" | "--uninstall")
uninstall "$2"
;;
2018-11-18 16:56:37 +00:00
"-p" | "--package")
package
;;
2022-09-05 19:06:36 +00:00
"-b" | "--build")
build
;;
2018-11-18 16:35:34 +00:00
*)
print_help
;;
esac