wpkg database

Introduction

The wpkg system makes use of a database to manage what is installed and make sure the installation remains coherent.

The database makes use of two sets of data: the data that is to be installed and the currently installed data. It is important to have those separate as the data to be installed needs to be verified against the data that is already installed to ensure that files never get overwritten when they shouldn't.

The database of installed packages is composed of the control.tar.gz file and the wpkg archive (an index of all the files with information about each one of them.)

The files to be installed also include the data.tar.gz file for when the installation can proceed then those files get installed.

The installed files can also be listed and searched. For example, a file installed in C:\Program Files\Windows Packager\This File.txt could be searched in the database. The result is the name of the package that installed the file. This can be useful especially if you have one bin folder with hundreds of .exe files.

The search can be slow as each wpkg archive is searched one after another. The files are very straight forward (1Kb blocks for each file entry) but if you install many packages it will have to check each one of them as it does not save an index with all the files. (Yet the Search features is rarely used.)

Database Structure

The database is a folder structure with the control.tar.gz and wpkg archive files. Note that the wkpg archive includes the status of all the different files installed. If not yet installed, it says so. This means we can know with a very fine granularity what was installed and what wasn't when an attempt fails midway.

The folder reserved for the database data is /var/lib/wpkg. It includes a tmp folder used for packages being prepared for installation. All the other folders are installed packages named after the package without the version or architecture (i.e. a package such as wpkg_0.7_win32.deb would have its control data saved in a folder named wpkg.)

Because of the strong naming convention of Debian packages, it is not possible to have two packages with the same name and thus two folders that conflict. If that were to happen, then only one of the packages could be installed.

/var/lib/wpkg/<package name>/control.tar.gz
/var/lib/wpkg/<package name>/files.wpkgar

The tmp folder includes packages with their full name, including their architecture and version. The files are saved there because when installing, it may require to load a very large number of packages (i.e. all the dependencies) before you can actually install anything and keeping everything in memory may not always be feasible.

/var/lib/wpkg/tmp/<full name>/control.tar.gz
/var/lib/wpkg/tmp/<full name>/data.tar.gz
/var/lib/wpkg/tmp/<full name>/files.wpkgar

The files.wpkgar is created and it includes the list of files found in the control.tar.gz file. This way only that file can remain in memory with all the necessary information. A simple call to a functon of the memfile class can be used to load any individual file.