5 Commits

Author SHA1 Message Date
unkinben f487365f96 feat: dist_tag boolean for distro-aware release strings
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build-fedora42 Pipeline was successful
ci/woodpecker/pr/build-fedora44 Pipeline was successful
ci/woodpecker/pr/build-fedora43 Pipeline was successful
ci/woodpecker/pr/build-almalinux8 Pipeline was successful
ci/woodpecker/pr/build-almalinux9 Pipeline was successful
Adds a per-package dist_tag: true/false metadata flag (default false).
When enabled the build tool appends the RPM dist tag to the release
at build time so each distro produces a unique version in the Gitea
package registry:

  release: 1  +  almalinux/el9  ->  PACKAGE_RELEASE=1.el9
  release: 1  +  fedora/43      ->  PACKAGE_RELEASE=1.fc43

This ensures Gitea package existence checks don't confuse packages built
for one distro with those built for another (the original bug).

Changes:
- Add effective_release() and get_rpm_dist_tag() helpers
- Revert the broken files-endpoint check from the previous commit;
  dist disambiguation is now handled purely via the release string
- discover_packages and build_single both compute the effective release
  before constructing PackageInfo
- check_package_exists simplified back to a single version-level check
- dist_tag added to METADATA_SCHEMA and PackageMetadata dataclass
- All 69 metadata.yaml files updated with dist_tag: true
- Exclude jellyfin from dist_tags
2026-05-17 12:36:06 +10:00
unkinben 651a38392e feat: add HTTP sessions and retry logic for Gitea/GitHub API calls
Creates two module-level requests.Session objects (_gitea_session,
_github_session) with an HTTPAdapter backed by urllib3 Retry:
- 3 retries with 0.5s exponential backoff
- retries on 429, 500, 502, 503, 504 and connection errors
- GET-only to avoid unsafe retries

Benefits:
- TCP connections are pooled and reused across all package checks,
  including concurrent builds in ThreadPoolExecutor
- Transient network blips no longer cause spurious rebuilds
- Per-request timeouts tightened to 10s (Gitea) / 15s (GitHub)
  so failures surface quickly and the retry budget is actually useful
2026-05-17 12:35:11 +10:00
unkinben 91771c2c4a fix: make package existence check distro-aware
check_package_exists was only checking name+version+release, so an
almalinux package already in Gitea would cause fedora builds to be
skipped incorrectly.

Now passes the target distro from PackageInfo through to
check_package_exists, which maps it to an RPM dist suffix (.el9,
.fc43, etc.) and queries the Gitea package files endpoint to confirm
a distro-specific file exists before skipping the build.

