I see that this topic has been discussed at length in various threads through the years, so I won't belabor the issue.
I wanted a no-frills script that assumes I know what I'm doing and simply uninstalls the extensions I tell it to, then also uninstalls any orphan dependencies that result. I don't want the script to check anything for me--it's up to me to not uninstall something that I'm currently using. I don't know if something like this already exists, but figured it would be faster and easier for me to roll my own than to search.
In case it is useful to someone, here is the script:
#!/bin/sh
# Purpose: uninstall the specified extension(s) and any orphaned dependencies that result
# Example: $ uninstall lftp openvpn
main()
{
create_notrequired_original
create_arg_hitlist "$@"
while [ -s hitlist ]; do
while read extension; do
uninstall "$extension"
done <hitlist
create_orphan_hitlist
done
exit
}
create_notrequired_original()
{
tce-audit builddb >/dev/null && tce-audit notrequired | sed 's/\.tcz$//' >notrequired-original
}
create_arg_hitlist()
{
cat /dev/null >hitlist
for arg in "$@"; do
echo "$arg" >>hitlist
done
}
create_orphan_hitlist()
{
tce-audit builddb >/dev/null && tce-audit notrequired | sed 's/\.tcz$//' >notrequired-now
comm -13 notrequired-original notrequired-now >hitlist
}
uninstall()
{
echo "Uninstalling ${1}..."
# this would be sufficient if followed by a reboot:
rm /etc/sysconfig/tcedir/optional/${1}.tcz*
sed -i "/^${1}\.tcz/ d" /etc/sysconfig/tcedir/onboot.lst
# current boot considerations:
link=$(which $1); [ "$link" ] && sudo rm $link
sudo umount -d /tmp/tcloop/$1
sudo rmdir /tmp/tcloop/$1
sudo rm /usr/local/tce.installed/$1
}
cd /tmp
main "$@"