tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Tentative "fix" for "pkg_info -E" problem



The following patch allows me to do the following on NetBSD-3.1 with
a current pkgsrc:

# cd pkgsrc/archivers/mousetar
# make show-var VARNAME=PKG_INFO_CMD
/usr/sbin/pkg_info
# make
=> Bootstrap dependency pkg_install>=20070802: NOT found
...
=> Registering installation for mousetar-20021217
# make show-var VARNAME=PKG_INFO_CMD
/usr/pkg/sbin/pkg_info
# /usr/pkg/sbin/pkg_info
pkg_install-20080313 Package management and administration tools for pkgsrc
digest-20070803     Message digest wrapper utility
mousetar-20021217   der Mouse's version of tar program

I am hoping that folks with faster computers and more bandwidth can
test the cases that were broken for them, especially the problems with
mk/bulk.

If this seems to work, then I'll commit this so that we can branch
pkgsrc.

        Thanks,

        -- Johnny C. Lam
Index: bootstrap/pkg_wrapper.sh
===================================================================
RCS file: bootstrap/pkg_wrapper.sh
diff -N bootstrap/pkg_wrapper.sh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ bootstrap/pkg_wrapper.sh    1 Apr 2008 20:47:26 -0000
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+# This script wraps the pkg_* tools in such a way that it will avoid
+# using features that were introduced after 20070813, specifically
+# ``pkg_info -E''.
+#
+# As of 20080401, this is used to wrap "pkg_admin" and "pkg_info"
+# in pkgsrc/mk/flavor/pkg/flavor-vars.mk, which are used during
+# the bootstrap-depends stage.
+#
+# XXX This script is really a hack and is not guaranteed to work in
+# XXX the future.  A better fix needs to be found so that NetBSD
+# XXX users with pkg_* in /usr/sbin can seamless use pkgsrc that
+# XXX requires a newer pkg_install.
+#
+
+: ${LOCALBASE:=/usr/pkg}
+: ${PKG_TOOLS_BIN:=/usr/sbin}
+
+cmd="pkg_$1"; shift
+
+version=`${PKG_TOOLS_BIN}/$cmd -V 2>/dev/null || echo 20010302`
+
+if [ $version -ge 20070813 ]; then
+       cmd="${PKG_TOOLS_BIN}/$cmd"
+elif [ -x "${LOCALBASE}/sbin/$cmd" ]; then
+       cmd="${LOCALBASE}/sbin/$cmd"
+else
+       cmd="${PKG_TOOLS_BIN}/$cmd"
+fi
+
+if [ $version -lt 20070813 ]; then
+       case $cmd in
+       */pkg_info)
+               while [ $# -gt 0 ]; do
+                       case $1 in
+                       -E)     arg="-e" ;;
+                       *)      arg="$1" ;;
+                       esac
+                       shift
+                       cmd="$cmd \"$arg\""
+               done
+               eval $cmd
+               ;;
+       *)
+               $cmd "$@"
+               ;;
+       esac
+else
+       $cmd "$@"
+fi
Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1940
diff -u -r1.1940 bsd.pkg.mk
--- mk/bsd.pkg.mk       8 Mar 2008 14:28:05 -0000       1.1940
+++ mk/bsd.pkg.mk       1 Apr 2008 20:47:26 -0000
@@ -116,13 +116,6 @@
 _INSTALL_UNSTRIPPED=   # set (flag used by platform/*.mk)
 .endif
 
-##### Non-overridable constants
-
-# Latest versions of tools required for correct pkgsrc operation.
-PKGTOOLS_REQD=         20070802
-# Versions of tools that are good enough to handle dependencies
-PKGTOOLS_BASE_REQD=    20051103
-
 ##### Transform USE_* into dependencies
 
 .include "bsd.pkg.use.mk"
@@ -147,19 +140,6 @@
 PKG_FAIL_REASON+=      "This package doesn't support 
PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE}."
 .endif
 
-# Check that we are using up-to-date pkg_* tools with this file.
-.if !defined(NO_PKGTOOLS_REQD_CHECK)
-.  if ${PKGTOOLS_VERSION} < ${PKGTOOLS_BASE_REQD}
-PKG_FAIL_REASON+='The package tools installed on this system are out of date.'
-PKG_FAIL_REASON+='The installed package tools are dated 
${PKGTOOLS_VERSION:C|(....)(..)(..)|\1/\2/\3|} and you must'
-PKG_FAIL_REASON+='update them to at least 
${PKGTOOLS_REQD:C|(....)(..)(..)|\1/\2/\3|} using the following command:'
-PKG_FAIL_REASON+=' '
-PKG_FAIL_REASON+='    (cd ${PKGSRCDIR}/pkgtools/pkg_install && ${MAKE} clean 
&& ${MAKE} update)'
-.  elif ${PKGTOOLS_VERSION} < ${PKGTOOLS_REQD}
-BOOTSTRAP_DEPENDS+=    pkg_install>=${PKGTOOLS_REQD}:../../pkgtools/pkg_install
-.  endif
-.endif # !NO_PKGTOOLS_REQD_CHECK
-
 .if defined(ALL_TARGET)
 PKG_FAIL_REASON+='ALL_TARGET is deprecated and must be replaced with 
