Klemens Nanni <[email protected]> writes:

> On Thu, Nov 25, 2021 at 04:45:06PM +0100, Omar Polo wrote:
>> I wanted to share gelatod with a friend but the package lacks a HOMEPAGE
>> and so `pkg_info gelatod' too.  I think it's handy to have a link in the
>> description, even if the package in question it's not really useful
>> outside of OpenBSD :)
>
> OK kn
>
> This makes me think:  Probably more ports use github.com as MASTER_SITES but
> don't have HOMEPAGE set... in bsd.port.mk(5) we could default to
> "https://github.com/author/repository"; for such ports and fix all of them.
>
> What do you think?
>
> [...]
>
> Here is a diff that yields the same HOMEPAGE for gelatod.
>
> I would still have yet to grep the tree and REVISION bump effected ones,
> but let's gauge interest first.

Came up with the following query against sqlports

select p.fullpkgpath
  from _paths p
  join _ports pp on pp.fullpkgpath = p.id
  join _mastersites ms on ms.fullpkgpath = p.id
 where pp.homepage is null and ms.value like 'https://github.com%';

probably not the best one but works and finds 25 ports affected, it
should save some grepping eventually :)

(it's important to match against 'https://github.com%' and not only
'%github.com%' or '%github%' like I initially did because it otherwise
picks up for e.g. stuff like proxy.golang.org/github.com/...)

> Index: bsd.port.mk
> ===================================================================
> RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
> retrieving revision 1.1562
> diff -u -p -r1.1562 bsd.port.mk
> --- bsd.port.mk       22 Nov 2021 11:01:47 -0000      1.1562
> +++ bsd.port.mk       25 Nov 2021 20:25:59 -0000
> @@ -1254,6 +1254,13 @@ HOMEPAGE ?= https://github.com/${GH_ACCO
>  .else
>  # Empty declarations to avoid "variable XXX is recursive" errors
>  MASTER_SITES ?=
> +
> +# default to the repository URL if MASTER_SITES points to GitHub
> +_GH_MASTER_URL = ${MASTER_SITES:Mhttps\://github.com/*}
> +.  if !empty(_GH_MASTER_URL)
> +# cut down to /author/repository
> +HOMEPAGE ?= ${_GH_MASTER_URL:C,(https\://github.com(/[^/]+){2}).*,\1,1}
> +.  endif
>  .endif
>  
>  # I guess we're in the master distribution business! :)  As we gain mirror

FWIW I like the result, having HOMEPAGE defined surely comes in handy :D

Reply via email to