Subject: Adding DESTDIR support to pkg_add
To: None <tech-pkg@netbsd.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-pkg
Date: 01/09/2006 09:44:04
I'd like to add DESTDIR support to pkg_add. The idea would be that the
directory which is accessible as ${DESTDIR} at the time you run pkg_add
will later be the root directory (because you chroot to it, or because
you boot from a different disk, or move the disk to another system).
At present, you can sort of fake it with
DESTDIR=/wherever
PREFIX=/usr/pkg
PKG_DBDIR=/var/db/pkg
pkg_add -K ${DESTDIR}/${PKG_DBDIR} -p ${DESTDIR}/${PREFIX} pkgname.tgz
or, for syspkgs,
DESTDIR=/wherever
PREFIX=/
PKG_DBDIR=/var/db/syspkg
pkg_add -K ${DESTDIR}/${PKG_DBDIR} -p ${DESTDIR}/${PREFIX} pkgname.tgz
but the databases in ${DESTDIR}/${PKG_DBDIR}/*.db
end up with an unwanted "${DESTDIR}" as part of the file name.
I was thinking of adding a -D DESTDIR flag to pkg_add, so you could do
DESTDIR=/wherever
PREFIX=/usr/pkg
PKG_DBDIR=/var/db/pkg
pkg_add -D ${DESTDIR} -K ${PKG_DBDIR} -p ${PREFIX} pkgname.tgz
The following things would be interpreted relative to ${DESTDIR}:
PKG_DBDIR
PREFIX
@cwd directories in the PLIST
%D substitutions in the PLIST
I believe that FreeBSD's pkg_add has the ability to chroot, but I don't
want to do that, because (especially when installing syspkgs into a
previously empty directory) necessary tools might not exist in the
target directory.
Comments?
--apb (Alan Barrett)