July 5, 2019

How to restore installed OpenWRT packages after a firmware update using opkg

I've been running into this problem all the time. You do a firmware update and all your packages are gone. Probably you don't know which ones were installed. Yes, there is opkg list-installed but there is a fancy version information at the end and so on. Here is a simple solution how to save all installed packages to a text file and reinstall them after your firmware update.

First of call, you have to use

opkg list-installed | awk '{ printf "%s ",$1 }' > /etc/config/installed_packages 

/etc/config is going to be saved across firmware updates, therefore it is a wise idea to put it there. Just be sure to have the checkbox "Keep settings" enabled.

After firmware update, run

 cat  /etc/config/installed_packages | xargs opkg install 

and you should be good to go. Keep in mind that some packages may be not available on your new firmware or changed names. But that is a fact independent from this howto.