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/purl-types-index.json b/purl-types-index.json index e043fdae..6855d73c 100644 --- a/purl-types-index.json +++ b/purl-types-index.json @@ -27,6 +27,7 @@ "npm", "nuget", "oci", + "opam", "otp", "pub", "pypi", diff --git a/tests/types/opam-test.json b/tests/types/opam-test.json new file mode 100644 index 00000000..ebc6a8b3 --- /dev/null +++ b/tests/types/opam-test.json @@ -0,0 +1,71 @@ +{ + "$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 (name only)", + "test_group": "base", + "test_type": "build", + "input": { + "type": "opam", + "namespace": null, + "name": "conex", + "version": null, + "qualifiers": null, + "subpath": null + }, + "expected_output": "pkg:opam/conex", + "expected_failure": false, + "expected_failure_reason": null + }, + { + "description": "name is 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" + ] +}