Apk: how to determine which packages were "user-installed"?

Using apk, how does one determine which packages were "user-installed"?

With ipkg it seems there was a way to determine the install date/time, so one could determine which packages were installed after the firmware flashing process.

Is there a script lying around that I missed perhaps? From what I can see, there isn’t an easy way to quickly parse this out within the confines of the installation itself, instead of comparing the list at https://firmware-selector.openwrt.org/ to what is currently installed.

I do see that /etc/apk/world contains all installed packages, but no details there.

Could compare to /rom/etc/apk/world which has the original package list. This doesn’t list what was upgraded however.

grep -Fxv -f /rom/etc/apk/world /etc/apk/world

Or to list removed packages reverse the arguments:

grep -Fxv -f /etc/apk/world /rom/etc/apk/world

Thanks @DBAA, that is the idea that I was looking for. Your command listed above seems to show what was uninstalled, which is also important. For newly installed packages, just needed to change the order of the operands ( grep -Fxv -f orig.list new.list ):

root@Host:/usr# grep -Fxv -f /rom/etc/apk/world /etc/apk/world
arp-scan
arp-scan-database
fping
luci-app-advanced-reboot
luci-app-usteer
nano
snmp-utils-nossl
umdns
usteer
wpad-openssl
zram-swap


I only did a quick test and since it output a package I posted it. Of course it was listing a package I had removed. Opps.

Looking around a bit more and there is also /lib/apk/db/installed which has more information on each installed package including version. Comparing with the /rom version a list of updates could be produced in addition to adds and deletes.

The apk query applet might be useful here, as it can output its results in json which can make the parsing bit a lot easier.

apk --installed query --format json --fields name,version,depends '*dnsmasq*'

And if you want to parse through world and installed db to do various analyses, you could grab this and hack it up. (It's intended to clean out any non-top-level packages in world, hence the name.)

@efahl & @DBAA , merci beaucoup, so much stuff to think about… :+1: