Script now checks for success before deleting files

This commit is contained in:
Mason Lary 2023-01-12 12:22:36 -05:00
parent 188d0db299
commit cabd538c8e

View File

@ -1,5 +1,7 @@
#!/bin/bash
shopt -s extglob
SCRIPTS_PATH="$(dirname "$(realpath "$0")")"/..
RESOURCES_PATH=$SCRIPTS_PATH/../../resources
INSTALL_PATH=$SCRIPTS_PATH/../../install
@ -29,25 +31,15 @@ then
export QMAKE=$QT_DIR/bin/qmake
fi
$RESOURCES_PATH/linux/linuxdeploy --appdir=$INSTALL_PATH \
--plugin qt
# after deploy, all required libraries are placed into usr/lib, therefore we can remove the ones in
# usr/lib/meshlab (except for the ones that are loaded at runtime)
shopt -s extglob
# If the script fails for some reason, it causes the deletion of files that weren't meant to be deleted.
# We can fix this with a simple if statement
if [[ -d $INSTALL_PATH/usr/lib/meshlab ]]
then
# Make sure that deploy succeeds before we start deleting files
if $RESOURCES_PATH/linux/linuxdeploy --appdir=$INSTALL_PATH --plugin qt; then
# after deploy, all required libraries are placed into usr/lib, therefore we can remove the ones in
# usr/lib/meshlab (except for the ones that are loaded at runtime)
cd $INSTALL_PATH/usr/lib/meshlab
rm -v !("libIFXCore.so"|"libIFXExporting.so"|"libIFXScheduling.so")
echo "$INSTALL_PATH is now a self contained meshlab application"
else
#at this point, distrib folder contains all the files necessary to execute meshlab
echo "$INSTALL_PATH/usr/lib/meshlab was not created. Script could not continue running."
echo "linuxdeploy failed with error code $?. Script was not completed successfully."
fi