WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to automate removal of leftover unneeded dependencies?  (Read 3198 times)

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
How to automate removal of leftover unneeded dependencies?
« on: February 02, 2015, 02:46:45 AM »
coreplayer2 nicely summarized how to remove TC applications - thanks:
http://forum.tinycorelinux.net/index.php/topic,17584.0.html
Quote
Simply use Apps   to remove programs

Open Apps, select  Apps button > Maintenance >  Dependencies and Deletions, wait for the list of installed extensions to be built, then,
Select the Extension you wish to remove, while highlighted go up to the Dependencies button and choose "Mark for deletion"  the extension will be listed in the right window along with any errors messages regarding dependencies..
Next select the Dependencies button > Exit Dependency check> close Apps, Apps button > Quit, then reboot

Sounds a little complex when is written but is actually quite easy when you get the routine down.

No problem. My query is related to removing leftover dependencies that are no longer needed.

I can manually check which dependencies were required for the application that was just removed, then attempt to Mark for Deletion these dependencies and Apps will either mark for deletion or failsafe notify if not possible as another application depends on it. That's fine but the manual method is tedious, especially after installing/removing several packages.

Another method would be to process the whole installed list one item at a time, then click Dependencies drop down, then Mark for Deletion and Apps either marks or warns, also very tedious. Would be great if there was a keyboard shortcut to quicken this process, like del key, instead of all the menu clicking.

Via Apps > Maintenance > Dependencies and deletions i tried shift, ctrl and ctrl-a in an attempt to select the entire list hoping to flag all unneeded dependencies at once but this doesn't work. In hindsight, Apps isn't designed to work this way because all primary packages will get removed with their dependencies and the optional folder will be gutted.

The last alternative i can think of would be to delete the optional folder contents and essentially start with a fresh system, reinstalling only desired applications - starting from scratch.

Any way to automate removal of leftover unneeded dependencies? Sorry if this has been brought up before, didn't find anything.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to automate removal of leftover unneeded dependencies?
« Reply #1 on: February 02, 2015, 09:10:20 AM »
Apps automatically removes any dependencies that are not needed by another app.

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to automate removal of leftover unneeded dependencies?
« Reply #2 on: February 02, 2015, 12:38:39 PM »
Thanks gerald_clark.

Sorry about that, should have RTFreeM   :-[

For others like me:
Quote
The other function, extension deletion, allows you to mark an
extension to be deleted on the next reboot. All of their dependencies
that aren’t needed by anything else will also be removed.
Page 56 of 163
Into the Core - A look at Tiny Core Linux


Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: How to automate removal of leftover unneeded dependencies?
« Reply #3 on: February 03, 2015, 03:58:37 AM »
@nitram: There's one teeency flaw with dependency assumptions we've encountered.

Let's say we have a web development box which under most distros we would install LAMP.
For CentOS (for example) the apps list would be:
apache2 php5 mysql mysql-server and a few other odds and ends.
I mistakenly took the same approach with TC
apache2 php5 mysql-client mysql and again, a few other oddities.
What I didn't know is that php5 claims MySQL as being a dependency.  You could imagine my surprise when I used a script for general installation (tce-load -wi $app_list) and then later removed php5 as it wasn't needed for THAT specific project, but MySQL was needed...  come to find out my SQL server disappeared! :)

Imagine looking at extensions based on their download: If you tce-load a given app such as php5 you could call this the "parent" extension and all dependencies listed within the file.tcz.dep as children.  With the PHP-MySQL scenario, one or more of the children are also parents in some instances.  There's a ton of legitimate examples which would likely fall into this category.

What we have on the white-board in the not so distant future is a separate file (similar to onboot.lst) which flags files which are specifically requested in tce-load where if you specifically request a file, it's considered a parent, thus when removing an extension, if a dependency is found within this new file, it's left alone - along with any of ITS dependencies.  This requires a little bit of a rewrite of tce-load so once finished and perfected we'll be submitting it here for consideration to be implemented into the core.

