The following very simple code shows that it's possible to figure out
most of the branches  (new % format) automatically based on comparison
between fullpkgname and fullpkgpath.

There are a few "false positive" (innocuous). I'm going to check soon that
I have them all.

This ought to yield a "better" way to achieve pkg_add -z, assuming I get
some kind of nicer pkg_info output (just the stem/flavor + possible branch).

Of course, this relies on pkgpath and pkgnames basically matching in every
case that actually matters...

#! /usr/bin/perl
use OpenBSD::PackageName;

open my $fh, "cd /usr/ports && make dump-vars |";
while (<$fh>) {
        next unless m/(.*)\.FULLPKGNAME=(.*)/;
        $fullpkgpath = $1;
        $fullpkgname = OpenBSD::PackageName->new_from_string($2);
        $stem = $fullpkgname->{stem};
        if ($fullpkgpath =~ m/\b\Q$stem\E\/(.*?)([,\/].*)?$/) {
                $branch = $1;
                print "$fullpkgname->{stem}%$branch\n";
        }
}

Reply via email to