You might want to check what packages you installed on OpenWrt, for example when wanting to build a custom image based on your installation or to restore the packages after an upgrade. I found a neat little script that lets you do just that!
The script I found on a GitHub gist by “devkid” and has the following contents:
#!/bin/sh
FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: ')
for i in $(opkg list-installed | cut -d' ' -f1)
do
if [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ]
then
echo $i
fi
done
Assuming you have curl installed with TLS support, you can download it to your device with:
curl -sSLo list.sh https://gist.githubusercontent.com/devkid/8d4c2a5ab62e690772f3d9de5ad2d978/raw/61e266674bcae03f4929299c1ac27e935c985280/list-user-installed-packages.sh
Make it executable with:
chmod +x list.sh
And then simply run it with ./list.sh
as you normally would. Just wait for it to go through your packages and list the ones you installed manually.
You can now copy the list to your local machine and keep it safe until the upgrade is complete. Afterwards put the list into a file like, say, packages.txt and re-install them with a command like:
opkg update && for i in `cat packages.txt`; do opkg install $i; done
And that’s how you list user installed packages in OpenWrt. Now go upgrade OpenWrt or build an image! ;)
You can update busybox via opkg update, so it’s install time can be wrong as reference.
As a result you will have wrong list.
Only one thing you cannot install via opkg is kernel – because you update it over flashing new firmware.
So the kernel’s install time should be used as flash time.
FLASH_TIME=$(opkg info kernel | grep ‘^Installed-Time: ‘)