From nobody Sun Sep 06 15:28:36 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hdDcj1QKRz6rGhw for ; Sun, 06 Sep 2026 15:28:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hdDcj0tNmz45hw for ; Sun, 06 Sep 2026 15:28:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788708517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4seTx5z6RejiIaMqfRFvJYFvmZg2uldEmdGy0IkKJmY=; b=FxAEwAeP5O3hDk075hYbJmWyx1ExBjCI7IfeYnRzgVAhpd0RovjtX61K+ng/TQrUlkXh0R APjy1VDsnMhjMuA0cAToMJsUFanmF/ElC9MIRnv4Rjwprbl3I/H7nh2VBSOIXyy69vB5Yp el0x4jTcWnKIwvUG1W21kjD0Vyo2NDV8GRkIsuliD5Me1YW8DUE9gIp4Te+6iMMUmZqyGT KtRmHdErt6O+c6ZGX9pspcXcWQd/rxmFmi1JkP9xV2nXeDXuX0B4jvr3BDPkz4+d8S51uZ BjG/m7AEXqhPKD/WCK6kad8vQMg5IHxCQIWR585FY2HzrHvmldm9ThSDYZSngA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788708517; a=rsa-sha256; cv=none; b=ASLsN4gcTqKqwCJpTjb8a8FueEqsj4Ugl1vXsls7IMfPs55hE8faQwbl5C+7mSlmoX0vBt nM0HSFqbewb+MkSJ1B4aLxzkEyU+hvRZviy0dnReg4ZTKc1TvUvk8PtXYQKR2+dp3GaUcr HZb8aSJTYw9wx/Zf2UR7cbbPExX1hJg99bzVcKC0o+go8XUNYx6nys+R+hNtpQqqQBhtRS XdJfrJbEdSLE7YKjmanoLHGiAAQXEFc1XKo526SJotiJOCEiZohGtElaZEKcOk/NVYvKnQ oQRfB5tKTw0USS/GPT70ErXcYNsmakxMTbxDMo+X7pDiT0yA9at05znIOCaFcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788708517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4seTx5z6RejiIaMqfRFvJYFvmZg2uldEmdGy0IkKJmY=; b=qYxP1XktlZqDHKvhD0bDhBCNCa+EXYIQOfcM1lykVZwgtzklO5ZXDnWSCnmGpY19OSQ4l8 9GzAsoErh0mpSgyiL1ZowK3+fQmmbN+Iu77EellA6QJtDgmkGYVYNR3lr4/V0BdtEo7ZBl 9+Wbo9+RyuQ2WDpdmEiCYH8qrKaG0E8DxP2etr7kifyX5MrG3EuLWYv2VYttSNBoQVv99Y yFkuTMrmq5v1RCVIIYbO0ReJnNsPUWo3gEk0eWXY1xBXUeIwpBzcytXiR4pKC0TSMRqGmQ jRddMaCgB0gOhorXLRRcGGNM/em/rG9dxB4bqgcuyqJhVkkfMZVWGyUnUNS2Ag== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hdDch6LdhzdXL for ; Sun, 06 Sep 2026 15:28:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3ebe2 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 06 Sep 2026 15:28:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Fernando Apeste=?utf-8?Q?gu=C3=ADa?= Subject: git: fc002631af3e - main - whereis(1): Respect PORTSDIR variable List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc002631af3e25c65d74ca6869c13b59f1af8689 Auto-Submitted: auto-generated Date: Sun, 06 Sep 2026 15:28:36 +0000 Message-Id: <6a9d86a4.3ebe2.654627bc@gitrepo.freebsd.org> The branch main has been updated by fernape: URL: https://cgit.FreeBSD.org/src/commit/?id=fc002631af3e25c65d74ca6869c13b59f1af8689 commit fc002631af3e25c65d74ca6869c13b59f1af8689 Author: Fernando ApesteguĂ­a AuthorDate: 2026-09-04 18:27:34 +0000 Commit: Fernando ApesteguĂ­a CommitDate: 2026-09-06 15:25:59 +0000 whereis(1): Respect PORTSDIR variable 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. While here, remove and old reference to CVS. Reviewed by: delphij@, ngie@ Approved by: ngie@ Differential Revision: https://reviews.freebsd.org/D42156 --- usr.bin/whereis/whereis.1 | 4 +++- usr.bin/whereis/whereis.c | 38 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/usr.bin/whereis/whereis.1 b/usr.bin/whereis/whereis.1 index 90922ce61db5..e6e2074acc40 100644 --- a/usr.bin/whereis/whereis.1 +++ b/usr.bin/whereis/whereis.1 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 22, 2002 +.Dd September 6, 2026 .Dt WHEREIS 1 .Os .Sh NAME @@ -71,6 +71,8 @@ Program sources are located in a list of known standard places, including all the subdirectories of .Pa /usr/src and +.Ev PORTSDIR +If the environment variable is not defined it defaults to .Pa /usr/ports . .Pp The following options are available: diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c index 8de56b9cf654..987ff68de44c 100644 --- a/usr.bin/whereis/whereis.c +++ b/usr.bin/whereis/whereis.c @@ -253,6 +253,7 @@ defaults(void) { size_t s; char *b, buf[BUFSIZ], *cp; + const char *path_ports; int nele; FILE *p; DIR *dir; @@ -305,7 +306,8 @@ defaults(void) decolonify(b, &mandirs, &nele); } - /* -s defaults to precompiled list, plus subdirs of /usr/ports */ + /* -s defaults to precompiled list, plus subdirs of + * $PORTSDIR. If not set, it defaults to /usr/ports */ if (!sourcedirs) { b = strdup(sourcepath); if (b == NULL) @@ -313,32 +315,34 @@ defaults(void) nele = 0; decolonify(b, &sourcedirs, &nele); - if (stat(PATH_PORTS, &sb) == -1) { + path_ports = getenv("PORTSDIR"); + if (!path_ports) + path_ports = PATH_PORTS; + + if (stat(path_ports, &sb) == -1) { if (errno == ENOENT) - /* no /usr/ports, we are done */ + /* no ports directory, we are done */ return; - err(EX_OSERR, "stat(" PATH_PORTS ")"); + err(EX_OSERR, "stat(%s)", path_ports); } if ((sb.st_mode & S_IFMT) != S_IFDIR) - /* /usr/ports is not a directory, ignore */ + /* path_ports is not a directory, ignore */ return; - if (access(PATH_PORTS, R_OK | X_OK) != 0) + if (access(path_ports, R_OK | X_OK) != 0) return; - if ((dir = opendir(PATH_PORTS)) == NULL) - err(EX_OSERR, "opendir" PATH_PORTS ")"); + if ((dir = opendir(path_ports)) == NULL) + err(EX_OSERR, "opendir(%s)", path_ports); while ((dirp = readdir(dir)) != NULL) { /* - * Not everything below PATH_PORTS is of + * Not everything below path_ports is of * interest. First, all dot files and * directories (e. g. .snap) can be ignored. * Also, all subdirectories starting with a - * capital letter are not going to be + * capital letter are not going to * examined, as they are used for internal - * purposes (Mk, Tools, ...). This also - * matches a possible CVS subdirectory. - * Finally, the distfiles subdirectory is also - * special, and should not be considered to - * avoid false matches. + * purposes (Mk, Tools, ...). Finally, the distfiles + * subdirectory is also special, and should not be + * considered to avoid false matches. */ if (dirp->d_name[0] == '.' || /* @@ -350,10 +354,10 @@ defaults(void) (dirp->d_name[0] >= 'A' && dirp->d_name[0] <= 'Z') || strcmp(dirp->d_name, "distfiles") == 0) continue; - if ((b = malloc(sizeof PATH_PORTS + 1 + dirp->d_namlen)) + if ((b = malloc(strlen(path_ports) + 1 + dirp->d_namlen + 1)) == NULL) abort(); - strcpy(b, PATH_PORTS); + strcpy(b, path_ports); strcat(b, "/"); strcat(b, dirp->d_name); if (stat(b, &sb) == -1 ||