Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Aug 2002 04:39:53 +0000
From:      Dima Dorfman <dima@trit.org>
To:        ports@freebsd.org
Cc:        tjr@freebsd.org
Subject:   make search broken for symlinked /usr/ports
Message-ID:  <20020826043953.A02283EE1@turbine.trit.org>

next in thread | raw e-mail | index | archive | help
[ I haven't been doing a good job of following -ports lately, so
  apologies if this has been discussed before. ]

Making -L the default for `pwd` (well, more precisely, the shell
builtin pwd (see below)) has broken `make search` for ports if
$PORTSDIR (usually /usr/ports) is a symbolic link.  The search code
contains the following fragment (after removing make(1)ese):

	here=`pwd`
	cd ${PORTSDIR}
	top=`pwd`
	there=`echo "$here/" | sed s%$top%${PORTSDIR}%`

What it's trying to do is set $there to be ${PORTSDIR}/category or
just ${PORTSDIR}, depending on where you are; the magic is necessary
since it knows that ${PORTSDIR} may be a symlink, but it can't use the
real physical path because it greps for $there in the INDEX, which
hard-codes ${PORTSDIR}.  The first `pwd` returns the physical
directory since it doesn't know the logical directory, but the second
`pwd` always returns ${PORTSDIR} (the logical directory we just cd'd
into).  The fourth line thinks that $top must always appear in $here,
but this is not true if ${PORTSDIR} is a symlink (i.e., the physical
path does *not* contain ${PORTSDIR}) and the first `pwd` returns a
physical path.

There are, as I see it, two possible solutions: make -P the default
again (I don't know if this has any standards implications)
(interestingly, -P was remade the default for /bin/pwd in pwd.c
rev. 1.19; the commit log says the author is not "convinced it's a
good idea", but does not elaborate--perhaps this change should have
propogated to /bin/sh as well?), or fix the search code to account for
the second pwd returning a logical path (by specifying -P explicitly).
A patch for the latter is attached.

Note that making ${PORTSDIR} not a symlink is not a viable solution;
first, because it makes it necessary to rebuild the INDEX yourself
(instead of using the cvsup-fetched copy), and second, and more
importantly, that if the ports collection is shared with other
computers (as via NFS), it may not be possible to make ${PORTSDIR} the
same on all machines (this is necessary for search to work everywhere,
since ${PORTSDIR} is written in INDEX) without using symlinks (e.g.,
/myvol/ports vs. /.amd/myhost/host/myvol/ports).  (It *is* possible,
with a lot of evil symlinks below ${PORTSDIR} (one option), but I'd
rather not think about that, esp. when other, more correct and less
evil, solutions are possible.)

Thoughts, anyone?

Dima.

Index: bsd.port.subdir.mk
===================================================================
RCS file: /ref/cvsf/ports/Mk/bsd.port.subdir.mk,v
retrieving revision 1.43
diff -u -r1.43 bsd.port.subdir.mk
--- bsd.port.subdir.mk	5 Jul 2002 09:14:53 -0000	1.43
+++ bsd.port.subdir.mk	26 Aug 2002 04:11:23 -0000
@@ -252,7 +252,7 @@
 search: ${PORTSDIR}/INDEX
 	@here=`pwd`; \
 	cd ${PORTSDIR}; \
-	top=`pwd`; \
+	top=`pwd -P`; \
 	there=`echo "$$here/" | sed s%$$top%${PORTSDIR}%`; \
 	if [ -n "$$key" ]; then \
 	  grep $$there ${PORTSDIR}/INDEX | grep -i "${key}" | awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }'; \

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?20020826043953.A02283EE1>