Listing user installed packages for when restoring OpenWrt config

Thought I would share this, thanks to chatgpt and GitHub gist by “devkid”

This will list all user installed packages, space separated so you can easily type opkg install ....

FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: '); for i in $(opkg list-installed | cut -d' ' -f1); do [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ] && echo -n "$i "; done

Or pipe it to a file in /tmp/installed_packages
Then retrieve using WinSCP etc.

FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: '); for i in $(opkg list-installed | cut -d' ' -f1); do [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ] && echo -n "$i "; done > /tmp/installed_packages.txt


You can use attended sysupgrade to include the packages in your upgrade image so you don't need to manually install packages after an upgrade.

Sysupgrade also has the -k option to create a list of packages during upgrade

Also please read the following topic about chatgpt


We had this a while ago in another thread, could be that that is the original source. I also use this from time to time.
Sometimes you just don't want to take over everything or want to do changes like switching from ksmbd to samba on an upgrade.

I still think, it would be a cool add-on, if "Download backup/Generate archive" could include that command line. I would not need auto restore of packages, just having this list being auto-generated as textfile part of the backup archive file as a convenience helper.

1 Like

With attended sysupgrade you can also select which packages to add or remove.

That's a good idea. You can post this in the feature request section and see if you get any traction.

Yeah, I've thought it would be nice if auc had an option like -w ("why" or "what"), showing everything it was going to do as sh commands or at least something cuttable'n'pasteable bits to build a customized updater script.

I know in the Luci app you can enable advanced mode and it'll show you a list of packages it'll request, you can add/remove packages. It's great!

1 Like

There's only one problem with this: it doesn't work.

If you've used an attended sysupgrade build to install your firmware, then all of the user-installed packages have exactly the same date stamp as everything else. Maybe it should filter on '^Status:.*user'? That doesn't look right, either...

1 Like

The script in this post may work well in that case. Read the other posts in that thread for more details.

1 Like

Thanks, I've been using a variant on your script for about a week now and it works quite well. My version just selects the top-level ones (unless I set an option to log everything).

    count=$(echo "$deps" | wc -w)
    if $log_all || [ "$count" -eq 0 ] ; then
1 Like