diff --git a/repology-schemacheck.py b/repology-schemacheck.py index 4c7d8f9d..03601100 100755 --- a/repology-schemacheck.py +++ b/repology-schemacheck.py @@ -111,6 +111,7 @@ 'salix', 'sclo', 'scoop', + 'serpentos', 'sisyphus', 'slackbuilds', 'spack', diff --git a/repology/packagemaker/names.py b/repology/packagemaker/names.py index d01f9ba1..c5741f4a 100644 --- a/repology/packagemaker/names.py +++ b/repology/packagemaker/names.py @@ -238,6 +238,8 @@ class NameType: T2_NAME: ClassVar[int] = GENERIC_SRC_NAME + SERPENTOS_NAME: ClassVar[int] = GENERIC_SRC_NAME + @dataclass class _NameMapping: diff --git a/repology/parsers/parsers/serpentos.py b/repology/parsers/parsers/serpentos.py new file mode 100644 index 00000000..10ab9ff2 --- /dev/null +++ b/repology/parsers/parsers/serpentos.py @@ -0,0 +1,60 @@ +# Copyright (C) 2024 Dmitry Marakasov +# +# This file is part of repology +# +# repology is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# repology is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with repology. If not, see . + +import os +from typing import Iterable + +import yaml + +from repology.logger import Logger +from repology.package import LinkType +from repology.packagemaker import NameType, PackageFactory, PackageMaker +from repology.parsers import Parser +from repology.parsers.walk import walk_tree + + +class SerpentOsGitParser(Parser): + def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]: + for filename in walk_tree(path, suffix='stone.yaml'): + relpath = os.path.relpath(filename, path) + subdir = os.path.basename(os.path.dirname(relpath)) + + with factory.begin(relpath) as pkg: + with open(filename, 'r') as fd: + pkgdata = yaml.safe_load(fd) + + if pkgdata['name'] != subdir: + RuntimeError(f'subdir "{subdir}" != name "{pkgdata["name"]}"') + + if isinstance(pkgdata['version'], float): + pkg.log(f'version "{pkgdata["version"]}" is a floating point, should be quoted in YAML', Logger.ERROR) + + pkg.add_name(pkgdata['name'], NameType.SERPENTOS_NAME) + pkg.set_version(str(pkgdata['version'])) + pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, pkgdata.get('homepage')) + pkg.add_licenses(pkgdata.get('license')) + pkg.set_summary(pkgdata.get('summary')) + + if upstreams := pkgdata.get('upstreams'): + for upstream in upstreams: + for url, checksum in upstream.items(): + if url.startswith('git|'): + pkg.add_links(LinkType.UPSTREAM_REPOSITORY, url[4:]) + else: + pkg.add_links(LinkType.UPSTREAM_DOWNLOAD, url) + + yield pkg diff --git a/repos.d/serpentos.yaml b/repos.d/serpentos.yaml new file mode 100644 index 00000000..daeb3964 --- /dev/null +++ b/repos.d/serpentos.yaml @@ -0,0 +1,30 @@ +########################################################################### +# SerpentOs +########################################################################### +- name: serpentos + type: repository + desc: Serpent OS + family: serpentos + ruleset: serpentos + minpackages: 400 + sources: + - name: recipes + fetcher: + class: GitFetcher + url: 'https://github.com/serpent-os/recipes.git' + branch: main + parser: + class: SerpentOsGitParser + repolinks: + - desc: Serpent OS home + url: https://serpentos.com/ + - desc: Recipes repository + url: https://github.com/serpent-os/recipes + packagelinks: + - type: PACKAGE_SOURCES + url: 'https://github.com/serpent-os/recipes/tree/main/{srcname|first_letter}/{srcname}' + - type: PACKAGE_RECIPE + url: 'https://github.com/serpent-os/recipes/blob/main/{srcname|first_letter}/{srcname}/stone.yaml' + - type: PACKAGE_RECIPE_RAW + url: 'https://raw.githubusercontent.com/serpent-os/recipes/main/{srcname|first_letter}/{srcname}/stone.yaml' + groups: [ all, production ]