Subject: Getting rid of pkg_install special handling
To: None <tech-pkg@netbsd.org>
From: Thomas Klausner <wiz@netbsd.org>
List: tech-pkg
Date: 04/23/2005 12:52:58
--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi!
The pkg_install package is currently a special case: It cannot be
pkg_deleted and is hard to update for this reason.
AFAICT, the reason for this is that we don't want to end up with
a system where there are no pkg tools installed.
Also, when the pkg tools are outdated, package builds fail and tell
the user to update the package manually, instead of the usual
dependency handling or automatic updating (I guess for a similar
reason).
This is not really necessary for a system that's using source
packages, since you can always go to pkg tools/pkg_install and do
'make install'. I tested this without any pkg_* in a chroot, and
I got lots of pkg_admin-not-found warnings, but a 'make install'
worked and registered the package successfully.
So there is a way to get pkg tools on a source package using system.
Then there are binary package systems, using packages compiled on
other systems. We need a way to install a pkg_install package
without any pkg_* installed. So dillo and I sat down and wrote a
small shell script that does exactly that: extract a pkg_add binary
from a pkg_install binary package and use that to install the
pkg_install binary package itself.
So if we make sure that this shell script gets created whenever a
pkg_install binary package is created, we can install pkg_install
from source and from binary package, even on systems with no pkg_*
tools installed. This way we can get rid of most parts of the
special handling of the pkg_install package, like in particular
the PKG_PRESERVE hack and the outdated pkg_install package handling.
Of course, this needs documentation updates, which I'll do.
The shell script is attached. It needs a better name, and in two
places @FOO@ variables need to be replaced instead of being hardcoded
for testing right now.
Does anyone see any problems with this approach?
Cheers,
Thomas
--IS0zKkzwUGydFO0o
Content-Type: application/x-sh
Content-Disposition: attachment; filename="pkg_install_fallback.sh"
Content-Transfer-Encoding: quoted-printable
#!/bin/sh=0A=0A# check argument=0Aif [ "$#" -eq "0" ]=0Athen=0A dir=3D"`dir=
name $0`"=0A n=3D"`ls $dir/pkg_install-????????.tgz 2>/dev/null | wc -l`"=
=0A if [ "$n" -eq "0" ]=0A then=0A echo "$0: cannot find pkg_install-?????=
???.tgz" 2>&1=0A exit 1=0A elif [ "$n" -ne "1" ]=0A then=0A echo "$0: mul=
tiple pkg_install-????????.tgz found" 2>&1=0A exit 1=0A fi=0A PKG_INSTALL_=
PACKAGE=3D"`ls $dir/pkg_install-????????.tgz`"=0Aelif [ "$#" -eq "1" ]=0Ath=
en=0A PKG_INSTALL_PACKAGE=3D"$1"=0Aelse=0A echo usage: $0 pkg_install-YYYYM=
MDD.tgz >&2=0A exit 1=0Afi=0A=0Aif [ ! -f "${PKG_INSTALL_PACKAGE}" -o ! -r =
"${PKG_INSTALL_PACKAGE}" ]=0Athen=0A echo $0: \"${PKG_INSTALL_PACKAGE}\" no=
t a readable file >&2=0A exit 1=0Afi=0A=0A# choose location to extract to=
=0Aif [ -z "$TMPDIR" ]=0Athen=0A TMPDIR=3D/tmp=0Afi=0AEXTRACT_TO=3D"$TMPDIR=
/dasscript.$$"=0A(umask 077 && mkdir "${EXTRACT_TO}")=0Aif [ $? -ne 0 ]=0At=
hen=0A echo $0: cannot create temporary directory \""${EXTRACT_TO}"\" >&2=
=0A exit 1=0Afi=0A=0AGZIP_CMD=3D@GZIP_CMD@=0AGZIP_CMD=3Dgzip=0ATAR=3D@TAR@=
=0ATAR=3Dtar=0A=0A# extract pkg_add from pkg_install binary package=0A${GZI=
P_CMD} -cd "${PKG_INSTALL_PACKAGE}" | \=0A (cd "${EXTRACT_TO}" && \=0A ${TA=
R} xf - sbin/pkg_add)=0Aif [ $? -ne 0 ]=0Athen=0A echo $0: cannot extract \=
"sbin/pkg_add\" from \""${PKG_INSTALL_PACKAGE}"\" >&2=0A rmdir "${EXTRACT_T=
O}" 2>/dev/null=0A exit 1=0Afi=0A=0A# use pkg_add to install pkg_install bi=
nary package=0A"${EXTRACT_TO}"/sbin/pkg_add "${PKG_INSTALL_PACKAGE}"=0Aif [=
$? -ne 0 ]=0Athen=0A echo $0: pkg_add \""${PKG_INSTALL_PACKAGE}"\" failed =
>&2=0A rm "${EXTRACT_TO}"/sbin/pkg_add 2>/dev/null=0A rmdir "${EXTRACT_TO}"=
/sbin 2>/dev/null=0A rmdir "${EXTRACT_TO}" 2>/dev/null=0A exit 1=0Afi=0A=0A=
rm "${EXTRACT_TO}"/sbin/pkg_add=0Armdir "${EXTRACT_TO}"/sbin=0Armdir "${EXT=
RACT_TO}"=0A=0Aecho pkg_install has been successfully installed=0A=0Aexit 0=
=0A
--IS0zKkzwUGydFO0o--