After the most recent simplification of portgen's port finding code, I think we can stop using sqlports and instead look to see if any $PORTSDIR/*/$PKGSTEM exist without a significant loss of functionality. We currently look for any FullPkgPath that matches the PKGSTEM in sqlports. I'm not aware of any module ports where that stem isn't the same as the directory name, and if there are, is that worth needing to install sqlports and p5-DBD-SQLite?
Comments, OK?
Index: infrastructure/lib/OpenBSD/PortGen/Utils.pm =================================================================== RCS file: /cvs/ports/infrastructure/lib/OpenBSD/PortGen/Utils.pm,v retrieving revision 1.6 diff -u -p -r1.6 Utils.pm --- infrastructure/lib/OpenBSD/PortGen/Utils.pm 15 Dec 2019 00:18:04 -0000 1.6 +++ infrastructure/lib/OpenBSD/PortGen/Utils.pm 2 Feb 2020 03:02:10 -0000 @@ -48,44 +48,20 @@ sub ports_dir { $ENV{PORTSDIR} || '/usr/ sub base_dir { ports_dir() . '/mystuff' } -sub _module_sth -{ - my $dbfile = '/usr/local/share/sqlports'; - die "install databases/sqlports and databases/p5-DBD-SQLite\n" - unless -e $dbfile; - - require DBI; # do this here after we've checked for $dbfile - - my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "", { - ReadOnly => 1, - RaiseError => 1, - } ) or die "failed to connect to database: $DBI::errstr"; - - return $dbh->prepare(q{ - SELECT _Paths.FullPkgPath FROM _Paths - JOIN _Ports ON _Paths.PkgPath = _Ports.FullPkgPath - WHERE PKGSTEM = ? - AND _Paths.Id = _Paths.PkgPath - ORDER BY LENGTH(_Paths.FullPkgPath) - }); -} - sub module_in_ports { my ( $module, $prefix ) = @_; return unless $module and $prefix; - state $sth = _module_sth(); - END { undef $sth }; # Bus error if destroyed during global destruction - my @stems = ( $prefix . $module ); # We commonly convert the port to lowercase push @stems, $prefix . lc($module) if $module =~ /\p{Upper}/; + my $ports_dir = ports_dir(); foreach my $stem (@stems) { - $sth->execute($stem); - my ($path, @extra) = map {@$_} @{ $sth->fetchall_arrayref }; + my ($path, @extra) = map { s{^\Q$ports_dir/}{}r } + glob("$ports_dir/*/$stem"); warn "Found paths other than $path: @extra\n" if @extra; return $path if $path;