How do I upgrade all of my installed packages in OpenWRT?
There no single command or argument, but you can easily do it. To upgrade all of the packages, LEDE recommends,
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
There are other less efficient ways where people use AWK and such.
An important caveat often follows with extensive use of LEDE / OpenWRT's opkg
Since OpenWrt firmware stores the base system in a compressed read-only partition, any update to base system packages will be written in the read-write partition and therefore use more space than it would if it was just overwriting the older version in the compressed base system partition. It's recommended to check the available space in internal flash memory and the space requirements for updates of base system packages.
As far as I can tell the correct answer to this question is that there is no equivalent for apt upgrade on OpenWrt and no set of commands that will create equivalent functionality. OpenWrt repos aren't maintained with the intention of keeping end user's packages updated (you're expected to move from release to release by flashing) and opkg does not handle or even check dependencies. Quotes from the OpenWrt forums:
Those of us who have more experience with OpenWrt know that it is a bad idea to use opkg upgrade (unless there is a very specific reason) as things can break. But many other users do not know -- they assume that it is just like any other linux installation and that the upgrades should work most of the time.
and
DO NOT USE OPKG UPGRADE!
Seriously, don't. Ever. Unless you know what you are doing, have a very good reason to do it, and are willing to face the consequences if you mess up your router when it doesn't go well. It will consume flash memory space, but even more importantly, there can be kernel mismatches and other broken dependencies which can cause various issues for OpenWrt -- some of them just at the nuisance level, others can be quite severe requiring re-flashing and such.
and
Never, ever use opkg upgrade - this method will likely cause you major problems and does not actually upgrade the version. Some people will say that they have used opkg upgrade successfully, but for every one of those people, there are many more who have problems caused entirely by that process - some minor, some major. Just don’t do it
In short, there is a reason there isn't a GUI option included in LUCI for performing this action. The methods being suggested for use in other answers here will achieve something similar to apt/apt-get but the underlying tools simply do not work the same way as apt or yum. The possible problems go beyond the mentioned possibility of running out of storage space (which is bad, but can be avoided if careful).
References:
https://forum.openwrt.org/t/okpg-upgrade-safeguards/30326
https://forum.openwrt.org/t/opkg-upgrade-vs-flashing-sysupgrade/58906
https://forum.openwrt.org/t/sysupgrade-instead-of-opkg-upgrade/32897/4
I'm not an OpenWRT expert, I arrived at this thread because it is still a top web search result for 'updating wrt'. After reading this thread, I continued to the OpenWrt forums, including the threads linked above. I'm only trying to help end users avoid future problems by passing on information I've found which was presumably written by those more familiar/knowledgeable on the subject than I am.
Those who wish to continue advocating the use of various commands to keep packages up to date on OpenWrt, please consider taking the time to verify with the OpenWrt team that this is a reasonable way to use the tools provided. I'd love to be proven wrong.
I have created a little script called opkg-upgrade
to deal with upgrading in a better way.
It is available on github:
https://github.com/tavinus/opkg-upgrade
It will make upgrading as easy as:
opkg-upgrade
Curl / Wget installation instructions here!
As mentioned on the readme.md file, there may be problems with upgrading though.
Possible problems:
- The squashfs problem (ROM is read-only, so upgrades takes extra space on flash or extroot).
- The dev/trunk (beta) problem (the beta versions can be soft-bricked on upgrades).
- The space problem (need enough free space for the downloads and installs).
I should also mention that upgrading from CRON is a very bad idea!
I would say that not even on a regular Linux distro blind upgrades are a good idea.
There are many things that can go wrong on upgrades and since OpenWrt usually runs on devices that can be bricked, it makes even less sense to do it unattended.
In short, the only cases where I would EVER upgrade are:
- If using extroot on a huge USB stick
- If internal Flash is 32Mb or bigger
- If NOT using dev/trunk (beta)
- If running on ext4 FS with plenty of space (x86 metal, VM, et. all)
Still, I would never upgrade from cron.
I would also think 20 times before upgrading internal Flash (even big ones), since that would degrade it faster.
My script has the option to send an e-mail report with the available updates.
So I would recommend to add the reporting tool to cron, and then people can upgrade manually after receiving the e-mail. This makes things safer while also giving the option to revise the upgrades.
Cheers!
Gus