Page MenuHomeFreeBSD

whereis(1): Respect PORTSDIR variable
Needs ReviewPublic

Authored by fernape on Oct 11 2023, 11:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 16, 10:53 PM
Unknown Object (File)
Thu, May 7, 10:57 AM
Unknown Object (File)
Wed, May 6, 6:59 AM
Unknown Object (File)
Sun, May 3, 9:07 PM
Unknown Object (File)
Apr 8 2026, 9:47 PM
Unknown Object (File)
Apr 6 2026, 3:24 AM
Unknown Object (File)
Apr 5 2026, 4:12 PM
Unknown Object (File)
Mar 21 2026, 10:28 AM

Details

Reviewers
None
Group Reviewers
Src Committers
Summary

Respect PORTSDIR variable for those who have the ports collection in a different
place than /usr/ports. PORTSDIR is a very common variable used in the ports
framework and in /etc/make.conf among other places.

Add note to manual page.
.Dd to be bumped at commit time.

Note that this same behavior can be achieved by doing something like:

export PORTSDIR=~/FreeBSD-repos/ports
whereis -S $PORTSDIR/** -f converseen

Assuming the shell is able to expand the **, but it is much less convenient.

Test Plan

Assuming the ports tree is in $HOME/FreeBSD-repos/ports and that there is no
/usr/ports, if we execute the following:

$ whereis converseen
converseen:

Apply the patch and run the following:

$ PORTSDIR=$HOME/FreeBSD-repos/ports ./whereis converseen
converseen: /home/fernape/FreeBSD-repos/ports/graphics/converseen

If we create the /usr/ports directory and populate some directories:

$ ls -R /usr/ports/
foo/      graphics/

/usr/ports/foo:
bar/

/usr/ports/foo/bar:

/usr/ports/graphics:
converseen/

/usr/ports/graphics/converseen:
Makefile   distinfo   pkg-descr  pkg-plist

and execute the same command we get the /usr/ports result as expected:

$ PORTSDIR=$HOME/FreeBSD-repos/ports ./whereis converseen
converseen: /usr/ports/graphics/converseen

Asking for all results gives both entries:

$ PORTSDIR=$HOME/FreeBSD-repos/ports ./whereis -a converseen
converseen: /usr/ports/graphics/converseen
/home/fernape/FreeBSD-repos/ports/graphics/converseen

Unsetting the variable works as expected:

$ ./whereis -a converseen
converseen: /usr/ports/graphics/converseen

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 53923
Build 50813: arc lint + arc unit