site  contact  subhomenews

easyVoid problem with user-installed packages

March 04, 2024 — BarryK

Here is the previous blog post in this easyVoid and woofV project:

https://bkhome.org/news/202403/xbpsget-cli-utility-to-install-xbps-packages.html

In a nutshell, woofV builds an easyVoid distribution with XBPS package manager handling all package installation, update, removal, etc. woofV creates 'easy.sfs' with all packages populated in it by XBPS.

However, there is an elephant in the room. Actually, there are a couple of elephants; considering just one of them here. The problem is, how to handle user-installed packages when there is a version update?

Here is the situation...

When XBPS installs a package, its details get added to file /var/db/xbps/pkgdb-0.38.plist. This is an XML text file, and information about all installed packages are in here, in alphabetical order. If, for example, I install 'abiword', various details about it, such as the description and size, get put into that file. Also, another file gets created, /var/db/xbps/.abiword-files.plist, XML also, that lists all the files in that package.

Say that the current version of easyVoid is "240304". Now, I used woofV and create a new release, say "240405". A user of "240304" can click on the "update" icon and download the new version. The three files 'vmlinuz', 'initrd' and 'easy.sfs' are extracted from the downloaded file, and after a reboot, the user has updated.

The problem is that 'easy.sfs' has /var/db/xbps/pkgdb-0.38.plist, which is the up-to-date packages in this new release. However, because of the layered filesystem, the old /var/db/xbps/pkgdb-0.38.plist will be "on top".

...which is just the start of the problems.

That particular problem is solved by the 'init' script in the initrd, which will delete /mnt/wkg/.session/var/db/xbps, that is, the folder on the top read-write layer. So, the /var/db/xbps files in easy.sfs will appear "on top".

The real problem is that this new 'pkgdb-0.38.plist' will not contain the information about any of the user-installed packages, nor will there be any '.<package name>-files.plist' files. XBPS will no longer know that they are installed. That is one of the elephants.

I thought of two possible solutions. Firstly, use XBPS to uninstall the user-installed packages before the reboot, then reinstall them after booting up the new release. Secondly, extract all the user-installed information out of pkgdb-0.38.plist, then merge it into the new pkgdb-0.38.plist after rebooting to the new release.

I decided on the latter solution. To implement that, wrote two scripts, 'pkgdb-extract-users' and 'pkgdb-merge-users'. Here they are:

https://github.com/bkauler/woofq/blob/main/easyos/easy-code/rootfs-skeleton/usr/local/woofV/support/pkgdb-extract-users

https://github.com/bkauler/woofq/blob/main/easyos/easy-code/rootfs-skeleton/usr/local/woofV/support/pkgdb-merge-users

...probably they could be implemented more efficiently using 'xmllint', 'xml2' and/or 'awk'.

When you click on the "update" desktop icon, the script /usr/local/easy_version/easy-update runs, and this will now run 'pkgdb-extract-users'. At reboot, the 'init' script in the initrd will delete the old pkgdb-0.38.plist and the hidden files, then /etc/rc.d/rc.update will run 'pkgdb-merge-users'. The changes to those three scripts are here:

https://github.com/bkauler/woofq/commit/9cb568dc618f00ea9393ac1d8fe81ae00a07b9bb

Could get XBPS to do an automatic update of user-installed packages also; will probably add that.

This is not yet tested.

As an extra note, I found it an interesting read; wiak, rockedge, jamesbond and peebee deliberating on the early design of VoidPup:

https://forum.puppylinux.com/viewtopic.php?t=4741

Hopefully one elephant has been negotiated out of the back door. Or rather, I had to demolish a wall to get it out. The other elephant is handling of the 'devx' SFS, which will be considered soon.

I would like to add one extra comment. It is awkward getting XBPS to function with a layered filesystem, aufs or overlayfs; however, it does bring a major advantage, support for snapshots. XBPS knows nothing about snapshots, but this is inherent in the design of EasyOS, and indeed in all layer-based pups such as those built from Woof-CE.

In the case of Easy, the previous 'vmlinuz', 'initrd' and 'easy.sfs' files will still exist. So, perchance you don't like the latest version, easy-peasy can roll back to the previous. So, we are adding major functionality to XBPS.        

Tags: easy