Subject: Re: OS release in "make bin-install"
To: None <tech-pkg@netbsd.org>
From: Aymeric Vincent <Aymeric.Vincent@labri.fr>
List: tech-pkg
Date: 07/07/2003 23:06:24
  Hi,

> p.s. I guess this is due to the fact that in bsd.pkg.mk, the OS
> release is computed with:
> 
> rel=`${UNAME} -r | ${SED} 's@\.\([0-9]*\)[\._].*@\.\1@'`
> 
> which truncates the actual release version to the "first two
> components".

Here is a patch that should take care of this problem by first trying
the "first three components" and then reverting to only the two first
if it fails. Feel free to improve on it.

BTW, I didn't know this bin-install target, and I noticed that it
calls pkg_add without using SU_CMD. Maybe this could be fixed as
well.

Kind regards,
 Aymeric

PS: I'm not subscribed to this list.

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1203
diff -u -r1.1203 bsd.pkg.mk
--- bsd.pkg.mk	2003/07/02 23:02:23	1.1203
+++ bsd.pkg.mk	2003/07/07 21:00:02
@@ -3548,15 +3548,21 @@
 		${ECHO_MSG} "Installing from binary pkg ${PKGFILE}" ;	\
 		${PKG_ADD} ${PKGFILE} ; 				\
 	else 				 				\
-		rel=`${UNAME} -r | ${SED} 's@\.\([0-9]*\)[\._].*@\.\1@'`; \
+		rel=`${UNAME} -r`;					\
+		rels=`echo $$rel | ${SED} 's@\.\([0-9]*\)[\._].*@\.\1@'`; \
+		case "$$rel" in						\
+		*.*.*) rels="`echo $$rel | ${SED} 's@\([0-9.]*\).*@\1@'` $$rels";; \
+		esac;							\
 		arch=${MACHINE_ARCH}; 					\
-		for site in ${BINPKG_SITES} ; do 			\
+		for rel in $$rels; do					\
+		    for site in ${BINPKG_SITES} ; do 			\
 			${ECHO} Trying `eval ${ECHO} $$site`/All ; 	\
 			${SHCOMMENT} ${ECHO} ${SETENV} PKG_PATH="`eval ${ECHO} $$site`/All" ${PKG_ADD} ${BIN_INSTALL_FLAGS} ${PKGNAME}${PKG_SUFX} ; \
 			if ${SETENV} PKG_PATH="`eval ${ECHO} $$site`/All" ${PKG_ADD} ${BIN_INSTALL_FLAGS} ${PKGNAME}${PKG_SUFX} ; then \
 				${ECHO} "${PKGNAME} successfully installed."; \
-				break ; 				\
+				break 2; 				\
 			fi ; 						\
+		    done ;						\
 		done ; 							\
 		if ! ${PKG_INFO} -qe "${PKGNAME}" ; then 		\
 			${SHCOMMENT} Cycle through some FTP server here ;\