Re: bsd.port.mk: provide GH_DISTFILE

2021-11-14 Thread Greg Steuck
Stuart Henderson  writes:

> We have a few ports that use GH_* and have a second distfile, so have to
> build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> but the ones with GH_COMMIT are a bit horrible:
>
> $ ag -G Makef ^DISTF.*GH_COMMIT
> devel/cabal-bundler/Makefile
> 13:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
>
> devel/msbuild/Makefile
> 29:DISTFILES =${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
>
> net/arp-scan/Makefile
> 22:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
>
> net/ntopng/Makefile
> 19:DISTFILES= ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
>
> x11/gnome/gdm/Makefile
> 15:DISTFILES= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
>
> x11/mruby-zest/Makefile
> 45:DISTFILES= zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
>
> Seems like it might be useful to provide the generated distfile name
> in a variable that can be reused here. I set it for ports using either
> GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> need to update something to an untagged checkout.

I like this patch. I tested the change with the update to cabal-bundler
(anybody feel like OK'ing?):

--- a/devel/cabal-bundler/Makefile
+++ b/devel/cabal-bundler/Makefile
@@ -10,7 +10,7 @@ GH_PROJECT =  cabal-extras
 
 # Overrides cabal.port.mk which would otherwise preempt bsd.port.mk
 DISTNAME = ${GH_PROJECT}-${V}
-DISTFILES =
${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
 \
+DISTFILES =${GH_DISTFILE} \
gentle-introduction-2021.2.tar.gz:1
 PKGNAME =  ${MODCABAL_EXECUTABLES}-${V}
 MASTER_SITES = ${MASTER_SITES_GITHUB}

>
> Any comments? OK?

OK gnezdo@

>
> Index: src/share/man/man5/bsd.port.mk.5
> ===
> RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> retrieving revision 1.546
> diff -u -p -r1.546 bsd.port.mk.5
> --- src/share/man/man5/bsd.port.mk.5  8 Oct 2021 13:52:28 -   1.546
> +++ src/share/man/man5/bsd.port.mk.5  13 Nov 2021 11:27:24 -
> @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
>  .It Ev GH_COMMIT
>  SHA1 commit id to fetch.
>  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> +.It Ev GH_DISTFILE
> +Set by
> +.Nm
> +to the generated name of the distribution file.
> +This can be useful for ports listing multiple
> +.Ev DISTFILES .
>  .It Ev GH_PROJECT
>  Name of the project on GitHub.
>  .It Ev GH_TAGNAME
> Index: ports/infrastructure/mk/bsd.port.mk
> ===
> RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> retrieving revision 1.1558
> diff -u -p -r1.1558 bsd.port.mk
> --- ports/infrastructure/mk/bsd.port.mk   8 Nov 2021 13:36:25 -   
> 1.1558
> +++ ports/infrastructure/mk/bsd.port.mk   13 Nov 2021 11:27:24 -
> @@ -612,6 +612,7 @@ GH_PROJECT ?=
>  
>  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
>  DISTNAME ?=  
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> +GH_DISTFILE = 
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
>  .endif
>  
>  PKGNAME ?= ${DISTNAME}
> @@ -1289,7 +1290,8 @@ _warn_checksum += ;echo ">>> MASTER_SITE
>  EXTRACT_SUFX ?= .tar.gz
>  
>  .if !empty(GH_COMMIT)
> -DISTFILES ?= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +GH_DISTFILE = 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +DISTFILES ?= ${GH_DISTFILE}
>  .else
>  .  if defined(DISTNAME)
>  DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX}



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-14 Thread Marc Espie
On Sun, Nov 14, 2021 at 02:37:34PM +, Stuart Henderson wrote:
> On 2021/11/14 13:56, Marc Espie wrote:
> > On Sat, Nov 13, 2021 at 11:31:57AM +, Stuart Henderson wrote:
> > > We have a few ports that use GH_* and have a second distfile, so have to
> > > build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> > > but the ones with GH_COMMIT are a bit horrible:
> > > 
> > > $ ag -G Makef ^DISTF.*GH_COMMIT
> > > devel/cabal-bundler/Makefile
> > > 13:DISTFILES =
> > > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > >  \
> > > 
> > > devel/msbuild/Makefile
> > > 29:DISTFILES =${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
> > > 
> > > net/arp-scan/Makefile
> > > 22:DISTFILES =
> > > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > >  \
> > > 
> > > net/ntopng/Makefile
> > > 19:DISTFILES= ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> > > ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
> > > 
> > > x11/gnome/gdm/Makefile
> > > 15:DISTFILES= 
> > > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > >  \
> > > 
> > > x11/mruby-zest/Makefile
> > > 45:DISTFILES= zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
> > > 
> > > Seems like it might be useful to provide the generated distfile name
> > > in a variable that can be reused here. I set it for ports using either
> > > GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> > > need to update something to an untagged checkout.
> > > 
> > > Any comments? OK?
> > > 
> > > 
> > > Index: src/share/man/man5/bsd.port.mk.5
> > > ===
> > > RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> > > retrieving revision 1.546
> > > diff -u -p -r1.546 bsd.port.mk.5
> > > --- src/share/man/man5/bsd.port.mk.5  8 Oct 2021 13:52:28 -   
> > > 1.546
> > > +++ src/share/man/man5/bsd.port.mk.5  13 Nov 2021 11:27:24 -
> > > @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
> > >  .It Ev GH_COMMIT
> > >  SHA1 commit id to fetch.
> > >  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> > > +.It Ev GH_DISTFILE
> > > +Set by
> > > +.Nm
> > > +to the generated name of the distribution file.
> > > +This can be useful for ports listing multiple
> > > +.Ev DISTFILES .
> > >  .It Ev GH_PROJECT
> > >  Name of the project on GitHub.
> > >  .It Ev GH_TAGNAME
> > > Index: ports/infrastructure/mk/bsd.port.mk
> > > ===
> > > RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> > > retrieving revision 1.1558
> > > diff -u -p -r1.1558 bsd.port.mk
> > > --- ports/infrastructure/mk/bsd.port.mk   8 Nov 2021 13:36:25 -   
> > > 1.1558
> > > +++ ports/infrastructure/mk/bsd.port.mk   13 Nov 2021 11:27:24 -
> > > @@ -612,6 +612,7 @@ GH_PROJECT ?=
> > >  
> > >  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
> > >  DISTNAME ?=  
> > > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> > > +GH_DISTFILE = 
> > > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
> > >  .endif
> > >  
> > >  PKGNAME ?= ${DISTNAME}
> > > @@ -1289,7 +1290,8 @@ _warn_checksum += ;echo ">>> MASTER_SITE
> > >  EXTRACT_SUFX ?= .tar.gz
> > >  
> > >  .if !empty(GH_COMMIT)
> > > -DISTFILES ?= 
> > > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > > +GH_DISTFILE = 
> > > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > > +DISTFILES ?= ${GH_DISTFILE}
> > >  .else
> > >  .  if defined(DISTNAME)
> > >  DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX}
> > > 
> > > 
> > You didn't mention whether you left it intentionally out of
> > dump-vars and sqlports or not.
> 
> I forgot about those; it doesn't seem to me that it's useful to add to
> sqlports but maybe is for dump-vars. What do you think?
> 
> 
Well, if it's not useful for sqlports, it doesn't belong in dump-vars
most probably. You can always make show=GH_DISTFILE
if you want to see the value.



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-14 Thread Stuart Henderson
On 2021/11/14 13:56, Marc Espie wrote:
> On Sat, Nov 13, 2021 at 11:31:57AM +, Stuart Henderson wrote:
> > We have a few ports that use GH_* and have a second distfile, so have to
> > build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> > but the ones with GH_COMMIT are a bit horrible:
> > 
> > $ ag -G Makef ^DISTF.*GH_COMMIT
> > devel/cabal-bundler/Makefile
> > 13:DISTFILES =  
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > devel/msbuild/Makefile
> > 29:DISTFILES =  ${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
> > 
> > net/arp-scan/Makefile
> > 22:DISTFILES =  
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > net/ntopng/Makefile
> > 19:DISTFILES=   ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> > ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
> > 
> > x11/gnome/gdm/Makefile
> > 15:DISTFILES=   
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > x11/mruby-zest/Makefile
> > 45:DISTFILES=   zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
> > 
> > Seems like it might be useful to provide the generated distfile name
> > in a variable that can be reused here. I set it for ports using either
> > GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> > need to update something to an untagged checkout.
> > 
> > Any comments? OK?
> > 
> > 
> > Index: src/share/man/man5/bsd.port.mk.5
> > ===
> > RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> > retrieving revision 1.546
> > diff -u -p -r1.546 bsd.port.mk.5
> > --- src/share/man/man5/bsd.port.mk.58 Oct 2021 13:52:28 -   
> > 1.546
> > +++ src/share/man/man5/bsd.port.mk.513 Nov 2021 11:27:24 -
> > @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
> >  .It Ev GH_COMMIT
> >  SHA1 commit id to fetch.
> >  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> > +.It Ev GH_DISTFILE
> > +Set by
> > +.Nm
> > +to the generated name of the distribution file.
> > +This can be useful for ports listing multiple
> > +.Ev DISTFILES .
> >  .It Ev GH_PROJECT
> >  Name of the project on GitHub.
> >  .It Ev GH_TAGNAME
> > Index: ports/infrastructure/mk/bsd.port.mk
> > ===
> > RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> > retrieving revision 1.1558
> > diff -u -p -r1.1558 bsd.port.mk
> > --- ports/infrastructure/mk/bsd.port.mk 8 Nov 2021 13:36:25 -   
> > 1.1558
> > +++ ports/infrastructure/mk/bsd.port.mk 13 Nov 2021 11:27:24 -
> > @@ -612,6 +612,7 @@ GH_PROJECT ?=
> >  
> >  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
> >  DISTNAME ?=
> > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> > +GH_DISTFILE = 
> > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
> >  .endif
> >  
> >  PKGNAME ?= ${DISTNAME}
> > @@ -1289,7 +1290,8 @@ _warn_checksum += ;echo ">>> MASTER_SITE
> >  EXTRACT_SUFX ?= .tar.gz
> >  
> >  .if !empty(GH_COMMIT)
> > -DISTFILES ?= 
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > +GH_DISTFILE = 
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> > +DISTFILES ?= ${GH_DISTFILE}
> >  .else
> >  .  if defined(DISTNAME)
> >  DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX}
> > 
> > 
> You didn't mention whether you left it intentionally out of
> dump-vars and sqlports or not.

I forgot about those; it doesn't seem to me that it's useful to add to
sqlports but maybe is for dump-vars. What do you think?



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-14 Thread Marc Espie
On Sat, Nov 13, 2021 at 11:31:57AM +, Stuart Henderson wrote:
> We have a few ports that use GH_* and have a second distfile, so have to
> build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> but the ones with GH_COMMIT are a bit horrible:
> 
> $ ag -G Makef ^DISTF.*GH_COMMIT
> devel/cabal-bundler/Makefile
> 13:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> devel/msbuild/Makefile
> 29:DISTFILES =${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
> 
> net/arp-scan/Makefile
> 22:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> net/ntopng/Makefile
> 19:DISTFILES= ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
> 
> x11/gnome/gdm/Makefile
> 15:DISTFILES= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> x11/mruby-zest/Makefile
> 45:DISTFILES= zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
> 
> Seems like it might be useful to provide the generated distfile name
> in a variable that can be reused here. I set it for ports using either
> GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> need to update something to an untagged checkout.
> 
> Any comments? OK?
> 
> 
> Index: src/share/man/man5/bsd.port.mk.5
> ===
> RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> retrieving revision 1.546
> diff -u -p -r1.546 bsd.port.mk.5
> --- src/share/man/man5/bsd.port.mk.5  8 Oct 2021 13:52:28 -   1.546
> +++ src/share/man/man5/bsd.port.mk.5  13 Nov 2021 11:27:24 -
> @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
>  .It Ev GH_COMMIT
>  SHA1 commit id to fetch.
>  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> +.It Ev GH_DISTFILE
> +Set by
> +.Nm
> +to the generated name of the distribution file.
> +This can be useful for ports listing multiple
> +.Ev DISTFILES .
>  .It Ev GH_PROJECT
>  Name of the project on GitHub.
>  .It Ev GH_TAGNAME
> Index: ports/infrastructure/mk/bsd.port.mk
> ===
> RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> retrieving revision 1.1558
> diff -u -p -r1.1558 bsd.port.mk
> --- ports/infrastructure/mk/bsd.port.mk   8 Nov 2021 13:36:25 -   
> 1.1558
> +++ ports/infrastructure/mk/bsd.port.mk   13 Nov 2021 11:27:24 -
> @@ -612,6 +612,7 @@ GH_PROJECT ?=
>  
>  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
>  DISTNAME ?=  
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> +GH_DISTFILE = 
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
>  .endif
>  
>  PKGNAME ?= ${DISTNAME}
> @@ -1289,7 +1290,8 @@ _warn_checksum += ;echo ">>> MASTER_SITE
>  EXTRACT_SUFX ?= .tar.gz
>  
>  .if !empty(GH_COMMIT)
> -DISTFILES ?= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +GH_DISTFILE = 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +DISTFILES ?= ${GH_DISTFILE}
>  .else
>  .  if defined(DISTNAME)
>  DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX}
> 
> 
You didn't mention whether you left it intentionally out of
dump-vars and sqlports or not.



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-13 Thread Klemens Nanni
On Sat, Nov 13, 2021 at 12:03:55PM +, Stuart Henderson wrote:
> I think I see what you mean. GH_TAGNAME doesn't normally set DISTFILES
> directly, only DISTNAME (which normal ports infrastructure turns into
> DISTFILES by adding EXTRACT_SUFX). So using GH_DISTFILE to build up
> that name doesn't work (unless we strip off EXTRACT_SUFX but that
> doesn't make sense to me).
> 
> Whereas with GH_COMMIT, DISTNAME isn't automatically set at all, it
> is up to the port to do so.
> 
> Originally I only had this set when you use GH_COMMIT not GH_TAGNAME,
> on the basis that it's easy to get the distfile name for a GH_TAGNAME
> port anyway. But then I wanted to test an update of librenms from a
> commit hash rather than the usual tag, and realised it would reduce
> churn in a port Makefile if it could cope with changing between the
> two.
> 
> So in a nutshell (assuming I understand the question correctly):
> yes it's intended.

Thanks, that makes more sense.
OK kn



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-13 Thread Stuart Henderson
On 2021/11/13 11:48, Klemens Nanni wrote:
> On Sat, Nov 13, 2021 at 11:31:57AM +, Stuart Henderson wrote:
> > We have a few ports that use GH_* and have a second distfile, so have to
> > build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> > but the ones with GH_COMMIT are a bit horrible:
> > 
> > $ ag -G Makef ^DISTF.*GH_COMMIT
> > devel/cabal-bundler/Makefile
> > 13:DISTFILES =  
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > devel/msbuild/Makefile
> > 29:DISTFILES =  ${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
> > 
> > net/arp-scan/Makefile
> > 22:DISTFILES =  
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > net/ntopng/Makefile
> > 19:DISTFILES=   ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> > ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
> > 
> > x11/gnome/gdm/Makefile
> > 15:DISTFILES=   
> > ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> >  \
> > 
> > x11/mruby-zest/Makefile
> > 45:DISTFILES=   zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
> > 
> > Seems like it might be useful to provide the generated distfile name
> > in a variable that can be reused here. I set it for ports using either
> > GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> > need to update something to an untagged checkout.
> 
> I like the idea!
> 
> > Any comments? OK?
> > 
> > 
> > Index: src/share/man/man5/bsd.port.mk.5
> > ===
> > RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> > retrieving revision 1.546
> > diff -u -p -r1.546 bsd.port.mk.5
> > --- src/share/man/man5/bsd.port.mk.58 Oct 2021 13:52:28 -   
> > 1.546
> > +++ src/share/man/man5/bsd.port.mk.513 Nov 2021 11:27:24 -
> > @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
> >  .It Ev GH_COMMIT
> >  SHA1 commit id to fetch.
> >  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> > +.It Ev GH_DISTFILE
> > +Set by
> > +.Nm
> > +to the generated name of the distribution file.
> > +This can be useful for ports listing multiple
> > +.Ev DISTFILES .
> >  .It Ev GH_PROJECT
> >  Name of the project on GitHub.
> >  .It Ev GH_TAGNAME
> 
> OK kn

Thanks.

> > Index: ports/infrastructure/mk/bsd.port.mk
> > ===
> > RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> > retrieving revision 1.1558
> > diff -u -p -r1.1558 bsd.port.mk
> > --- ports/infrastructure/mk/bsd.port.mk 8 Nov 2021 13:36:25 -   
> > 1.1558
> > +++ ports/infrastructure/mk/bsd.port.mk 13 Nov 2021 11:27:24 -
> > @@ -612,6 +612,7 @@ GH_PROJECT ?=
> >  
> >  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
> >  DISTNAME ?=
> > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> > +GH_DISTFILE = 
> > ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
> >  .endif
> >  
> >  PKGNAME ?= ${DISTNAME}
> 
> You're not using GH_DISTFILE for ports using GH_TAGNAME, is that
> intentional?
> 
> With your diff, picking a random GH_TAGNAME por:
> 
>   $ make -C /usr/ports/security/hydra -p | egrep 
> '^(DIST(FILES|NAME)|GH_DISTFILE)'
>   DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
>   DISTNAME = 
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
>   GH_DISTFILE  = 
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}

I think I see what you mean. GH_TAGNAME doesn't normally set DISTFILES
directly, only DISTNAME (which normal ports infrastructure turns into
DISTFILES by adding EXTRACT_SUFX). So using GH_DISTFILE to build up
that name doesn't work (unless we strip off EXTRACT_SUFX but that
doesn't make sense to me).

Whereas with GH_COMMIT, DISTNAME isn't automatically set at all, it
is up to the port to do so.

Originally I only had this set when you use GH_COMMIT not GH_TAGNAME,
on the basis that it's easy to get the distfile name for a GH_TAGNAME
port anyway. But then I wanted to test an update of librenms from a
commit hash rather than the usual tag, and realised it would reduce
churn in a port Makefile if it could cope with changing between the
two.

So in a nutshell (assuming I understand the question correctly):
yes it's intended.



Re: bsd.port.mk: provide GH_DISTFILE

2021-11-13 Thread Klemens Nanni
On Sat, Nov 13, 2021 at 11:31:57AM +, Stuart Henderson wrote:
> We have a few ports that use GH_* and have a second distfile, so have to
> build up their own DISTFILES. Where that uses GH_TAGNAME it's not too bad
> but the ones with GH_COMMIT are a bit horrible:
> 
> $ ag -G Makef ^DISTF.*GH_COMMIT
> devel/cabal-bundler/Makefile
> 13:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> devel/msbuild/Makefile
> 29:DISTFILES =${DISTNAME}{${GH_COMMIT}}${EXTRACT_SUFX} \
> 
> net/arp-scan/Makefile
> 22:DISTFILES =
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> net/ntopng/Makefile
> 19:DISTFILES= ntopng-${NTOPNG_V}-{}${GH_COMMIT}.tar.gz 
> ndpi-${NDPI_V}-{}${NDPI_COMMIT}.tar.gz:0
> 
> x11/gnome/gdm/Makefile
> 15:DISTFILES= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
>  \
> 
> x11/mruby-zest/Makefile
> 45:DISTFILES= zyn-fusion-{}${GH_COMMIT}${EXTRACT_SUFX} \
> 
> Seems like it might be useful to provide the generated distfile name
> in a variable that can be reused here. I set it for ports using either
> GH_TAGNAME and GH_COMMIT so that it doesn't need modifying if we
> need to update something to an untagged checkout.

I like the idea!

> Any comments? OK?
> 
> 
> Index: src/share/man/man5/bsd.port.mk.5
> ===
> RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v
> retrieving revision 1.546
> diff -u -p -r1.546 bsd.port.mk.5
> --- src/share/man/man5/bsd.port.mk.5  8 Oct 2021 13:52:28 -   1.546
> +++ src/share/man/man5/bsd.port.mk.5  13 Nov 2021 11:27:24 -
> @@ -1925,6 +1925,12 @@ Account name of the GitHub user hosting 
>  .It Ev GH_COMMIT
>  SHA1 commit id to fetch.
>  It is an error to specify ${GH_COMMIT} when ${GH_TAGNAME} is specified.
> +.It Ev GH_DISTFILE
> +Set by
> +.Nm
> +to the generated name of the distribution file.
> +This can be useful for ports listing multiple
> +.Ev DISTFILES .
>  .It Ev GH_PROJECT
>  Name of the project on GitHub.
>  .It Ev GH_TAGNAME

OK kn

> Index: ports/infrastructure/mk/bsd.port.mk
> ===
> RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> retrieving revision 1.1558
> diff -u -p -r1.1558 bsd.port.mk
> --- ports/infrastructure/mk/bsd.port.mk   8 Nov 2021 13:36:25 -   
> 1.1558
> +++ ports/infrastructure/mk/bsd.port.mk   13 Nov 2021 11:27:24 -
> @@ -612,6 +612,7 @@ GH_PROJECT ?=
>  
>  .if !empty(GH_PROJECT) && !empty(GH_TAGNAME)
>  DISTNAME ?=  
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
> +GH_DISTFILE = 
> ${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}
>  .endif
>  
>  PKGNAME ?= ${DISTNAME}

You're not using GH_DISTFILE for ports using GH_TAGNAME, is that
intentional?

With your diff, picking a random GH_TAGNAME por:

$ make -C /usr/ports/security/hydra -p | egrep 
'^(DIST(FILES|NAME)|GH_DISTFILE)'
DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
DISTNAME = 
${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}
GH_DISTFILE  = 
${GH_PROJECT}-${GH_TAGNAME:C/^(v|V|ver|[Rr]el|[Rr]elease)[-._]?([0-9])/\2/}${EXTRACT_SUFX}

> @@ -1289,7 +1290,8 @@ _warn_checksum += ;echo ">>> MASTER_SITE
>  EXTRACT_SUFX ?= .tar.gz
>  
>  .if !empty(GH_COMMIT)
> -DISTFILES ?= 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +GH_DISTFILE = 
> ${DISTNAME}-${GH_COMMIT:C/().*/\1/}${EXTRACT_SUFX}{${GH_COMMIT}${EXTRACT_SUFX}}
> +DISTFILES ?= ${GH_DISTFILE}
>  .else
>  .  if defined(DISTNAME)
>  DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX}
>