How do you create a dpkg admin directory?

by Bruce Adams   Last Updated November 23, 2017 13:01 PM

This was originally posted to stackoverflow (https://stackoverflow.com/questions/47099045/how-do-you-create-a-dpkg-admin-directory) but probably belongs here instead

I have a package that previously only targeted RPM based distros for which I am now building .deb packages for Debian based distros.

The aim is to simulate a test installation from user-space that is isolated from the system you are building on. It may be multi-user and you do not want to require root access just to build the software. Many of our tests simulate the installation directory structure already. This is for the next step up to simulate an actual installation using packages built.

For the RPM packages I was able to create test installations using:

WSDIR=/where/I/want/my/tests/to/run
rpmdb --initdb --dbpath "$WSDIR"/rpmdb
rpm --relocate /opt="$WSDIR"/opt --dbpath $WSDIR/rpmdb -i <package>.rpm 

The equivalent in the Debian world is something like:

dpkg --force-not-root --admindir=$WSDIR/dpkg --root=$WSDIR/install --install "$DEB" 

However, I am stuck over the equivalent to the rpmdb --initdb step.

Note that I can just unpack the archive using:

dpkg-deb -x "$DEB" $WSDIR/install

But I would prefer to be closer to how a real package is installed. Also I don't think this will run preinstall and postinstall scripts.

Similar questions have suggested using deboostrap to create a chroot environment but this creates a complete new installation. As well as being overkill it is too slow for an automated test. I intend to use this for quick tests of the installation package prior to further testing in actual test environments.

My experiments so far:

(cd $WSDIR/dpkg && mkdir alternatives info parts triggers updates)
cp /var/lib/dpkg/status $WSDIR/dpkg/status

have at best resulted in:

dpkg: error: unable to access dpkg status area: No such file or directory

which does not indicate clear what is wrong.

So how do you create a dpkg admin directory?

Tags : debian dpkg deb


Related Questions


/usr/bin/dpkg was accidentally deleted

Updated November 25, 2015 14:00 PM


apt-get install: Error: Timeout was reached?

Updated May 09, 2018 14:01 PM

Unable to remove package on Debian 7

Updated January 11, 2018 01:01 AM

MacOS Port for apt-ftparchive?

Updated October 31, 2018 18:01 PM