[Bug 278898] /usr/ports/Tools/scripts/redundant-opt-files.sh lists things that don't correspond to ports

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 10 May 2024 17:54:15 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278898

            Bug ID: 278898
           Summary: /usr/ports/Tools/scripts/redundant-opt-files.sh lists
                    things that don't correspond to ports
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: bob@vesterman.com

First, I'm sorry that this has the "Component" "Individual Port(s)", but that's
the only option that the required Component field is giving me (even if I get
here by clicking the link "File a new bug in the "Ports Framework" component of
the "Ports & Packages" product", with "Ports Framework" seemingly being the
appropriate component for this. With that said:

The script /usr/ports/Tools/scripts/redundant-opt-files.sh is described (in its
source) as follows:

"This script checks every option file against the default options of its port. 
If they are identical, it writes the full path of the ports option directory
(typically in /var/db/ports) to stdout."

Unfortunately, it seems to assume that every directory in /var/db/ports
corresponds to some port, even if it doesn't, even if it has a name that isn't
in the pkg_port format, even if it's a dotfile, and even if it doesn't even
contain an options file.

So, for example, right now I have two options directories in /var/db/ports:
games_xcowsay/options and ports-mgmt_synth/options. The former has all default
options, while the latter has custom options. Given that, I would expect this
script to output:

/var/db/ports/games_xcowsay

But instead, it outputs:

/var/db/ports/.svn
/var/db/ports/games_xcowsay
/var/db/ports/stowfiles

This is because I store my custom configuration using Subversion (hence .svn)
and Stow (hence stowfiles):

$ ls /var/db/ports
.svn/             games_xcowsay/    ports-mgmt_synth@ stowfiles/

I assume that this sort of thing also happens when various other tools are used
on that directory (e.g. git).

Obviously this is not the most pressing issue in the world, but given that the
typical suggestions on the internet for using this script involve piping its
output to "rm -rf", perhaps it should be changed to not print out anything that
doesn't correspond to an actual port, with the pkg_port naming convention
corresponding to something that really exists at /usr/ports/pkg/port.

This is on 14.0-RELEASE-p6, by the way (I don't mean to imply not elsewhere too
- just that I only know for sure it happens on that one).

-- 
You are receiving this mail because:
You are the assignee for the bug.