Skip to content

Commit

Permalink
Add Serpent OS (fixes #1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Jul 18, 2024
1 parent 9a194da commit c314772
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions repology-schemacheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
'salix',
'sclo',
'scoop',
'serpentos',
'sisyphus',
'slackbuilds',
'spack',
Expand Down
2 changes: 2 additions & 0 deletions repology/packagemaker/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ class NameType:

T2_NAME: ClassVar[int] = GENERIC_SRC_NAME

SERPENTOS_NAME: ClassVar[int] = GENERIC_SRC_NAME


@dataclass
class _NameMapping:
Expand Down
60 changes: 60 additions & 0 deletions repology/parsers/parsers/serpentos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (C) 2024 Dmitry Marakasov <amdmi3@amdmi3.ru>
#
# 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 <http://www.gnu.org/licenses/>.

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
30 changes: 30 additions & 0 deletions repos.d/serpentos.yaml
Original file line number Diff line number Diff line change
@@ -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 ]

0 comments on commit c314772

Please sign in to comment.