As for a clean slate as you noted, we already have a method which is relatively tried and tested which helps with this kind of maintenance.  We have our own TCL mirror in-house so it will be more convenient (and faster) when we're using it, but even "live" it should be a good alternative assuming any updates which have been made to the live repository are functional.

1) Create a static file somewhere (we persist /opt, so that's where most of our functions like this are placed) such as /opt/.extensions and within this file list all of the extensions you want to have "always installed" and maintained.  I'm going to use the basic TinyCore approach for the example:
/opt/.extensions
Code: [Select]
Xvesa
Xprogs
flwm_topside
wbar

2) Create a small script to run the show
/opt/extensions.sh (chmod +x)
Code: [Select]
#!/bin/sh
exts=`cat /opt/.extensions`
for ext in $exts
do
     ext=${ext/.tcz/} # Remove the .tcz extension if it's in the item
     if [ ! -d /tmp/tcloop/$ext ]; then
          # The extension isn't installed and/or loaded #
          echo "Installing extension [$ext]"
          su -c "tce-load -wi $ext" tc
     fi
done
There are a few assumptions involved here, such as networking is up and running, the machine itself HAS internet or network access by the time it runs AND that the extension(s) listed were intended for install-and-boot.

When ever you need to clean out the closet, simply delete tcedir/optional, onboot.lst and on-demand if it's used, then reboot.  If you don't want to reboot, also empty the /usr/local/tce.installed directory, kill all post-boot processes and then run the script.  Rebooting is the cleanest method, though, as many times apps create files/directories elsewhere which may no longer be in their default state.  We're working on this problem, too (where in the end we'll be able to call a "reformat" program which basically takes the machine back to a clean boot without the need for rebooting, which should be about 98% efficient as there might be a small amount of memory loss from less-than-efficient programs which had been running previously and didn't die gracefully.)

Offline core-user

  • Full Member
  • ***
  • Posts: 191
  • Linux since 1999
Re: How to automate removal of leftover unneeded dependencies?
« Reply #4 on: February 03, 2015, 04:28:35 AM »
Quote
We're working on this problem, too (where in the end we'll be able to call a "reformat" program which basically takes the machine back to a clean boot without the need for rebooting
I certainly would not call it "reformat" - you will scare people, who will think they are going to lose all their data!  ;)
AMD, ARM, & Intel.

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: How to automate removal of leftover unneeded dependencies?
« Reply #5 on: February 03, 2015, 05:17:23 AM »
Good call! :)  It was initially called "factory" (/usr/local/sbin/factory) but in all actuality "reformat" ended up being the case as our in-house version actually can do a complete wipe-from-memory if there's enough memory or a second storage device available to run a backup.

reformat -complete -backup=sdb1
* Pull in any extensions, if necessary, such as syslinux
* Backup /opt, /home and boot files to /tmp if memory permits
* Backup to /mnt/sdb1 /opt, /home and /boot files if directed to do so
* dd the boot drive, fdisk, reformat and reinstall the boot loader
* Restore the backup from /tmp and/or /mnt/sdb1
* unlike dd, we at least confirm destruction! :)
reformat with no parameters tends to just extensions

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to automate removal of leftover unneeded dependencies?
« Reply #6 on: February 03, 2015, 04:21:23 PM »
@centralware: Thanks for the info and for taking the time to write at basic user level. Your posts are always concise and easy to read even if i need to review a few times for the information to sink in.

The scripted clean slate approach would be very slick for my wired desktop, which autoconnects no problem. As most TC users are probably interested in lean and clean systems, these reset methods are awesome. Used to think keeping an old OS for a long time was a badge of honour (eg upgrade Ubuntu 6 to 8.04 to 10.04) but now realize this exposes the system to vulnerabilties, cruft and inefficiencies.

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to automate removal of leftover unneeded dependencies?
« Reply #7 on: February 03, 2015, 09:34:21 PM »
Could someone explain this please, as i'm still not understanding or there's a bug.

