diff --git a/craft_archives/repo/package_repository.py b/craft_archives/repo/package_repository.py index db08bc6..3068185 100644 --- a/craft_archives/repo/package_repository.py +++ b/craft_archives/repo/package_repository.py @@ -27,6 +27,7 @@ from pydantic import ( AnyUrl, ConstrainedStr, + FileUrl, root_validator, # pyright: ignore[reportUnknownVariableType] validator, # pyright: ignore[reportUnknownVariableType] ) @@ -220,7 +221,7 @@ def pin(self) -> str: class PackageRepositoryApt(PackageRepository): """An APT package repository.""" - url: AnyUrl + url: Union[AnyUrl, FileUrl] key_id: KeyIdStr = pydantic.Field(alias="key-id") architectures: Optional[List[str]] formats: Optional[List[Literal["deb", "deb-src"]]] diff --git a/tests/unit/repo/test_package_repository.py b/tests/unit/repo/test_package_repository.py index 3b097be..d886161 100644 --- a/tests/unit/repo/test_package_repository.py +++ b/tests/unit/repo/test_package_repository.py @@ -97,6 +97,12 @@ def test_apt_name(): "key-server": "my-key-server", "suites": ["some", "suites"], }, + { # File URLs. See: https://github.com/canonical/craft-archives/issues/92 + "type": "apt", + "url": "file:///tmp/apt-repo", + "path": "my/path", + "key-id": "BCDEF12345" * 4, + }, ], ) def test_apt_valid(repo, priority): @@ -104,7 +110,7 @@ def test_apt_valid(repo, priority): repo["priority"] = priority apt_deb = PackageRepositoryApt.unmarshal(repo) assert apt_deb.type == "apt" - assert apt_deb.url == "https://some/url" + assert apt_deb.url == repo["url"] assert apt_deb.key_id == "BCDEF12345" * 4 assert apt_deb.formats == (["deb"] if "formats" in repo else None) assert apt_deb.components == (