Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Aug 2007 01:53:40 -0400
From:      Kris Kennaway <kris@obsecurity.org>
To:        ports@FreeBSD.org
Subject:   PORTSDIR use-before-define fix
Message-ID:  <20070805055340.GA11899@rot26.obsecurity.org>

next in thread | raw e-mail | index | archive | help

--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Previous DESTDIR commits introduced dereferences of ${PORTSDIR} before
it was set (via .include), which broke e.g. portmaster.  This diff
shuffles some things around to hopefully restore everything to being
defined before it is used.  It also cleans up some stale cruft.  It
has only been lightly tested.

Kris

Index: bsd.port.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.579
diff -u -r1.579 bsd.port.mk
--- bsd.port.mk	4 Aug 2007 19:48:34 -0000	1.579
+++ bsd.port.mk	5 Aug 2007 05:50:10 -0000
@@ -1089,6 +1089,17 @@
 # Most port authors should not need to understand anything after this poin=
t.
 #
=20
+# These need to be absolute since we don't know how deep in the ports
+# tree we are and thus can't go relative.  They can, of course, be overrid=
den
+# by individual Makefiles or local system make configuration.
+PORTSDIR?=3D		/usr/ports
+LOCALBASE?=3D		/usr/local
+X11BASE?=3D		${LOCALBASE}
+LINUXBASE?=3D		/compat/linux
+DISTDIR?=3D		${PORTSDIR}/distfiles
+_DISTDIR?=3D		${DISTDIR}/${DIST_SUBDIR}
+INDEXDIR?=3D		${PORTSDIR}
+
 .include "${PORTSDIR}/Mk/bsd.commands.mk"
=20
 #
@@ -1294,16 +1305,6 @@
 PKGNAME=3D	${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PKGVERSION}
 DISTNAME?=3D	${PORTNAME}-${DISTVERSIONPREFIX}${DISTVERSION:C/:(.)/\1/g}${D=
ISTVERSIONSUFFIX}
=20
-# These need to be absolute since we don't know how deep in the ports
-# tree we are and thus can't go relative.  They can, of course, be overrid=
den
-# by individual Makefiles or local system make configuration.
-PORTSDIR?=3D		/usr/ports
-LOCALBASE?=3D		/usr/local
-X11BASE?=3D		${LOCALBASE}
-LINUXBASE?=3D		/compat/linux
-DISTDIR?=3D		${PORTSDIR}/distfiles
-_DISTDIR?=3D		${DISTDIR}/${DIST_SUBDIR}
-INDEXDIR?=3D		${PORTSDIR}
 INDEXFILE?=3D		INDEX-${OSVERSION:C/([0-9]).*/\1/}
=20
 DOCSDIR?=3D		${PREFIX}/share/doc/${PORTNAME}
@@ -2300,7 +2301,6 @@
 .undef NO_PACKAGE
 .endif
=20
-COMMENTFILE?=3D	${PKGDIR}/pkg-comment
 DESCR?=3D			${PKGDIR}/pkg-descr
 PLIST?=3D			${PKGDIR}/pkg-plist
 PKGINSTALL?=3D	${PKGDIR}/pkg-install
Index: bsd.port.subdir.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/pcvs/ports/Mk/bsd.port.subdir.mk,v
retrieving revision 1.71
diff -u -r1.71 bsd.port.subdir.mk
--- bsd.port.subdir.mk	4 Aug 2007 11:37:24 -0000	1.71
+++ bsd.port.subdir.mk	5 Aug 2007 05:50:10 -0000
@@ -40,6 +40,21 @@
 #		Search for ports using either 'make search key=3D<keyword>'
 #		or 'make search name=3D<keyword>'.
=20
+PORTSDIR?=3D		/usr/ports
+TEMPLATES?=3D		${PORTSDIR}/Templates
+.if defined(PORTSTOP)
+README=3D			${TEMPLATES}/README.top
+.else
+README=3D			${TEMPLATES}/README.category
+.endif
+MOVEDDIR?=3D		${PORTSDIR}
+MOVEDFILE?=3D		MOVED
+
+# XXX Are these needed here?  DESCR was set wrong for a few years
+MASTERDIR?=3D     ${.CURDIR}
+PKGDIR?=3D		${MASTERDIR}
+DESCR?=3D			${PKGDIR}/pkg-descr
+
 .include "${PORTSDIR}/Mk/bsd.commands.mk"
=20
 .MAIN: all
@@ -66,6 +81,9 @@
 .endif
 .endif
=20
+INDEXDIR?=3D	${PORTSDIR}
+INDEXFILE?=3D	INDEX-${OSVERSION:C/([0-9]).*/\1/}
+
 UID!=3D	${ID} -u
 .if exists(${LOCALBASE}/sbin/pkg_info)
 PKG_INFO?=3D	${LOCALBASE}/sbin/pkg_info
@@ -249,28 +267,6 @@
 	@${MAKE} README.html
 .endif
=20
-.if (${OPSYS} =3D=3D "NetBSD")
-PORTSDIR ?=3D /usr/opt
-.else
-PORTSDIR ?=3D /usr/ports
-.endif
-TEMPLATES ?=3D ${PORTSDIR}/Templates
-.if defined(PORTSTOP)
-README=3D	${TEMPLATES}/README.top
-.else
-README=3D	${TEMPLATES}/README.category
-.endif
-COMMENTFILE?=3D	${.CURDIR}/pkg/COMMENT
-DESCR?=3D		${.CURDIR}/pkg/DESCR
-INDEXDIR?=3D	${PORTSDIR}
-.if ${OSVERSION} >=3D 500036
-INDEXFILE?=3D	INDEX-${OSVERSION:C/([0-9]).*/\1/}
-.else
-INDEXFILE?=3D	INDEX
-.endif
-MOVEDDIR?=3D	${PORTSDIR}
-MOVEDFILE?=3D	MOVED
-
 HTMLIFY=3D	${SED} -e 's/&/\&amp;/g' -e 's/>/\&gt;/g' -e 's/</\&lt;/g'
=20
 package-name:
@@ -298,9 +294,6 @@
 .if defined(COMMENT)
 	@${ECHO_CMD} "${COMMENT}" | ${HTMLIFY} > $@.tmp4
 .else
-.if exists(${COMMENTFILE})
-	@${HTMLIFY} ${COMMENTFILE} > $@.tmp4
-.else
 	@> $@.tmp4
 .endif
 .endif
@@ -415,7 +408,7 @@
                        break; \
                  }\
 	      } \
-      	    if (toprint =3D=3D 1 ) disp[fields[d[i]]] =3D 1; \
+	    if (toprint =3D=3D 1 ) disp[fields[d[i]]] =3D 1; \
 	    } \
 	  } \
 	  { \

--jRHKVT23PllUwdXP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFGtWXjWry0BWjoQKURAtgiAJ4lulypxlCN3YRK36OqMu6SWm819ACeJ5pa
pxif9vMqVJam9IRp04qjc/I=
=8W37
-----END PGP SIGNATURE-----

--jRHKVT23PllUwdXP--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070805055340.GA11899>