30

I'm just wondering what is the equivalent of

apt-get upgrade
apt upgrade
yum update

with OpenWRT or LEDE?

63

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 LEDE 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.

|improve this answer|||||
  • 1
    another way to do this is with a shell for loop. e.g.> for a in `opkg list-upgradable | cut -f 1 -d ' '` ; do opkg upgrade "$a" ; done – Scott Jul 24 '18 at 14:29
  • 1
    "There are other less efficient ways where people use AWK and such" is a bit snide. awk '{print$1}' has just as few characters as that cut command and awk isn't fooled by multiple spaces (its delimiter is an ~extended regex that defaults to [[:space:]]+). OpenWRT doesn't have enough packages for @Scott's above command to be problematic, but using xargs would avoid errors regarding a command line that's too long (since `…` and $(…) are fully expanded before running a command that uses them). – Adam Katz Feb 15 at 23:07
  • hehe, yeah and often times when you look inside tools like opkg, you find out it's a script using awk and sed or a compiled binary doing essentially the same things in whatever language was used to build it. – Scott Feb 17 at 2:12
6

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

|improve this answer|||||
1

As of OpenWrt 19.07, performing opkg upgrade [pkgname] may throw this error.

Collected errors:
 * pkg_hash_add_from_file: Failed to open /var/opkg-lists/openwrt_routing: Out of memory.

A workaround is to use opkg install instead, which is the same as how luci-app-opkg upgrades packages.

opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg install 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.