BUILD_TARGET.'
 .endif
Index: mk/flavor/pkg/flavor-vars.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/flavor/pkg/flavor-vars.mk,v
retrieving revision 1.7
diff -u -r1.7 flavor-vars.mk
--- mk/flavor/pkg/flavor-vars.mk        10 Mar 2008 20:05:59 -0000      1.7
+++ mk/flavor/pkg/flavor-vars.mk        1 Apr 2008 20:47:26 -0000
@@ -35,11 +35,51 @@
 PKG_VIEW_CMD?=         ${PKG_TOOLS_BIN}/pkg_view
 LINKFARM_CMD?=         ${PKG_TOOLS_BIN}/linkfarm
 
+# Latest versions of tools required for correct pkgsrc operation.
+PKGTOOLS_REQD=         20070802
+# Versions of tools that are good enough to handle dependencies
+PKGTOOLS_BASE_REQD=    20051103
+
 .if !defined(PKGTOOLS_VERSION)
 PKGTOOLS_VERSION!=     ${PKG_INFO_CMD} -V 2>/dev/null || echo 20010302
 MAKEFLAGS+=            PKGTOOLS_VERSION=${PKGTOOLS_VERSION}
 .endif
 
+# Check that we are using up-to-date pkg_* tools with this file.
+.if !defined(NO_PKGTOOLS_REQD_CHECK)
+.  if ${PKGTOOLS_VERSION} < ${PKGTOOLS_BASE_REQD}
+PKG_FAIL_REASON+='The package tools installed on this system are out of date.'
+PKG_FAIL_REASON+='The installed package tools are dated 
${PKGTOOLS_VERSION:C|(....)(..)(..)|\1/\2/\3|} and you must'
+PKG_FAIL_REASON+='update them to at least 
${PKGTOOLS_REQD:C|(....)(..)(..)|\1/\2
+/\3|} using the following command:'
+PKG_FAIL_REASON+=' '
+PKG_FAIL_REASON+='    (cd ${PKGSRCDIR}/pkgtools/pkg_install && ${MAKE} clean 
&& ${MAKE} update)'
+.  elif ${PKGTOOLS_VERSION} < ${PKGTOOLS_REQD}
+BOOTSTRAP_DEPENDS+=    pkg_install>=${PKGTOOLS_REQD}:../../pkgtools/pkg_install
+#
+# XXX This is a hack to allow NetBSD users with old pkg_* in /usr/sbin to
+# XXX use current pkgsrc.  It works by forcing PKG_TOOLS_BIN to point to
+# XXX the location where the new pkg_install binaries will be located,
+# XXX then wrapping calls to ``pkg_admin'' and ``pkg_info'' to allow the
+# XXX old ones in /usr/sbin to be used just for the bootstrap-depends
+# XXX phase.
+# XXX
+# XXX This is really a hack and is not guaranteed to work in the future.
+# XXX A better fix needs to be found so that NetBSD users with pkg_* in
+# XXX /usr/sbin can seamless use pkgsrc that requires a newer pkg_install.
+#
+.    if empty(PKG_TOOLS_BIN:M${LOCALBASE}/sbin)
+_OLD_PKG_TOOLS_BIN:=   ${PKG_TOOLS_BIN}
+PKG_TOOLS_BIN=         ${LOCALBASE}/sbin
+_PKG_WRAPPER_CMD=      ${SETENV} LOCALBASE=${LOCALBASE:Q} \
+                               PKG_TOOLS_BIN=${_OLD_PKG_TOOLS_BIN:Q} \
+                       ${SH} ${PKGSRCDIR}/bootstrap/pkg_wrapper.sh
+PKG_ADMIN_CMD=         ${_PKG_WRAPPER_CMD} admin
+PKG_INFO_CMD=          ${_PKG_WRAPPER_CMD} info
+.    endif
+.  endif
+.endif # !NO_PKGTOOLS_REQD_CHECK
+
 # audit-packages logic for its location depends on a variety of factors
 # including OS, pkg_install version and NetBSD version.  The following
 # should pick the correct version to run.


Home | Main Index | Thread Index | Old Index