On Wed, Mar 17, 2021 at 07:44:52PM +0000, Stuart Henderson wrote:
> On 2021/03/17 12:53, Josh Rickmar wrote:
> > This portgen(1) patch allows for an optional @version suffix to a
> > ported Go module to specify a tag or branch to port.  The implied
> > default is @latest, which is the latest semver tag known by the proxy
> > server.  This is the same syntax used to refer to module versions in
> > Go's own tooling.
> > 
> > I've inlined two patches here for both the src and ports trees since
> > the portgen manpage is in src.
> 
> Works for me, I've wanted to do this a few times before and know that
> others have too so definitely useful.
> 
> > +     elsif ($at_version =~ /^v\d+\.\d+\.\d+/) {
> 
> Is this vx.y.z format fixed with go, or just a convention?

Released versions of Go modules do need to follow semver exactly,
although I suppose the match should actually be:

/^v\d+\.\d+\.\d+(-[^\+])?/

since while prerelease info is valid, build metadata is not.

Anything not matching this must be looked up through the other proxy
endpoint (ending in .info).

> 
> 
> > diff 5dfe4c7116fefdfa88d0ee0df89758e96e280278 /usr/src
> > blob - 22ccaf2e01cffbb10cf1fb4b7fc0ade89fa16b48
> > file + share/man/man1/portgen.1
> > --- share/man/man1/portgen.1
> > +++ share/man/man1/portgen.1
> > @@ -58,6 +58,15 @@ for Ruby gems.
> >  for Go modules.
> >  .El
> >  .Pp
> > +A
> > +.Cm go
> > +module may be used with an
> > +.Ar @version
> > +suffix to specify a tag or branch to port.
> > +The default suffix is
> > +.Ar @latest ,
> > +which is interpreted as the latest stable release.
> > +.Pp
> >  The following packages must be installed prior to the invocation of
> >  .Nm :
> >  .Pp
> > 
> > diff 6eaf30816f4def2f40cb2b765a3aa33ae11ae4a8 /usr/ports
> > blob - 40be89f09438e34ea14cb0d116e20663a949ea4b
> > file + infrastructure/lib/OpenBSD/PortGen/Port/Go.pm
> > --- infrastructure/lib/OpenBSD/PortGen/Port/Go.pm
> > +++ infrastructure/lib/OpenBSD/PortGen/Port/Go.pm
> > @@ -69,14 +69,13 @@ sub _go_determine_name
> >     my ( $self, $module ) = @_;
> >  
> >     my $json = $self->get_ver_info($module);
> > +   $module = $json->{Module};
> >     if ($module =~ m/v\d$/) {
> >             $json->{Name}   = ( split '/', $module )[-2];
> >     } else {
> >             $json->{Name}   = ( split '/', $module )[-1];
> >     }
> >  
> > -   $json->{Module} = $module;
> > -
> >     return $json;
> >  }
> >  
> > @@ -87,7 +86,7 @@ sub get_dist_info
> >     my $json = $self->_go_determine_name($module);
> >  
> >     my ($dist, $mods) = $self->_go_mod_info($json);
> > -   $json->{License} = $self->_go_lic_info($module);
> > +   $json->{License} = $self->_go_lic_info($json->{Module});
> >  
> >     $json->{Dist} = $dist if @$dist > 0;
> >     $json->{Mods} = $mods if @$mods > 0;
> > @@ -218,6 +217,13 @@ sub get_ver_info
> >     my $version_list = do { local $@; eval { local $SIG{__DIE__};
> >         $self->get( $module . '/@v/list' ) } };
> >  
> > +   # Versions can be specified on the command line with a
> > +   # '@<version>' suffix, which defaults to '@latest':
> > +   my $at_version = 'latest';
> > +   if ($module =~ /@/) {
> > +           ($module, $at_version) = split(/@/, $module);
> > +   }
> > +
> >     my $version_info;
> >     if ($version_list) {
> >             my %v = ( o => 
> > OpenBSD::PackageName::version->from_string("v0.0.0") );
> > @@ -234,8 +240,17 @@ sub get_ver_info
> >                     croak "Unable to determine version for $module!";
> >             }
> >     }
> > +   elsif ($at_version =~ /^v\d+\.\d+\.\d+/) {
> > +           $version_info->{Module} = $module;
> > +           $version_info->{Version} = $at_version;
> > +   }
> >     else {
> > -           $version_info = $self->get_json( 
> > $self->_go_mod_normalize($module) . '/@latest' );
> > +           my $endpoint = '/@latest';
> > +           if ($at_version ne 'latest') {
> > +                   $endpoint = '/@v/' . "${at_version}.info";
> > +           }
> > +           $version_info = $self->get_json( 
> > $self->_go_mod_normalize($module) . $endpoint );
> > +           $version_info->{Module} = $module;
> >     }
> >  
> >     return $self->{version_info} = $version_info;
> > 

Reply via email to