2011-02-07 16:16:24 -05:00
#!/bin/sh
######################################
#
# Ardour/Mixbus bundle uninstaller
# Todd Naugle
#
#####################################
2015-03-09 13:41:46 -04:00
MAJOR_VERSION = "%REPLACE_MAJOR_VERSION%"
2011-02-07 16:16:24 -05:00
PGM_NAME = "%REPLACE_PGM%"
PGM_VENDOR = "%REPLACE_VENDOR%"
PGM_VERSION = "%REPLACE_VERSION%"
2011-02-25 17:05:15 -05:00
PGM_BUILDTYPE = "%REPLACE_TYPE%"
2011-02-07 16:16:24 -05:00
INSTALL_DEST_BASE = /opt
2012-02-29 12:55:13 -05:00
USER_BIN_DIR = "/usr/local/bin"
UNINSTALLER = " $( readlink -f " $0 " ) "
2011-02-07 16:16:24 -05:00
2011-11-08 13:07:29 -05:00
USER_NAME = $( logname)
2011-02-07 16:16:24 -05:00
#### Derived Variables ####
2011-02-25 17:05:15 -05:00
if [ -z " ${ PGM_BUILDTYPE } " ] ; then
2013-03-25 10:39:00 -04:00
PGM_PATH = ${ INSTALL_DEST_BASE } /${ PGM_NAME } -${ PGM_VERSION }
Fix various typos
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sord,sur,te,trough,ue`
Follow-up to 364f2f078
2022-04-07 09:09:04 -04:00
ICON_NAME = " ${ PGM_VENDOR } - ${ PGM_NAME } _ ${ PGM_VERSION } " #no dash between name and version since dash separates vendor from program
MENU_FILE = " ${ PGM_VENDOR } - ${ PGM_NAME } _ ${ PGM_VERSION } .desktop " #no dash between name and version since dash separates vendor from program
2011-02-25 17:05:15 -05:00
DESKTOP_LINK_FILE = " ${ PGM_NAME } _ ${ PGM_VERSION } .desktop "
else
2013-03-25 10:39:00 -04:00
PGM_PATH = ${ INSTALL_DEST_BASE } /${ PGM_NAME } -${ PGM_VERSION } -${ PGM_BUILDTYPE }
Fix various typos
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sord,sur,te,trough,ue`
Follow-up to 364f2f078
2022-04-07 09:09:04 -04:00
ICON_NAME = " ${ PGM_VENDOR } - ${ PGM_NAME } _ ${ PGM_VERSION } _ ${ PGM_BUILDTYPE } " #no dash between name and version since dash separates vendor from program
MENU_FILE = " ${ PGM_VENDOR } - ${ PGM_NAME } _ ${ PGM_VERSION } _ ${ PGM_BUILDTYPE } .desktop " #no dash between name and version since dash separates vendor from program
2011-02-25 17:05:15 -05:00
DESKTOP_LINK_FILE = " ${ PGM_NAME } _ ${ PGM_VERSION } _ ${ PGM_BUILDTYPE } .desktop "
fi
2011-02-07 16:16:24 -05:00
MENU_FILE_PATH = " ${ PGM_PATH } /share/ ${ MENU_FILE } "
2011-04-06 15:02:11 -04:00
#############################
# Check for root privileges
#############################
SUPER = ""
if [ " $( id -u) " != "0" ] ; then
if ! which sudo > /dev/null;
then
echo ""
2012-02-29 12:55:13 -05:00
echo "Attempting to uninstall using su"
echo "Please enter root password below"
2011-04-06 15:02:11 -04:00
echo ""
2012-02-29 12:55:13 -05:00
if ! su -c " ${ UNINSTALLER } " ;
then
echo ""
echo "!!! ERROR !!!"
echo ""
echo "This uninstaller requires root privileges. It is currently not"
echo "running as root AND an attempt to use su failed."
echo ""
echo "Please correct this by installing and configuring sudo or running"
echo "the uninstaller as root (su -c)."
echo ""
read -p "Press ENTER to exit uninstaller:" BLAH
exit 1
fi
exit
2014-11-13 00:00:29 -05:00
else
sudo -k # make sudo forget about cached credentials
2011-04-06 15:02:11 -04:00
fi
if ! sudo date;
then
echo ""
2012-02-29 12:55:13 -05:00
echo "Attempting to uninstall using su"
echo "Please enter root password below"
2011-04-06 15:02:11 -04:00
echo ""
2012-02-29 12:55:13 -05:00
if ! su -c " ${ UNINSTALLER } " ;
then
echo ""
echo "!!! ERROR !!!"
echo ""
echo "This uninstaller requires root privileges. It is currently not"
echo "running as root AND an attempt to use both sudo and su failed."
echo ""
echo "Please correct this by installing and configuring sudo or running"
echo "the uninstaller as root (su -c)."
echo ""
read -p "Press ENTER to exit uninstaller:" BLAH
exit 1
fi
exit
2011-04-06 15:02:11 -04:00
fi
SUPER = "sudo"
fi
2011-02-07 16:16:24 -05:00
#######################
# Check for xdg utils
#######################
HAS_XDG = "T"
2011-11-08 13:07:29 -05:00
#load the file that contains the translated names of the users directories
if [ -e /home/${ USER_NAME } /.config/user-dirs.dirs ] ; then
. /home/${ USER_NAME } /.config/user-dirs.dirs
fi
if [ " $( id -u) " != "0" ] ; then
USER_DESKTOP_DIR = ${ XDG_DESKTOP_DIR :- $HOME /Desktop }
else
#running as root with su makes this more difficult
DESKTOP_FOLDER = $( echo ${ XDG_DESKTOP_DIR :- $HOME /Desktop } | awk -F/ '{print $NF}' )
USER_DESKTOP_DIR = " /home/ ${ USER_NAME } / ${ DESKTOP_FOLDER } "
fi
2011-02-07 16:16:24 -05:00
XDG_MENU_VER = $( xdg-desktop-menu --version 2> /dev/null)
if [ -z " $XDG_MENU_VER " ] ;
then
echo "System does not have xdg-desktop-menu installed"
HAS_XDG = "F"
fi
XDG_ICON_VER = $( xdg-icon-resource --version 2> /dev/null)
if [ -z " $XDG_ICON_VER " ] ;
then
echo "System does not have xdg-icon-resource installed"
HAS_XDG = "F"
fi
#############
# Uninstall
#############
if [ -d ${ PGM_PATH } ] ;
then
echo ""
echo " Removing existing ${ PGM_NAME } installation at ${ PGM_PATH } "
echo ""
if [ "T" = ${ HAS_XDG } ] ;
then
2011-04-06 15:02:11 -04:00
${ SUPER } xdg-desktop-menu uninstall ${ MENU_FILE_PATH }
${ SUPER } xdg-icon-resource uninstall --size 16 ${ ICON_NAME }
${ SUPER } xdg-icon-resource uninstall --size 22 ${ ICON_NAME }
${ SUPER } xdg-icon-resource uninstall --size 32 ${ ICON_NAME }
${ SUPER } xdg-icon-resource uninstall --size 48 ${ ICON_NAME }
2015-12-17 11:18:56 -05:00
${ SUPER } xdg-icon-resource uninstall --size 256 ${ ICON_NAME }
2011-02-07 16:16:24 -05:00
if [ -e /usr/share/icons/hicolor/scalable/apps/${ ICON_NAME } .svg ] ;
then
2011-04-06 15:02:11 -04:00
${ SUPER } rm -f /usr/share/icons/hicolor/scalable/apps/${ ICON_NAME } .svg
2011-02-07 16:16:24 -05:00
fi
fi
2011-11-08 13:07:29 -05:00
if [ -e ${ USER_DESKTOP_DIR } /${ DESKTOP_LINK_FILE } ] ;
2011-02-07 16:16:24 -05:00
then
2011-11-08 13:07:29 -05:00
${ SUPER } rm -f ${ USER_DESKTOP_DIR } /${ DESKTOP_LINK_FILE }
2011-02-07 16:16:24 -05:00
fi
2012-02-29 12:55:13 -05:00
# delete the bin link if it is linked to this version
2015-03-09 13:41:46 -04:00
if [ -e " ${ USER_BIN_DIR } / ${ PGM_NAME } ${ MAJOR_VERSION } " ] ;
2012-02-29 12:55:13 -05:00
then
2015-03-09 13:41:46 -04:00
BIN_LINK_TARGET = $( readlink " ${ USER_BIN_DIR } / ${ PGM_NAME } ${ MAJOR_VERSION } " )
2012-02-29 12:55:13 -05:00
BIN_LINK_TARGET_DIR = $( dirname " ${ BIN_LINK_TARGET } " )
if [ " ${ BIN_LINK_TARGET_DIR } " = " ${ PGM_PATH } /bin " ] ;
then
2015-03-09 13:41:46 -04:00
${ SUPER } rm -f " ${ USER_BIN_DIR } / ${ PGM_NAME } ${ MAJOR_VERSION } "
2012-02-29 12:55:13 -05:00
fi
fi
2011-02-07 16:16:24 -05:00
# delete the old package
2011-04-06 15:02:11 -04:00
${ SUPER } rm -rf ${ PGM_PATH }
${ SUPER } rm -f $0
2011-02-07 16:16:24 -05:00
else
echo ""
echo " !!! FAILURE !!! - install path ${ PGM_PATH } does not exist. "
echo ""
fi