The last change was flawed; for deleted ports it was writing out the
origin, but it should be writing out the appropriate ports cache
database directory.
The redundant-opt-file scripts assumes that if options are cached,
then the port that it was created by still exists. This, of course, is
a terrible assumption.
If the cached options refer to a port that has since been deleted or
otherwise no longer exists, just print the origin and continue. The
normal use case is that the origin will be piped to xargs rm -rf which
will purge the obsolete directory as desired.
I got a request to make Synth identify "redundant" cached option files,
where "redundant" means the saved port options are identical to the
default options. For Synth (and portmaster?) which use the port's
cache options, these redundant files are somewhat of a liability. At
best they do nothing (Synth assumes default options) and at worst they
will cause a future build to stop if the maintainer changes the port
options later.
This situation is avoidable. Rather than build detection into Synth,
I decided to write a generic shell script for ports. When run, it
will display the full path to the port's options directory if the
cached options are the same as the defaults. This output is suitable
to pipe to "xargs rm -rf" to remove all the redundant options in a
single command.