Date: Thu, 14 Jun 2001 15:26:53 -0600 (MDT) From: jhein@timing.com To: FreeBSD-gnats-submit@freebsd.org Subject: ports/28155: DESTDIR is used incorrectly in bsd.port.mk Message-ID: <200106142126.f5ELQrf48612@Elmer.timing.com>
next in thread | raw e-mail | index | archive | help
>Number: 28155 >Category: ports >Synopsis: DESTDIR is used incorrectly in bsd.port.mk >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jun 14 14:30:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: John E. Hein >Release: FreeBSD 4.3-RELEASE-TSC i386 >Organization: Timing Solutions Corporation >Environment: FreeBSD flash.timing.com 4.3-RELEASE-TSC FreeBSD 4.3-RELEASE-TSC #0: Wed Jun 13 16:13:53 MDT 2001 imp@marvin.timing.com:/net/brain/uv/staging/imp/FreeBSD-tsc-4/sys/compile/FLASH i386 >Description: DESTDIR should not interfere with PREFIX. PREFIX is really the run-time location of the port. DESTDIR is where it gets installed. These may not be the same thing. Unfortunately, bsd.port.mk simply prefixes LOCALBASE, X11BASE & LINUXBASE with DESTDIR. If PREFIX is not specified to override these values, PREFIX will contain DESTDIR. Not only bsd.port.mk, but many port Makefiles are broken in this regard. For example, many post-install targets specify something like: ${INSTALL_PROGRAM} ${WRKSRC}/foo ${PREFIX}/bin They should probably read: ${INSTALL_PROGRAM} ${WRKSRC}/foo ${DESTDIR}/${PREFIX}/bin But, before we fix the ports, we have to fix bsd.port.mk The included patch does that. If anyone seriously tries to use DESTDIR for its intended use, many ports won't work anyway. Please commit the patch to bsd.port.mk Feel free to try it out first. Send me feedback. Ask for its commit in freebsd-ports. Pester portmgr@FreeBSD.org It's a large step in fixing the problem with the ports system's inability to install in non-standard paths. It's time we fixed this. >How-To-Repeat: Let's suppose you want to install a port for system B on a removable drive bay on system A... sudo mount /dev/da1s1g /mnt_B/usr sudo mount /dev/da1s1a /mnt_B/root Now I want to install, say, the glib port to /mnt_B/usr/local. cd /usr/ports/devel/glib12 sudo make DESTDIR=/mnt_B PKG_DBDIR=/mnt_B/root/var/db/pkg install umount /mnt_B/root umount /mnt_B/usr Now, move the disk to system B and boot it. Now, run /usr/local/bin/glib-config --cflags and get: -I/mnt_B/usr/local/include/glib12 That is wrong. It should read -I/usr/local/include/glib12 >Fix: First, give a heads up that the following patch will be applied in, say, a week or two. Notify maintainers about it and have them fix their ports to handle DESTDIR & PREFIX correctly in preparation for this commit. Then apply the following patch to bsd.port.mk and commit. Then tell maintainers to commit their fixed ports. $ cvs diff -u bsd.port.mk Index: bsd.port.mk =================================================================== RCS file: /base/FreeBSD-CVS/ports/Mk/bsd.port.mk,v retrieving revision 1.367 diff -u -r1.367 bsd.port.mk --- bsd.port.mk 2001/05/23 02:46:52 1.367 +++ bsd.port.mk 2001/05/27 13:39:33 @@ -600,9 +600,22 @@ .else PORTSDIR?= /usr/ports .endif -LOCALBASE?= ${DESTDIR}/usr/local -X11BASE?= ${DESTDIR}/usr/X11R6 -LINUXBASE?= ${DESTDIR}/compat/linux +LOCALBASE?= /usr/local +X11BASE?= /usr/X11R6 +LINUXBASE?= /compat/linux +.if defined(DESTDIR) +.if defined(USE_GMAKE) +# Tell gmake makefiles to override any local definition of DESTDIR with +# our definition. +MAKE_ARGS+= DESTDIR=${DESTDIR} +.else +# FreeBSD's make is not the same as gmake in being able to override VAR=FOO +# style definitions in the makefile with VAR=SOMETHING_ELSE passed on the +# command line to make, but we can use -E to get similar behavior. +MAKE_ARGS+= -E DESTDIR +MAKE_ENV+= DESTDIR=${DESTDIR} +.endif +.endif DISTDIR?= ${PORTSDIR}/distfiles _DISTDIR?= ${DISTDIR}/${DIST_SUBDIR} .if defined(USE_BZIP2) @@ -1064,7 +1077,7 @@ PKG_DELETE?= /usr/sbin/pkg_delete PKG_INFO?= /usr/sbin/pkg_info .if !defined(PKG_ARGS) -PKG_ARGS= -v -c ${COMMENT} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`" ${EXTRA_PKG_ARGS} +PKG_ARGS= -v -c ${COMMENT} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -s ${DESTDIR}/${PREFIX} -P "`${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`" ${EXTRA_PKG_ARGS} .if exists(${PKGINSTALL}) PKG_ARGS+= -i ${PKGINSTALL} .endif @@ -1271,7 +1284,8 @@ WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \ SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \ PORTSDIR=${PORTSDIR} DEPENDS="${DEPENDS}" \ - PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} + PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} \ + DESTDIR=${DESTDIR} .if defined(BATCH) SCRIPTS_ENV+= BATCH=yes @@ -1302,7 +1316,7 @@ else \ { print "broken"; exit; } \ } \ - }' | ${SED} -e 's \([^/ ][^ ]*\.\(.\)[^. ]*\) $${MAN\2PREFIX}/man/$$$$$$$${__lang}/man\2/\1.gzg' -e 's/ //g' -e 's/MANlPREFIX/MANLPREFIX/g' -e 's/MANnPREFIX/MANNPREFIX/g' + }' | ${SED} -e 's \([^/ ][^ ]*\.\(.\)[^. ]*\) ${DESTDIR}/$${MAN\2PREFIX}/man/$$$$$$$${__lang}/man\2/\1.gzg' -e 's/ //g' -e 's/MANlPREFIX/MANLPREFIX/g' -e 's/MANnPREFIX/MANNPREFIX/g' .if ${__pmlinks:Mbroken} == "broken" .BEGIN: @${ECHO} "${PKGNAME}: Unable to parse MLINKS." @@ -1322,30 +1336,31 @@ .for sect in 1 2 3 4 5 6 7 8 9 .if defined(MAN${sect}) -_MANPAGES+= ${MAN${sect}:S%^%${MAN${sect}PREFIX}/man/${lang}/man${sect}/%} +JUNK=1 +_MANPAGES+= ${MAN${sect}:S%^%${DESTDIR}/${MAN${sect}PREFIX}/man/${lang}/man${sect}/%} .endif .endfor .if defined(MANL) -_MANPAGES+= ${MANL:S%^%${MANLPREFIX}/man/${lang}/manl/%} +_MANPAGES+= ${MANL:S%^%${DESTDIR}/${MANLPREFIX}/man/${lang}/manl/%} .endif .if defined(MANN) -_MANPAGES+= ${MANN:S%^%${MANNPREFIX}/man/${lang}/mann/%} +_MANPAGES+= ${MANN:S%^%${DESTDIR}/${MANNPREFIX}/man/${lang}/mann/%} .endif .endfor .if defined(_MLINKS) && make(generate-plist) -_TMLINKS!= ${ECHO} ${_MLINKS} | ${AWK} '{for (i=2; i<=NF; i+=2) print $$i}' +_TMLINKS!= ${ECHO} ${_MLINKS} | ${AWK} '{for (i=2; i<=NF; i+=2) print $$i}' | ${SED} 's,^${DESTDIR}/,,' .else _TMLINKS= .endif .if defined(_MANPAGES) && defined(NOMANCOMPRESS) -__MANPAGES:= ${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g} +__MANPAGES:= ${_MANPAGES:S^${DESTDIR}/^^:S^${PREFIX}/^^:S/""//:S^//^/^g} .elif defined(_MANPAGES) -__MANPAGES:= ${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g:S/$/.gz/} +__MANPAGES:= ${_MANPAGES:S^${DESTDIR}/^^:S^${PREFIX}/^^:S/""//:S^//^/^g:S/$/.gz/} .endif .if defined(_MANPAGES) && ${MANCOMPRESSED} == "yes" @@ -1962,10 +1977,10 @@ .if make(real-install) @${MKDIR} ${PREFIX} @if [ `id -u` != 0 ]; then \ - if [ -w ${PREFIX}/ ]; then \ + if [ -w ${DESTDIR}/${PREFIX}/ ]; then \ ${ECHO_MSG} "Warning: not superuser, you may get some errors during installation."; \ else \ - ${ECHO_MSG} "Error: ${PREFIX}/ not writable."; \ + ${ECHO_MSG} "Error: ${DESTDIR}/${PREFIX}/ not writable."; \ ${FALSE}; \ fi; \ fi >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106142126.f5ELQrf48612>