pkgmeta: add multiple URL fields

This allows us to specifiy multiple URLs for each project in addition
to the homepage that is defined by the PKGBUILD.

This is similar to what Python packages can do, which then gets
exposed on pypi. But while they allow free form text we specify
a fixed set with a specific purpose, so we can pontentially re-use them
in the future, and also to make it more clear what we expect them to
point to.
This commit is contained in:
Christoph Reiter 2023-07-22 18:15:48 +02:00
parent b5a6db9025
commit 0149efb907
4 changed files with 61 additions and 4 deletions

View File

@ -283,6 +283,32 @@ class Package:
def __repr__(self) -> str:
return "Package(%s)" % self.fileurl
@property
def pkgmeta(self) -> PkgMetaEntry:
global state
return state.pkgmeta.packages.get(self.base, PkgMetaEntry())
@property
def urls(self) -> List[Tuple[str, str]]:
"""Returns a list of (name, url) tuples for the various URLs of the package"""
meta = self.pkgmeta
urls = []
# homepage from the PKGBUILD, everything else from PKGMETA
urls.append(("Homepage", self.url))
if meta.changelog_url is not None:
urls.append(("Changelog", meta.changelog_url))
if meta.repository_url is not None:
urls.append(("Repository", meta.repository_url))
if meta.issue_tracker_url is not None:
urls.append(("Issue tracker", meta.issue_tracker_url))
if meta.documentation_url is not None:
urls.append(("Documentation", meta.documentation_url))
if meta.pgp_keys_url is not None:
urls.append(("PGP keys", meta.pgp_keys_url))
return urls
@property
def realprovides(self) -> Dict[str, Set[str]]:
prov = {}
@ -435,6 +461,10 @@ class Source:
return state.pkgmeta.packages.get(self.name, PkgMetaEntry())
@property
def urls(self) -> List[Tuple[str, str]]:
return self._package.urls
@property
def external_infos(self) -> Sequence[Tuple[ExtId, ExtInfo]]:
global state

View File

@ -7,6 +7,7 @@ from typing import Dict, Optional
class PkgMetaEntry(BaseModel):
"""Extra metadata for a PKGBUILD"""
internal: bool = Field(default=False)
"""If the package is MSYS2 internal or just a meta package"""
@ -14,6 +15,24 @@ class PkgMetaEntry(BaseModel):
references: Dict[str, Optional[str]] = Field(default_factory=dict)
"""References to third party repositories"""
changelog_url: Optional[str] = Field(default=None)
"""A NEWS file in git or the github releases page.
In case there are multiple, the one that is more useful for packagers
"""
documentation_url: Optional[str] = Field(default=None)
"""Documentation for the API, tools, etc provided, in case it's a different
website"""
repository_url: Optional[str] = Field(default=None)
"""Web view of the repository, e.g. on github or gitlab"""
issue_tracker_url: Optional[str] = Field(default=None)
"""The bug tracker, mailing list, etc"""
pgp_keys_url: Optional[str] = Field(default=None)
"""A website containing which keys are used to sign releases"""
class PkgMeta(BaseModel):

View File

@ -55,8 +55,12 @@
{% endfor %}
</dd>
<dt class="col-sm-3 text-sm-end">Upstream URL:</dt>
<dd class="col-sm-9"><a href="{{ s.url }}">{{ s.url }}</a></dd>
<dt class="col-sm-3 text-sm-end">URL(s):</dt>
<dd class="col-sm-9">
{% for name, url in s.urls %}
<a href="{{ url }}">{{ name }}</a>{{ ", " if not loop.last else "" }}
{% endfor %}
</dd>
<dt class="col-sm-3 text-sm-end">License(s):</dt>
<dd class="col-sm-9">

View File

@ -44,8 +44,12 @@
<dt class="col-sm-3 text-sm-end">Repo:</dt>
<dd class="col-sm-9">{{ p.repo }}</dd>
<dt class="col-sm-3 text-sm-end">Upstream URL:</dt>
<dd class="col-sm-9"><a href="{{ p.url }}">{{ p.url }}</a></dd>
<dt class="col-sm-3 text-sm-end">URL(s):</dt>
<dd class="col-sm-9">
{% for name, url in p.urls %}
<a href="{{ url }}">{{ name }}</a>{{ ", " if not loop.last else "" }}
{% endfor %}
</dd>
<dt class="col-sm-3 text-sm-end">License(s):</dt>
<dd class="col-sm-9">{{ licenses_to_html(p.licenses)|safe }}</dd>