WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: script to uninstall extension and resulting orphan dependencies  (Read 144 times)

Offline GNUser

  • WikiUser
  • *
  • Posts: 24
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: [Select]
#!/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 "$@"




Offline GNUser

  • WikiUser
  • *
  • Posts: 24
Re: script to uninstall extension and resulting orphan dependencies
« Reply #1 on: July 09, 2019, 08:28:48 AM »
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.)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6599
Re: script to uninstall extension and resulting orphan dependencies
« Reply #2 on: July 09, 2019, 08:52:40 AM »
Hi GNUser
(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.)
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.

Offline GNUser

  • WikiUser
  • *
  • Posts: 24
Re: script to uninstall extension and resulting orphan dependencies
« Reply #3 on: July 09, 2019, 09:06:48 AM »
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.
« Last Edit: July 09, 2019, 09:11:28 AM by GNUser »