[Solved] How to remove unused dependencies from LEDE?

Or the correct is:

cp /rom/lib/libfstools.so /rom/sbin/libfstools.so

Sorry for my ignorance...

cp /rom/lib/libfstools.so /lib

Think like /rom/remaining_path --> /remaining_path

Let's see what we did...

root@LEDE:/lib# ls
config libfstools.so modules
firmware libgcc_s.so.1 netifd
functions libjson_script.so network
ld-musl-mips-sf.so.1 libubox.so preinit
libblobmsg_json.so libubus.so upgrade
libc.so libuci.so wifi
root@LEDE:/lib# /rom/sbin/jffs2reset
This will erase all settings and remove any installed packages. Are you sure? [N/y]

Just as expected :wink:
y

It doesn't reboot (yet). The full last lines are:

root@LEDE:~# cp /rom/lib/libfstools.so /lib
root@LEDE:~# cd /lib
root@LEDE:/lib# ls
config libfstools.so modules
firmware libgcc_s.so.1 netifd
functions libjson_script.so network
ld-musl-mips-sf.so.1 libubox.so preinit
libblobmsg_json.so libubus.so upgrade
libc.so libuci.so wifi
root@LEDE:/lib# /rom/sbin/jffs2reset
This will erase all settings and remove any installed packages. Are you sure? [N/y]
y
/dev/mtdblock6 is mounted as /overlay, only erasing files
root@LEDE:/lib#

OK! opkg responds! I will do a reboot now.
Thanks @hnyman, I hope this is over!
Have a nice day again!

You need to reboot manually.

Normal "reboot" may not work for you, so hard power-off might be the last resort there.

root@LEDE:~# opkg update
root@LEDE:~# opkg list-upgradable
root@LEDE:~# reboot
Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.
vasilis74@teras:~$

Everything is fine thanks to @hnyman's patience! I update the system now.

The initial question is not yet answered

I assume it cannot be done, dependencies can only be removed or listed when the initial packages are removed.

opkg would probably be heavier if could do it, but if can be done would someone provide a script that lists unneeded dependencies?
I wouldn't stay more at it just for me. I just believe that beginners would not have to flash firmware again and again until they figure-out they have to take notes of all packages they try and then remove, leaving dependencies IF they ONLY use LuCI.
If any of the above is possible, a button
CLEAN DEPENDENCIES
at LuCI/Software would be perfect.

@lleachii and @hnyman have both answered your initial question, and your other questions correctly.

I'm not sure what your goal is, but taking some time learning and fully understanding package structure, and how to manage packages would be a good start.

Further info can be found on the OpenWrt site...

https://wiki.openwrt.org/doc/techref/opkg

Have a good day.

Goal? Don't bother please, there is no point me to clarify anything, what was asked is obvious.
Thanks for the links, they were already in my bookmarks before.

Have a good day.

If someone is interested in removing a package and it's dependencies at the same time, here are my conclusions about how to .
This does not remove any dependencies of rtorrent-rpc:

root@LEDE:~# opkg remove rtorrent-rpc --force-removal-of-dependent-packages
Removing package luci-app-rtorrent from root...
Not deleting modified conffile /etc/config/rtorrent.
Removing package rtorrent-rpc from root...

Then, after installing rtorrent-rpc again to test removing it once more, --autoremove does remove its dependencies (although I think there are more of them, not sure):

root@LEDE:~# opkg remove rtorrent-rpc --autoremove
Removing package rtorrent-rpc from root...
libtorrent was autoinstalled and is now orphaned, removing.
Removing package libtorrent from root...
libsigcxx was autoinstalled and is now orphaned, removing.
Removing package libsigcxx from root...
libstdcpp was autoinstalled and is now orphaned, removing.
Refusing to remove essential package libstdcpp.
Removing an essential package may lead to an unusable system, but if
you enjoy that kind of pain, you can force opkg to proceed against
its will with the option: --force-removal-of-essential-packages
No packages removed.

This is what I found, there may be differences with others, I will be glad to learn more. The purpose of this search is to try packages, keeping the most free space left when uninstall them.

Re-read the above post...

1 Like

Thanks, I have already understood it very well, what in my previous post shows I didn't? Package rtorrent-rpc is not included in the LEDE initial firmware, I installed it by opkg and I showed that uninstalling it with –force-removal-of-dependent-packages did not removed dependencies, despite the

opkg remove foo –force-removal-of-dependent-packages

adviced in a previous post. Instead, the --autoremove Force Option successfully removed the dependencies. Didn't miss something I think.

For now removing left-over dependencies is a mystery for me, as also is upgrading all packages of opkg list-upgradable at once, without copying the results after opkg upgrade pkg1 pkg2 pkg3.
Please don't take me wrong, I first used opkg with LEDE and I don't scout it, just learning by testing and asking. Thanks everyone for the help.

To answer your original question, I have successfully used the advice given in this post:
https://forum.openwrt.org/viewtopic.php?pid=316052#p316052

This is the command given in the post:
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

1 Like

@mikewse Thank you for the answer! Congratulations to you and xenith from forum.openwrt.org.
Although I used --autoremove when removing rtorrent, some packages remained, probably because there were dependencies of rtorrent-rpc etc. I see that the command takes a lot of time to be executed. The command you posted saved me about 300kb space, could be more if I had installed/removed many packages. I checked some of the removed packages and I did not found any package depending on them, so your posting was great, at least for me!
I consider the thread really [Solved] now, but if someone is the mood to post a command that checks and auto-installs missing dependencies would be even greater. I just removed libpcre

opkg remove libpcre --force-depends

and I had to

opkg install wget --force-reinstall

to have opkg reinstall libpcre.
It is just a proposal to people that find useful like me such tool-commadns and have the time to help, not a demand. Also not very important, because someone using

--force-depends

usually remembers what had removed.

Cheers and thanks again!

The command line I posted from the other thread will never remove packages that are depended upon by other packages as it only uses the "autoremove" and not the "force" feature. Personally I would at all times stay away from "force" flags as they are the ones that will break dependencies in the first place.

2 Likes

I stay away of force options too. libpcre was just a test to see if there is an automatic way to reinstall missing dependencies.

at the risk of resurrecting a dead thread wanted to post this script I hacked together to find possibly orphaned packages. it checks installed packages against the original ROM list and for any dependencies.

for i in `opkg list-installed |sed 's/ - .*//'`; do if !(cat /rom/usr/lib/opkg/status |grep -q "Package: $i") && !(opkg whatdepends $i |grep -q "depends on $i"); then echo $i; fi; done

2 Likes

I confirm the script listed the 9 packages I manually installed. It did not print any missing dependencies, obviously because there are not any at my router. Thanks @papasan!
As for "dead", the thread seems to be dead, although I would say it fully completed it's life cycle when the CLEAN DEPENDENCIES button is born...

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.