Gparted.tcz lists parted.tcz as one of it's dependencies. I only have a few applications on this system and it is doubtful any of the other extensions rely on parted.tcz.

Used Apps to remove gparted:

- opened apps > maintenance > dependencies and deletions
- select update dep files
- select build reporting database
- select gparted, then mark for deletion
- select display marked for deletion, confirms gparted is to be removed (believe couple other libraries too, but NOT parted)
- exit dependency check
- quit apps
- shutdown computer and reboot
- restart apps > dependencies and deletions
- update dep files and re-build reporting database
- parted still listed as installed
- check optional folder, confirms gparted deleted but parted still installed
- back to apps > display all with no dependencies, parted is listed
- apps > display all not depended on, parted is listed

Why was parted.tcz not removed? It's listed as a gparted dependency, which was removed, and is not required for another application.
« Last Edit: February 03, 2015, 09:45:21 PM by nitram »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: How to automate removal of leftover unneeded dependencies?
« Reply #8 on: February 03, 2015, 11:50:18 PM »
Hi nitram
If you are running TC4 the following extensions depend on parted:
Code: [Select]
        SpaceFM-locale.tcz
        SpaceFM.tcz
        compiz-gnome.tcz
        gnome-desktop-base.tcz
        gnome-disk-utility-dev.tcz
        gnome-disk-utility-locale.tcz
        gnome-disk-utility.tcz
        gparted.tcz
        gvfs-dev.tcz
        gvfs-locale.tcz
        gvfs.tcz
        parted-dev.tcz
        udisks.tcz

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to automate removal of leftover unneeded dependencies?
« Reply #9 on: February 04, 2015, 12:21:59 AM »
Thanks Rich.

I'm running TC6. Don't have any of the extensions you listed in:
- tce-status -i
- optional folder
- ondemand folder
- onboot.lst

Just noticed that the TC6 Apps browser, does not, however, populate the parted.tcz depends and size tabs (empty information box). The info and files tabs are populated as one would normally expect.

Is this just a bug in the TC6 parted.tcz - extension does not provide dependency and size info?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: How to automate removal of leftover unneeded dependencies?
« Reply #10 on: February 04, 2015, 12:34:46 AM »
Hi nitram
Quote
Just noticed that the TC6 Apps browser, does not, however, populate the parted.tcz depends and size tabs (empty information box). The info and files tabs are populated as one would normally expect.
If an extension has no dependencies there might not be a dependency file or it might be be empty, either of which would cause that.

Is parted.tcz listed in your onboot.lst file? Maybe that's why it wasn't removed.
« Last Edit: February 04, 2015, 12:43:26 AM by Rich »

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: How to automate removal of leftover unneeded dependencies?
« Reply #11 on: February 04, 2015, 12:41:38 AM »
@nitram: It sounds like a dependency loop.

Parted depends on Gparted.  Gparted depends on Parted.  If you try to remove one, the other will be left behind, and if memory serves, Apps only allows you to work on one extension at a time.  Just for kicks, remove Gparted (which sounds like what you've done) followed by Parted.  If my assumptions are correct, THIS should alleviate the remaining dependencies assuming they're not being used elsewhere.

Bare in mind, I've used "Apps" twice.  The first time (TC4) was when I was just skimming through the list of extensions TC has available.  The second time was to see whether or not "Apps" could nab a clean copy of the kernel and core.gz from the repository...  which it couldn't, but was worth looking! :)  From there out I've stuck with the CLI (shell) interface as I was born (so to speak) on the keyboard back when DOS was still a baby, Windows slid open and closed and being "online" was more of a reference of understanding a topic and had nothing to do with wires or digital networking, thus I don't prefer to "click" (or SWIPE!) unless I just "have to."  LOL...  I had a newer laptop dropped at my doorstep a couple weeks ago.  Win8 lasted about 4-5 minutes before it booted saying "Welcome to Linux!" and the "Built for Win..." was all that was seen from the sticker that once was adhered to the top panel once it was folded in half and ready for the "real" Recycle Bin. :)  I'm not anti-windows...  I have plenty hanging on the walls and they're the most secure windows ever released - I found out the hard way when I locked myself out of the house!  I'm married, so I'm not Anti-Misses (Ms.)  I'm just anti-control-freak and thus why certain breeds of equipment which cross my path rarely stay as they were intended.  The last apple I bought was in a bag for $4.50...  though I must admit my daughter has an older generation "pod" which has as much mileage as my van.

