OpenWrt Forum Archive

Topic: Removing orphaned packages

The content of this topic has been archived on 15 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

How do I remove packages that were installed only to satisfy other packages dependencies, which have since been removed?  Using apt-get, it was as simple as "apt-get autoremove".  Apparently the autoremove functionality of opkg only works on a per-package basis.  This does not help me as I can not remember all of the packages I have installed and uninstalled.

Well, I suppose I only need help *identifying* orphaned packages.

Theres a few ways to go about this, for example, instead of identifying specifically orphaned packages, I could identify all packages set as manually installed or installed as a dependency of another package.  If installed as a dependency of another package which is no longer present, then that would probably be an orphaned package.

Id rather not do a reset.

This always worked for me:
opkg remove --autoremove PACKAGE_NAME

dabyd64 wrote:

This always worked for me:
opkg remove --autoremove PACKAGE_NAME

But what to do if you do not remember the packages you have removed?  Debians package manager did this easily by simply

apt-get autoremove

No need to specify the package.  I think I can not expect the autoremove package to function the same for opkg, but is there way to tell which packages were auto-installed and by what other packages?

I still am unsure of how to tell what packages I have installed that were auto-installed and now no longer needed.  I do not want to just run "firstboot" because I have a fair amount of configuration I do not want to lose.  I would not mind removing all software except for the packages and configuration involved in using my USB port as WAN.  I am out of space on my router even though I have very few packages installed. 

I even had a backup image that I did after getting my USB WAN working, but surprisingly, loading it did not result in the same amount of free space as when the image was generated.

Can someone please tell me my options?  Again I do not want to use "firstboot" because I do not want to lose my working USB WAN. 

Thanks

opkg list-installed | awk '{print $1}' | while read -r line; do if (opkg info $line | grep -q 'install ok installed'); then opkg --autoremove remove $line; fi; done

Sorry for resurrecting a dead thread but this is one of those that appears as the first result on google when searching for the orphans topic (a common word used to describe this type of situation)

It was my observation that all dependent packages have "Status: installed ok installed" instead of "hold installed" or "user installed", so I'm testing for that and then attempting to remove. Since opkg will only remove packages that aren't depended on, it should in theory only remove those packages that are orphaned.

(Last edited by xenith on 22 Mar 2016, 06:25)

@cobalt60 More than 3 years later, but did you see the command @xenith posted? I used it first time now and found it very useful.

The discussion might have continued from here.