From a68516b5aaf753dca700cbb5be03cc566e3775ab Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Thu, 4 Dec 2025 15:32:25 +0100 Subject: [PATCH 1/4] add opam package url specification Co-Authored-By: Laurent Goderre Co-Authored-By: Kate --- docs/candidate-purl-types.md | 1 - tests/types/opam-test.json | 89 ++++++++++++++++++++++++++++++++++++ types/opam-definition.json | 30 ++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 tests/types/opam-test.json create mode 100644 types/opam-definition.json diff --git a/docs/candidate-purl-types.md b/docs/candidate-purl-types.md index b86f70c6..640ab007 100644 --- a/docs/candidate-purl-types.md +++ b/docs/candidate-purl-types.md @@ -30,7 +30,6 @@ - ``meteor`` for Meteor JavaScript packages - ``nim`` for Nim packages - ``nix`` for Nixos packages -- ``opam`` for OCaml packages - ``openwrt`` for OpenWRT packages - ``osgi`` for OSGi bundle packages - ``p2`` for Eclipse p2 packages diff --git a/tests/types/opam-test.json b/tests/types/opam-test.json new file mode 100644 index 00000000..299cd96e --- /dev/null +++ b/tests/types/opam-test.json @@ -0,0 +1,89 @@ +{ + "$schema": "https://packageurl.org/schemas/purl-test.schema-0.1.json", + "tests": [ + { + "description": "valid opam purl. Roundtrip an input purl to canonical.", + "test_group": "advanced", + "test_type": "roundtrip", + "input": "pkg:opam/conex@1.0.0", + "expected_output": "pkg:opam/conex@1.0.0", + "expected_failure": false, + "expected_failure_reason": null + }, + { + "description": "valid opam purl", + "test_group": "base", + "test_type": "parse", + "input": "pkg:opam/conex@1.0.0", + "expected_output": { + "type": "opam", + "namespace": null, + "name": "conex", + "version": "1.0.0", + "qualifiers": null, + "subpath": null + }, + "expected_failure": false, + "expected_failure_reason": null + }, + { + "description": "valid opam purl. Roundtrip a canonical input to canonical output.", + "test_group": "base", + "test_type": "roundtrip", + "input": "pkg:opam/conex@1.0.0", + "expected_output": "pkg:opam/conex@1.0.0", + "expected_failure": false, + "expected_failure_reason": null + }, + { + "description": "valid opam purl", + "test_group": "base", + "test_type": "build", + "input": { + "type": "opam", + "namespace": null, + "name": "conex", + "version": "1.0.0", + "qualifiers": null, + "subpath": null + }, + "expected_output": "pkg:opam/conex@1.0.0", + "expected_failure": false, + "expected_failure_reason": null + }, + { + "description": "name and version are always required", + "test_group": "base", + "test_type": "parse", + "input": "pkg:opam", + "expected_output": null, + "expected_failure": true, + "expected_failure_reason": "Should fail to parse a PURL from invalid purl input" + }, + { + "description": "name and version are always required", + "test_group": "base", + "test_type": "parse", + "input": "pkg:opam", + "expected_output": null, + "expected_failure": true, + "expected_failure_reason": "Should fail to parse a PURL from invalid canonical purl input" + }, + { + "description": "name and version are always required", + "test_group": "base", + "test_type": "build", + "input": { + "type": "opam", + "namespace": null, + "name": null, + "version": null, + "qualifiers": null, + "subpath": null + }, + "expected_output": null, + "expected_failure": true, + "expected_failure_reason": "Should fail to build a PURL from invalid input components" + } + ] +} diff --git a/types/opam-definition.json b/types/opam-definition.json new file mode 100644 index 00000000..64a407a2 --- /dev/null +++ b/types/opam-definition.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://packageurl.org/schemas/purl-type-definition.schema-1.0.json", + "$id": "https://packageurl.org/types/opam-definition.json", + "type": "opam", + "type_name": "Opam package", + "description": "Opam packages", + "repository": { + "use_repository": true, + "default_repository_url": "https://opam.ocaml.org" + }, + "namespace_definition": { + "requirement": "prohibited", + "note": "there is no namespace" + }, + "name_definition": { + "requirement": "required", + "case_sensitive": true, + "native_name": "name", + "note": "The name is case sensitive." + }, + "version_definition": { + "requirement": "optional", + "native_name": "version", + "note": "The version is package version." + }, + "examples": [ + "pkg:opam/ocaml-base-compiler@5.2.0", + "pkg:opam/git@3/16.1" + ] +} From cd4b0734d6caa5cf28e6e1c6ca368409d4ea8633 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 10 Dec 2025 15:52:43 +0100 Subject: [PATCH 2/4] add opam to purl-types-index --- purl-types-index.json | 1 + 1 file changed, 1 insertion(+) diff --git a/purl-types-index.json b/purl-types-index.json index c956935b..ac9b6c69 100644 --- a/purl-types-index.json +++ b/purl-types-index.json @@ -27,6 +27,7 @@ "npm", "nuget", "oci", + "opam", "pub", "pypi", "qpkg", From bb1c445b1073ca5fd9f372ec22bb3a458f353103 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 7 Jan 2026 13:13:37 +0100 Subject: [PATCH 3/4] remove two tests as suggested by review --- tests/types/opam-test.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/types/opam-test.json b/tests/types/opam-test.json index 299cd96e..6a76bfb2 100644 --- a/tests/types/opam-test.json +++ b/tests/types/opam-test.json @@ -51,24 +51,6 @@ "expected_failure": false, "expected_failure_reason": null }, - { - "description": "name and version are always required", - "test_group": "base", - "test_type": "parse", - "input": "pkg:opam", - "expected_output": null, - "expected_failure": true, - "expected_failure_reason": "Should fail to parse a PURL from invalid purl input" - }, - { - "description": "name and version are always required", - "test_group": "base", - "test_type": "parse", - "input": "pkg:opam", - "expected_output": null, - "expected_failure": true, - "expected_failure_reason": "Should fail to parse a PURL from invalid canonical purl input" - }, { "description": "name and version are always required", "test_group": "base", From 67ecae6a0ec3242caf772096795eeed0f19f804d Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 14 Jan 2026 22:43:34 +0100 Subject: [PATCH 4/4] version is not required for opam, as commented by @johnmhoran --- tests/types/opam-test.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/types/opam-test.json b/tests/types/opam-test.json index 6a76bfb2..ebc6a8b3 100644 --- a/tests/types/opam-test.json +++ b/tests/types/opam-test.json @@ -36,23 +36,23 @@ "expected_failure_reason": null }, { - "description": "valid opam purl", + "description": "valid opam purl (name only)", "test_group": "base", "test_type": "build", "input": { "type": "opam", "namespace": null, "name": "conex", - "version": "1.0.0", + "version": null, "qualifiers": null, "subpath": null }, - "expected_output": "pkg:opam/conex@1.0.0", + "expected_output": "pkg:opam/conex", "expected_failure": false, "expected_failure_reason": null }, { - "description": "name and version are always required", + "description": "name is always required", "test_group": "base", "test_type": "build", "input": {