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)
Tue, Oct 7, 8:01 AM
Unknown Object (File)
Thu, Oct 2, 2:14 AM
Unknown Object (File)
Tue, Sep 30, 9:33 PM
Unknown Object (File)
Wed, Sep 24, 7:24 AM
Unknown Object (File)
Tue, Sep 23, 11:56 PM
Unknown Object (File)
Aug 26 2025, 7:27 AM
Unknown Object (File)
Aug 26 2025, 7:27 AM
Unknown Object (File)
Aug 26 2025, 7:20 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