diff --git a/dbuild/__init__.py b/dbuild/__init__.py index 42cfd69..d240677 100644 --- a/dbuild/__init__.py +++ b/dbuild/__init__.py @@ -1,4 +1,4 @@ """dbuild: FreeBSD OCI container image build tool. """ -VERSION = "1.13.1" +VERSION = "1.14.0" diff --git a/dbuild/config.py b/dbuild/config.py index 677c746..e6b8913 100644 --- a/dbuild/config.py +++ b/dbuild/config.py @@ -128,6 +128,19 @@ def _prefix_from_executable() -> Path | None: "Storage & Backup", ] +# Accepted with a deprecation warning in 1.14.x; become hard errors in 1.15.0. +LEGACY_CATEGORIES: list[str] = [ + "Development", + "Downloaders", + "Infrastructure", + "Media Management", + "Media Servers", + "Network", + "Photos & Media", + "Productivity", + "Utilities", +] + # ── Architecture tag suffixes ──────────────────────────────────────── # Single source of truth, shared by push, manifest, and the CI matrix diff --git a/dbuild/lint.py b/dbuild/lint.py index d8156b7..fa82c8d 100644 --- a/dbuild/lint.py +++ b/dbuild/lint.py @@ -11,7 +11,13 @@ from typing import Any from dbuild import choices as choices_mod -from dbuild.config import VALID_CATEGORIES, VALID_IMAGE_CLASSES, VALID_TYPES, is_cli_name +from dbuild.config import ( + LEGACY_CATEGORIES, + VALID_CATEGORIES, + VALID_IMAGE_CLASSES, + VALID_TYPES, + is_cli_name, +) _SLUG_RE = re.compile(r"^[a-z0-9][a-z0-9-]*$") _CF_CATEGORY_LABEL_RE = re.compile(r'io\.daemonless\.category="([^"{}$]+)"') @@ -189,7 +195,12 @@ def lint_repo(repo_path: Path, verbose: bool = False) -> tuple[list[str], list[s f"Invalid class '{image_class}'." f" Valid: {', '.join(VALID_IMAGE_CLASSES)}" ) - if category and category not in VALID_CATEGORIES: + if category and category in LEGACY_CATEGORIES: + warnings.append( + f"Deprecated category '{category}' (will be an error in 1.15.0)." + f" Valid: {', '.join(VALID_CATEGORIES)}" + ) + elif category and category not in VALID_CATEGORIES: errors.append( f"Invalid category '{category}'." f" Valid: {', '.join(VALID_CATEGORIES)}" @@ -331,7 +342,15 @@ def lint_repo(repo_path: Path, verbose: bool = False) -> tuple[list[str], list[s if isinstance(cfg_meta, dict): cfg_cat = cfg_meta.get("category", "") if not cfg_cat: - errors.append("Missing required field: x-daemonless.category") + warnings.append( + "Missing required field: x-daemonless.category" + " (will be an error in 1.15.0)" + ) + elif cfg_cat in LEGACY_CATEGORIES: + warnings.append( + f"Deprecated category '{cfg_cat}' (will be an error in 1.15.0)." + f" Valid: {', '.join(VALID_CATEGORIES)}" + ) elif cfg_cat not in VALID_CATEGORIES: errors.append( f"Invalid category '{cfg_cat}'." @@ -344,8 +363,9 @@ def lint_repo(repo_path: Path, verbose: bool = False) -> tuple[list[str], list[s effective_type = config.get("type") or meta.get("type", "") if meta.get("class") == "base" and effective_type != "base": - errors.append( - "x-daemonless.class: base requires type: base (in compose.yaml or .daemonless/config.yaml)" + warnings.append( + "x-daemonless.class: base requires type: base" + " (in compose.yaml or .daemonless/config.yaml; will be an error in 1.15.0)" ) archs = config.get("build", {}).get("architectures", []) @@ -507,8 +527,9 @@ def lint_repo(repo_path: Path, verbose: bool = False) -> tuple[list[str], list[s and meta.get("class") == "base" and meta.get("type") != "base" ): - errors.append( - "x-daemonless.class: base requires type: base (in compose.yaml or .daemonless/config.yaml)" + warnings.append( + "x-daemonless.class: base requires type: base" + " (in compose.yaml or .daemonless/config.yaml; will be an error in 1.15.0)" ) if verbose: @@ -525,9 +546,10 @@ def lint_repo(repo_path: Path, verbose: bool = False) -> tuple[list[str], list[s for m in _CF_CATEGORY_LABEL_RE.finditer(cf_text): cf_cat = m.group(1).strip() if cf_cat != expected_category: - errors.append( + warnings.append( f"{cf_path.name}: io.daemonless.category={cf_cat!r} does not match" f" x-daemonless.category={expected_category!r}" + " (will be an error in 1.15.0)" ) warnings.extend(_lint_containerfile_bloat(cf_path, cf_text.splitlines())) diff --git a/docs/dbuild.1 b/docs/dbuild.1 index d861277..b54494d 100644 --- a/docs/dbuild.1 +++ b/docs/dbuild.1 @@ -1,4 +1,4 @@ -.TH DBUILD 1 "2026-11-24" "dbuild 1.13.1" "User Commands" +.TH DBUILD 1 "2026-12-01" "dbuild 1.14.0" "User Commands" .SH NAME dbuild \- FreeBSD OCI container image build tool .SH SYNOPSIS diff --git a/tests/test_lint.py b/tests/test_lint.py index 5fa40f2..48d4bf7 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -442,7 +442,7 @@ def test_own_path_must_keep_the_wrappers_first(self): class TestTaxonomyAndMetadataLint(unittest.TestCase): """Tests for canonical 10-category taxonomy, Base/class parity, Containerfile label parity, and screenshot bloat.""" - def test_utilities_category_is_rejected(self): + def test_legacy_category_warns_without_error(self): import tempfile with tempfile.TemporaryDirectory() as d: p = Path(d) @@ -452,8 +452,22 @@ def test_utilities_category_is_rejected(self): " description: d\n upstream_url: https://example.com\n user: bsd\n" "services:\n app:\n image: ghcr.io/daemonless/app:latest\n" ) + errors, warnings = lint_repo(p) + self.assertEqual(errors, []) + self.assertTrue(any("Deprecated category 'Utilities'" in w for w in warnings), warnings) + + def test_unknown_category_is_rejected(self): + import tempfile + with tempfile.TemporaryDirectory() as d: + p = Path(d) + (p / "Containerfile").write_text("FROM scratch\n") + (p / "compose.yaml").write_text( + "name: app\nx-daemonless:\n title: App\n icon: ':x:'\n category: Bogus\n" + " description: d\n upstream_url: https://example.com\n user: bsd\n" + "services:\n app:\n image: ghcr.io/daemonless/app:latest\n" + ) errors, _ = lint_repo(p) - self.assertTrue(any("Invalid category 'Utilities'" in e for e in errors), errors) + self.assertTrue(any("Invalid category 'Bogus'" in e for e in errors), errors) def test_base_category_and_class_parity(self): import tempfile @@ -468,13 +482,41 @@ def test_base_category_and_class_parity(self): errors, _ = lint_repo(p) self.assertTrue(any("Category 'Base' is reserved" in e for e in errors), errors) - def test_containerfile_category_mismatch_and_oversized_screenshot(self): + def test_base_class_without_base_type_warns_without_error(self): + import tempfile + with tempfile.TemporaryDirectory() as d: + p = Path(d) + (p / "Containerfile").write_text("FROM scratch\n") + (p / "compose.yaml").write_text( + "name: node\nx-daemonless:\n title: Node\n icon: ':x:'\n category: Base\n" + " class: base\n description: d\n upstream_url: https://example.com\n user: bsd\n" + "services:\n node:\n image: ghcr.io/daemonless/node:latest\n" + ) + errors, warnings = lint_repo(p) + self.assertEqual(errors, []) + self.assertTrue(any("x-daemonless.class: base requires type: base" in w for w in warnings), warnings) + + def test_containerfile_category_mismatch_warns_without_error(self): import tempfile with tempfile.TemporaryDirectory() as d: p = Path(d) (p / "Containerfile").write_text( 'FROM scratch\nLABEL io.daemonless.category="Utilities"\n' ) + (p / "compose.yaml").write_text( + "name: app\nx-daemonless:\n title: App\n icon: ':x:'\n category: Networking\n" + " description: d\n upstream_url: https://example.com\n user: bsd\n" + "services:\n app:\n image: ghcr.io/daemonless/app:latest\n" + ) + errors, warnings = lint_repo(p) + self.assertEqual(errors, []) + self.assertTrue(any("io.daemonless.category" in w for w in warnings), warnings) + + def test_invalid_part_of_and_oversized_screenshot(self): + import tempfile + with tempfile.TemporaryDirectory() as d: + p = Path(d) + (p / "Containerfile").write_text("FROM scratch\n") (p / ".daemonless" / "screenshots").mkdir(parents=True) (p / ".daemonless" / "screenshots" / "huge.png").write_bytes(b"0" * (1600 * 1024)) (p / "compose.yaml").write_text( @@ -484,6 +526,5 @@ def test_containerfile_category_mismatch_and_oversized_screenshot(self): "services:\n app:\n image: ghcr.io/daemonless/app:latest\n" ) errors, warnings = lint_repo(p) - self.assertTrue(any("io.daemonless.category" in e for e in errors), errors) self.assertTrue(any("part_of" in e for e in errors), errors) self.assertTrue(any("huge.png" in w for w in warnings), warnings)