Stepping out from the "badge of honor" must be a little scary, yet refreshing for some.  Set up a re-install system like the one I mentioned earlier and you can virtually beat the thing senseless and with a teency call to the aforementioned command, viola'...  you're back to square one without the mess of recovery, restores, etc. thus my particular love for TC.

Recommendation: In addition to the clean-up system, I suggest also throwing together a boot menu which is a bit more geared to a backup system in case you do decide to venture and find a few screws missing which are vital to booting the machine.

Have your standard boot listed like it is now in tce/boot/extlinux/extlinux.conf which has all of your bells and whistles you want, but create a second "emergency" boot menu item which allows you to get into just the "base core" in the event you rearrange the furniture and find you can't get back in.
See this post for an example:
http://forum.tinycorelinux.net/index.php/topic,17999.msg108932.html#msg108932
Oh wait...  that post was to you! :)

Good luck and take care!

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to automate removal of leftover unneeded dependencies?
« Reply #12 on: February 04, 2015, 01:02:27 AM »
Quote
Rich wrote:
If an extension has no dependencies there might not be a dependency file or it might be be empty, either of which would cause that.
Okay i guess that makes sense.

parted.tcz is not listed in my onboot.lst.

Quote
centralware wrote:
@nitram: It sounds like a dependency loop.

Parted depends on Gparted.  Gparted depends on Parted.  If you try to remove one, the other will be left behind...

You're a funny one  ;D

It seems that this is what is happening, but in my humble opinion, Apps is then not operating as advertised - no? Getting late in the day in my part of the world but i will play with Apps a bit more in the next few days and see if i can't figure this out. At this point, it appears Apps is not removing unnecessary dependencies and i can not trust it enough to use it regularly without double-checking everything.

Maybe similar to Debian, my comfortable home. Synaptic is great for browsing packages and can even be good for installing/removing or updating the system but there are times when simple apt-get commands via terminal were quick and robust. I will need to spend some time learning more of the manual tce-type commands.

Thanks again for replies. I will post back if i discover anything new.

Afterthought: Maybe i'm just using a bad example, using gparted to test App's ability to autoremove unneeded dependencies as gparted is the GUI but parted is a proper standalone application, not just a minor dependency. Having said that, the initial install was gparted, which dragged along parted. I did not install parted first, then decide i wanted the graphical gparted. Maybe Apps isn't smart enough to remember or care which extension was the primary install.

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: How to automate removal of leftover unneeded dependencies?
« Reply #13 on: February 04, 2015, 01:12:04 AM »
As was inquired, your files found in onboot.lst (and/or ondemand.lst) will generally determine (to Apps) what's considered a "Parent" extension versus a child/dependency.  If you open tcedir/onboot.lst and see parted.tcz listed there, it generally indicates that parted was installed on its own.  This could likely be that parted was the chosen app (from Apps) and GParted was merely a child, thus when you removed GParted, it saw parted as something you wanted to keep.

If parted.tcz is NOT in your onboot.lst file, then yes...  I'd agree that something went wrong with Apps.  The catch with Apps is that it allows you to install ONE extension at a time, thus if you installed 5 apps, all related to one another (and sharing different extensions as dependencies) it would not be until you manually un-installed that fifth extension before those dependencies would be taken out.

1AM here - so I agree, it's time to call it a night!  Have a great evening and take care!