In case we decide not to use opkg as the backend (which is somewhat problematic with the old updater and doesn’t allow some nice features, like transactions), we need to migrate from its data structures.

There are two possibilities. Either repeatedly call opkg to provide the information (eg. opkg list-installed, opkg files <package>). The other possibility is to decode its on-disk data structures.

It would also be possible to use something backwards compatible with the opkg structures (keep them up to date and use them, but add some more information to other files, like journal).

Here’s a list of files discovered to be used by opkg to store the database of installed packages.

Global files

There’s /usr/lib/opkg/status. This file lists all the installed packages. Each one is represented by a block of email-like headers, listing some basic info about the package. This is the local status of the package ‒ when it has been installed, if it is installed as a dependency or requested by a user, etc. The block could be different from router to router even for the same package, unlike the files in the following list.

Per-package files

There are some files for each installed package in the /usr/lib/opkg/info directory. The files are named after the package names, suffixed by the type of the file (eg. package-name.type). The types are following:

control

This is the description block taken vanilla from the package. The same info is also found in the repository index list.

list

Lists the files owned by the package, one file per line.

conffiles

Lists the config files owned by the package (files that shall not be overwritten by an upgrade of the package). Note that config files are also listen in list file. The file is present only if the package has some config files.

preinst
postinst
prerm
postrm

Executable scripts that are run in the right moment of installation process. They are present only if the package contains them.

It looks like some of the files are taken directly from the control.tar.gz of the package.