Also adds fedora/42, fedora/43, fedora/44 to the allowed repository
values in the metadata schema.
2026-05-17 12:35:11 +10:00
unkinben 539a63e0a1 feat/metadata-schema-validation (#165)
ci/woodpecker/push/deploy-fedora42 Pipeline was successful
ci/woodpecker/push/deploy-fedora43 Pipeline was successful
ci/woodpecker/push/deploy-fedora44 Pipeline was successful
ci/woodpecker/push/deploy-almalinux9 Pipeline was successful
ci/woodpecker/push/deploy-almalinux8 Pipeline was successful
Reviewed-on: #165
2026-05-17 12:34:33 +10:00
unkinben aeea587aeb fix: move unkin-undionly-kpxe preinstall.sh to scripts/ subdirectory (#166)
ci/woodpecker/push/deploy-fedora42 Pipeline was successful
ci/woodpecker/push/deploy-fedora43 Pipeline was successful
ci/woodpecker/push/deploy-almalinux9 Pipeline was successful
ci/woodpecker/push/deploy-fedora44 Pipeline was successful
ci/woodpecker/push/deploy-almalinux8 Pipeline was successful
nfpm.yaml referenced /app/resources/scripts/preinstall.sh but the file
was at resources/preinstall.sh, causing the build to fail.

Reviewed-on: #166
2026-05-17 12:29:10 +10:00
9 changed files with 183 additions and 2 deletions
+18
View File
@@ -31,6 +31,24 @@ repos:
"-s",
]
- repo: local
hooks:
- id: pytest
name: Run unit tests
entry: make test
language: system
types: [python]
pass_filenames: false
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.2
hooks:
- id: check-jsonschema
name: Validate RPM package metadata
files: ^rpms/[^/]+/metadata\.yaml$
args: [--schemafile, schema/metadata.json]
language_version: python3.11
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.7
hooks:
+5 -1
View File
@@ -11,7 +11,7 @@ DISTRO ?= almalinux/el9
PACKAGES := $(shell find $(ROOT_DIR)/rpms -mindepth 1 -maxdepth 1 -type d -exec test -f {}/metadata.yaml \; -print | xargs -n1 basename | sort)
# Default target to build all packages
.PHONY: all list build clean
.PHONY: all list build clean test
all: build-all
# List all available packages
@@ -47,6 +47,10 @@ dry-run:
@echo "Dry run - showing what would be built for distro $(DISTRO):"
$(BUILD_TOOL) build-all --distro $(DISTRO) --dry-run
# Run unit tests
test:
@uv run --group dev pytest tests/ -q; rc=$$?; [ $$rc -eq 5 ] && exit 0 || exit $$rc
# Clean target
clean:
@echo "Cleaning build artifacts..."
+11
View File
@@ -0,0 +1,11 @@
[project]
name = "rpmbuilder"
version = "0.1.0"
requires-python = ">=3.11"
[dependency-groups]
dev = [
"pytest>=8",
"jsonschema>=4",
"pyyaml>=6",
]
-1
View File
@@ -17,4 +17,3 @@ builds:
repository:
- almalinux/el9
version: 2.1.126
claude_ai: true
+111
View File
@@ -0,0 +1,111 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "Schema for rpms/*/metadata.yaml files",
"properties": {
"arch": {
"enum": [
"amd64",
"arm64",
"x86_64"
],
"type": "string"
},
"builds": {
"items": {
"additionalProperties": false,
"properties": {
"image": {
"minLength": 1,
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-_.:/@]+$",
"type": "string"
},
"release": {
"oneOf": [
{
"minLength": 1,
"type": "string"
},
{
"type": "number"
}
]
},
"repository": {
"items": {
"enum": [
"almalinux/el8",
"almalinux/el9",
"fedora/42",
"fedora/43",
"fedora/44"
],
"type": "string"
},
"minItems": 1,
"type": "array"
},
"version": {
"minLength": 1,
"pattern": "^[0-9]+(\\.[0-9]+)*(-[a-zA-Z0-9]+)*$",
"type": "string"
}
},
"required": [
"repository",
"image",
"release",
"version"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"description": {
"minLength": 1,
"type": "string"
},
"dist_tag": {
"type": "boolean"
},
"github": {
"minLength": 1,
"pattern": "^[a-zA-Z0-9\\-_]+/[a-zA-Z0-9\\-_.]+$",
"type": "string"
},
"github_release_pattern": {
"minLength": 1,
"type": "string"
},
"homepage": {
"minLength": 1,
"pattern": "^https?://.+",
"type": "string"
},
"license": {
"minLength": 1,
"type": "string"
},
"maintainer": {
"minLength": 1,
"type": "string"
},
"name": {
"minLength": 1,
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9\\-_.]*$",
"type": "string"
},
"platform": {
"minLength": 1,
"type": "string"
}
},
"required": [
"name",
"description",
"builds"
],
"title": "RPM Package Metadata",
"type": "object"
}
View File
+2
View File
@@ -0,0 +1,2 @@
# Tests for tools/build and tools/update-gh.
# See https://git.unkin.net/unkin/rpmbuilder/issues/162
+36
View File
@@ -0,0 +1,36 @@
"""Validate every rpms/*/metadata.yaml against schema/metadata.json."""
import json
from pathlib import Path
import jsonschema
import pytest
import yaml
REPO_ROOT = Path(__file__).parent.parent
SCHEMA_FILE = REPO_ROOT / "schema" / "metadata.json"
RPMS_DIR = REPO_ROOT / "rpms"
@pytest.fixture(scope="session")
def schema():
with open(SCHEMA_FILE) as f:
return json.load(f)
def metadata_files():
return sorted(RPMS_DIR.glob("*/metadata.yaml"))
@pytest.mark.parametrize("metadata_file", metadata_files(), ids=lambda p: p.parent.name)
def test_metadata_valid(metadata_file, schema):
with open(metadata_file) as f:
data = yaml.safe_load(f)
validator = jsonschema.Draft7Validator(schema)
errors = sorted(validator.iter_errors(data), key=str)
assert not errors, "\n".join(
f" {'.'.join(str(p) for p in e.absolute_path) or '(root)'}: {e.message}"
for e in errors
)