Paco Esteban writes: > Hi ports@, > > I had the idea of having a make target to help with MODGO_MODULES and > MODGO_MODFILES generation just like devel/cargo does with its > modcargo-gen-crates. > > It may be a bit crude but it works and it could be quite useful when > updating ports that use this. > > I discussed it a bit with abieber@ (as it's based on his portgen go work). > He liked the general idea, and we agreed to continue on the list.
IMO this will be a nice addition. I am not sure if adding it to infrastructure/bin is correct, but it seems logical to me! > > Not sure if I should use ${REPORT_PROBLEM} instead of that `exit 1`. > Of course this should be > > Comments appreciated. > > Attached 2 diffs, one against ports for the helper and make target and > one against src for the man page changes. Assuming the bin location is appropriate, OK abieber@! > > Cheers, Expanding on this a bit, here is a diff to Go.pm that allows one to specify the version (non-versioned will grab what ever the latest is still): portgen go suah.dev/ogvt@v1.0.2 - or - portgen go suah.dev/ogvt@v1.0.3 This will let existing ports spit out the proper MOGGO_MOD* values. Without this the portgen logic will assume you want the latest version of whatever app you are using which might not align with the current version of a given port. Alternatively we could output MODGO_VERSION var alongside the MODGO_MOD* stuff.
diff --git a/infrastructure/lib/OpenBSD/PortGen/Port/Go.pm b/infrastructure/lib/OpenBSD/PortGen/Port/Go.pm index ffee13013e7..27e84cb1263 100644 --- a/infrastructure/lib/OpenBSD/PortGen/Port/Go.pm +++ b/infrastructure/lib/OpenBSD/PortGen/Port/Go.pm @@ -65,16 +65,31 @@ sub _go_lic_info sub _go_determine_name { - # Some modules end in "v1" or "v2", if we find one of these, we need - # to set PKGNAME to something up a level my ( $self, $module ) = @_; - my $json = $self->get_json( $module . '/@latest' ); + my $json = {}; + + # Versions can be specified on the command line: + if ($module =~ m/\@v/) { + my @parts = split("@", $module); + $module = $parts[0]; + $json->{Module} = $parts[0]; + $json->{Version} = $parts[1]; + + # This is used in get_ver_info when we have already determined + # the version to use. + $self->{ModName} = $parts[0]; + $self->{ModVersion} = $parts[1]; + } else { + $json = $self->get_json( $module . '/@latest' ); + } if ($json->{Version} =~ m/incompatible/) { my $msg = "${module} $json->{Version} is incompatible with Go modules."; croak $msg; } + # Some modules end in "v1" or "v2", if we find one of these, we need + # to set PKGNAME to something up a level if ($module =~ m/v\d$/) { $json->{Name} = ( split '/', $module )[-2]; } else { @@ -166,7 +181,6 @@ sub _go_mod_info my @mods; foreach my $mod (@raw_mods) { - carp Dumper $mod if ($mod =~ m/markbates/); foreach my $m (split(/ /, $mod)) { $m =~ s/@/ /; $m = $self->_go_mod_normalize($m); @@ -212,6 +226,11 @@ sub _go_mod_normalize sub get_ver_info { my ( $self, $module ) = @_; + + if (defined $self->{ModVersion} && defined $self->{ModName}) { + return { Module => $self->{ModName}, Version => $self->{ModVersion} }; + } + my $version_list = $self->get( $module . '/@v/list' ); my $version = "v0.0.0"; my $ret;
-- PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A 4AF0 1F81 112D 62A9 ADCE