Daniel Jakots writes:

> On Wed, 30 Jun 2021 14:24:24 -0600, Aaron Bieber <aa...@bolddaemon.com>
> wrote:
>
> Thanks for working on it! I see a few possible improvements:
>
>> -# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES
>> +# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES for
>> +# the latest version of a given MODGO_MODNAME if MODGO_VERSION is set to
>> +# "current". Otherwise it will fetch the MODULES/MODFILES for the presently
>> +# set MODGO_VERSION.
>
> Can we use "latest" instead of current? That's the terminology upstream
> uses:
> "The string latest, which selects the highest available release
> version."
>
> https://golang.org/ref/mod#version-queries
>
>>  modgo-gen-modules:
>>  .if empty(MODGO_MODNAME)
>>      @${ECHO_MSG} "No MODGO_MODNAME set"
>>      @exit 1
>>  .else
>> +.if ${MODGO_VERSION} == "current"
>>      @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
>> +.else
>> +    @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
>> ${MODGO_VERSION} .endif
>> +.endif
>
> We're nesting ifs here. We can put the new one outside easily, but if
> you don't want to do that, the second one should be indented like the
> one L152.
>
> My main disagreement is that if you don't have any MODGO_VERSION set,
> it fails with 
> $ make modgo-gen-modules 
> *** Parse error in /usr/ports/security/age: Malformed conditional 
> (${MODGO_VERSION} == "current") (/usr/ports/lang/go/go.port.mk:189)
> *** Parse error: Need an operator in '"current"' 
> (/usr/ports/lang/go/go.port.mk:189)
>
> I tried setting something like
> MODGO_VERSION ?= "current" but make(1) didn't like it.
>
> Here's an updated diff for the two first points. It doesn't improve the
> empty MODGO_VERSION tho :(
>
> BTW, go-module(5) will need an update.
>
> Index: go.port.mk
> ===================================================================
> RCS file: /cvs/ports/lang/go/go.port.mk,v
> retrieving revision 1.42
> diff -u -p -r1.42 go.port.mk
> --- go.port.mk        23 Mar 2021 13:19:08 -0000      1.42
> +++ go.port.mk        30 Jun 2021 21:23:38 -0000
> @@ -71,7 +71,7 @@ DISTNAME_ESC =              ${DISTNAME${_s}}
>  EXTRACT_SUFX ?=              .zip
>  PKGNAME ?=           ${DISTNAME:S/-v/-/}
>  ALL_TARGET ?=                ${MODGO_MODNAME}
> -MODGO_FLAGS +=               -modcacherw
> +MODGO_FLAGS +=               -modcacherw -trimpath
>  DISTFILES +=         
> ${DISTNAME_ESC}${EXTRACT_SUFX}{${MODGO_VERSION}${EXTRACT_SUFX}}
>  EXTRACT_ONLY =               ${DISTNAME_ESC}${EXTRACT_SUFX}
>  MASTER_SITES ?=              ${MASTER_SITE_ATHENS}${MODGO_MODNAME_ESC}/@v/
> @@ -177,11 +177,17 @@ do-test:
>  .  endif
>  .endif
>  
> -# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES
> +# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES for
> +# the latest version of a given MODGO_MODNAME if MODGO_VERSION is set to
> +# "latest". Otherwise it will fetch the MODULES/MODFILES for the presently
> +# set MODGO_VERSION.
>  modgo-gen-modules:
>  .if empty(MODGO_MODNAME)
>       @${ECHO_MSG} "No MODGO_MODNAME set"
>       @exit 1
> -.else
> +.endif
> +.if ${MODGO_VERSION} == "latest"
>       @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
> +.else
> +     @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME} 
> ${MODGO_VERSION}
>  .endif

K, here is an update that works with the empty MODGO_VERSION.

diff 6f40cd6bc7cac1369cff9b00b9162c62b1d82490 /usr/ports
blob - 60b84fb0ae310786ee5c71a2e4e4e741f0904da9
file + infrastructure/bin/modgo-gen-modules-helper
--- infrastructure/bin/modgo-gen-modules-helper
+++ infrastructure/bin/modgo-gen-modules-helper
@@ -17,6 +17,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 use 5.012;
+use strict;
 use warnings;
 
 my ($portdir);
@@ -31,7 +32,11 @@ use lib ( "$portdir/infrastructure/lib", "$FindBin::Bi
 
 use OpenBSD::PortGen::Port::Go;
 
-my ( $module ) = @ARGV;
+die if @ARGV < 1;
+my $module = shift;
+if (@ARGV == 1) {
+	$module .= '@'. shift;
+}
 
 my $port = OpenBSD::PortGen::Port::Go->new;
 my $portinfo = $port->get_dist_info($module);
blob - 924c64a51696a59fd6dc5456b1f3f7abda7e38d6
file + lang/go/go.port.mk
--- lang/go/go.port.mk
+++ lang/go/go.port.mk
@@ -71,7 +71,7 @@ DISTNAME_ESC =		${DISTNAME${_s}}
 EXTRACT_SUFX ?=		.zip
 PKGNAME ?=		${DISTNAME:S/-v/-/}
 ALL_TARGET ?=		${MODGO_MODNAME}
-MODGO_FLAGS +=		-modcacherw
+MODGO_FLAGS +=		-modcacherw -trimpath
 DISTFILES +=		${DISTNAME_ESC}${EXTRACT_SUFX}{${MODGO_VERSION}${EXTRACT_SUFX}}
 EXTRACT_ONLY =		${DISTNAME_ESC}${EXTRACT_SUFX}
 MASTER_SITES ?=		${MASTER_SITE_ATHENS}${MODGO_MODNAME_ESC}/@v/
@@ -177,11 +177,18 @@ do-test:
 .  endif
 .endif
 
-# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES
+# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES for
+# the latest version of a given MODGO_MODNAME if MODGO_VERSION is set to
+# "latest". Otherwise it will fetch the MODULES/MODFILES for the presently
+# set MODGO_VERSION.
 modgo-gen-modules:
 .if empty(MODGO_MODNAME)
 	@${ECHO_MSG} "No MODGO_MODNAME set"
 	@exit 1
-.else
+.endif
+
+.if empty(MODGO_VERSION) || ${MODGO_VERSION} == "latest"
 	@${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
+.else
+	@${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME} ${MODGO_VERSION}
 .endif

Reply via email to