Usage of opkg extras

I have successfully deployed opkg extras on my device.

However, it's not clear to me how to use this tool.

My understanding is that it's based on profiles.
My first question is:
How do I generate a profile?

The next question is:
Can I generate a custom profile that includes user-removed packages (e.g. dnsmasq) and user-installed packages (e.g. dnsmasq-full)?
Or should I generate 2 seperated profiles for this?

Another question is related to opkg extras coding:

opkg_init() {
uci import opkg < /dev/null
uci -q batch << EOI
set opkg.defaults='opkg'
set opkg.defaults.import='/etc/backup/installed_packages.txt'
set opkg.defaults.restore='auto'
set opkg.defaults.rollback='auto'
set opkg.defaults.upgr='ai'
set opkg.defaults.export='ai'
set opkg.defaults.proc='--force-depends'
set opkg.defaults.reinstall='--force-reinstall'
set opkg.defaults.newconf='/etc'

Directory /etc/backup does not exist on my device.
Does this mean I can customize this coding line

set opkg.defaults.import='<path/to/opkg_extras_profile.txt>'

Thanks for your advise.

The Wiki [literally] tells you. But to be sure in case...

Sub-command Description
save [<prof>] Save the current Opkg profile to UCI.

~ from:

:confused: You realize the "profile" is what's installed [or what you previously saved into a profile], correct?

So install/remove what you desire, and then generate a profile.

Yes, this in the Wiki - is literally a custom script, just customize it more.

:warning: (Don't use a non-persistent location to e.g. /tmp)

EDIT: I realized - you can even change the command syntax from "save" to "generate" if that confuses you.

After executing opkg save custom the config-file /etc/config/opkg now includes the relevant profile with all packages removed and installed.

Why would I generate file /etc/backup/installed_packages.txt with command opkg save if I have just updated /etc/config/opkg with a custom profile?

Good question, it logically makes no sense to me or I miss the reason for these "extras". I also don't know your use case. Some other software for OpenWrt may better fit your need (I actually though of that as I looked at this script).


  • automated update
  • firmware selector (adding custom packages)
  • etc.

This seems for a use case where someone may need a set of packages for a limited time, on a schedule, under a "test mode", etc.

@vpelletier - pinging you as the last editor of the Wiki.


Well, my use case is (traditional) backup and restore.

I'm currently running OpenWrt 21.02.3, but I consider to upgrade to 22.03.
And in case of failure I need to go back to the previous state incl. all packages and configurations.

In my opinion it's sufficient to create custom profile with opkg extras and include this with sysupgrade backup file. This means I will not create file /etc/backup/installed_packages.txt.