Tiny Core Extensions > TCE Tips & Tricks
script to uninstall extension and resulting orphan dependencies
GNUser:
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:
--- Code: ---#!/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 "$@"
--- End code ---
GNUser:
I just realized that both the script and one of its functions are called "uninstall". It works but is confusing. Perhaps a better name for the script would be tce-uninstall.
(Maybe the GUI version of TC provides this script's functionality, but I'm running without X and couldn't find something like it among the CLI tools.)
Rich:
Hi GNUser
--- Quote from: GNUser on July 09, 2019, 11:28:48 AM ---(Maybe the GUI version of TC provides this script's functionality, but I'm running without X and couldn't find something like it among the CLI tools.)
--- End quote ---
tce-audit provides that function, but it marks the extensions for removal and deletes them when you reboot. There is no mechanism
for removing installed extensions from a running system.
GNUser:
Yes, I noticed tce-audit's "mark-then-reboot" approach. However, during intense tinkering sessions I need to test different versions of an extension. Having to reboot between tests makes me a sad panda.
Well, now we have this mechanism for removing installed extensions from a running system ;) I have already put my script through some abuse and it works exactly as advertised. After uninstalling an extension with the script, one can immediately re-install it as usual (with tce-load or tce-ab) if one so desires.
GNUser:
I cleaned the script up a bit. Here is the new version:
--- Code: ---#!/bin/sh
# Purpose: uninstall the specified extension(s) and any orphaned dependencies that result
# Example: $ tce-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$//' | sort >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$//' | sort >notrequired-now
comm -13 notrequired-original notrequired-now >hitlist
}
uninstall()
{
if [ -e /etc/sysconfig/tcedir/optional/${1}.tcz ]; then
echo "Uninstalling ${1}..."
# this would be sufficient if followed by a reboot:
rm /etc/sysconfig/tcedir/optional/${1}.tcz* 2>/dev/null
sed -i "/^${1}\.tcz/ d" /etc/sysconfig/tcedir/onboot.lst 2>/dev/null
# current boot considerations:
link=$(which $1); [ "$link" ] && sudo rm $link
sudo umount -d /tmp/tcloop/$1 2>/dev/null
sudo rmdir /tmp/tcloop/$1 2>/dev/null
sudo rm /usr/local/tce.installed/$1 2>/dev/null
else
echo "${1} is not installed."
fi
}
cd /tmp
main "$@"
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version