Skip to content

Commit e578e27

Browse files
authored
Merge pull request #472 from maennchen/jm/otp_type
Add `otp` Type
2 parents 7d75ccc + 4f03a27 commit e578e27

File tree

4 files changed

+250
-0
lines changed

4 files changed

+250
-0
lines changed

purl-types-index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"npm",
2828
"nuget",
2929
"oci",
30+
"otp",
3031
"pub",
3132
"pypi",
3233
"qpkg",

tests/types/otp-test.json

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"$schema": "https://packageurl.org/schemas/purl-test.schema-0.1.json",
3+
"tests": [
4+
{
5+
"description": "Parse test for <class 'type'> PURL",
6+
"test_group": "base",
7+
"test_type": "parse",
8+
"input": "pkg:otp/asn1@5.4.1?arch=amd64&platform=linux&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git#src/asn1ct.erl",
9+
"expected_output": {
10+
"type": "otp",
11+
"namespace": null,
12+
"name": "asn1",
13+
"version": "5.4.1",
14+
"qualifiers": {
15+
"platform": "linux",
16+
"arch": "amd64",
17+
"repository_url": "https://github.com/erlang/otp",
18+
"vcs_url": "git+https://github.com/erlang/otp.git"
19+
},
20+
"subpath": "src/asn1ct.erl"
21+
},
22+
"expected_failure": false,
23+
"expected_failure_reason": null
24+
},
25+
{
26+
"description": "Roundtrip test for <class 'type'> PURL",
27+
"test_group": "base",
28+
"test_type": "roundtrip",
29+
"input": "pkg:otp/asn1@5.4.1?arch=amd64&platform=linux&repository_url=https://github.com/erlang/otp&vcs_url=git%2Bhttps://github.com/erlang/otp.git#src/asn1ct.erl",
30+
"expected_output": "pkg:otp/asn1@5.4.1?arch=amd64&platform=linux&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git#src/asn1ct.erl",
31+
"expected_failure": false,
32+
"expected_failure_reason": null
33+
},
34+
{
35+
"description": "Build test for <class 'type'> PURL",
36+
"test_group": "base",
37+
"test_type": "build",
38+
"input": {
39+
"type": "otp",
40+
"namespace": null,
41+
"name": "asn1",
42+
"version": "5.4.1",
43+
"qualifiers": {
44+
"platform": "linux",
45+
"arch": "amd64",
46+
"repository_url": "https://github.com/erlang/otp",
47+
"vcs_url": "git+https://github.com/erlang/otp.git"
48+
},
49+
"subpath": "src/asn1ct.erl"
50+
},
51+
"expected_output": "pkg:otp/asn1@5.4.1?arch=amd64&platform=linux&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git#src/asn1ct.erl",
52+
"expected_failure": false,
53+
"expected_failure_reason": null
54+
},
55+
{
56+
"description": "Parse test for <class 'type'> PURL",
57+
"test_group": "base",
58+
"test_type": "parse",
59+
"input": "pkg:otp/hex@2.1.1",
60+
"expected_output": {
61+
"type": "otp",
62+
"namespace": null,
63+
"name": "hex",
64+
"version": "2.1.1",
65+
"qualifiers": null,
66+
"subpath": null
67+
},
68+
"expected_failure": false,
69+
"expected_failure_reason": null
70+
},
71+
{
72+
"description": "Roundtrip test for <class 'type'> PURL",
73+
"test_group": "base",
74+
"test_type": "roundtrip",
75+
"input": "pkg:otp/hex@2.1.1",
76+
"expected_output": "pkg:otp/hex@2.1.1",
77+
"expected_failure": false,
78+
"expected_failure_reason": null
79+
},
80+
{
81+
"description": "Build test for <class 'type'> PURL",
82+
"test_group": "base",
83+
"test_type": "build",
84+
"input": {
85+
"type": "otp",
86+
"namespace": null,
87+
"name": "hex",
88+
"version": "2.1.1",
89+
"qualifiers": null,
90+
"subpath": null
91+
},
92+
"expected_output": "pkg:otp/hex@2.1.1",
93+
"expected_failure": false,
94+
"expected_failure_reason": null
95+
},
96+
{
97+
"description": "Parse test for <class 'type'> PURL",
98+
"test_group": "base",
99+
"test_type": "parse",
100+
"input": "pkg:otp/namespace/hex@2.1.1",
101+
"expected_failure": true,
102+
"expected_failure_reason": "Should fail to parse an OTP PURL containing a prohibited namespace component"
103+
},
104+
{
105+
"description": "Build test for <class 'type'> PURL",
106+
"test_group": "base",
107+
"test_type": "build",
108+
"input": {
109+
"type": "otp",
110+
"namespace": "namespace",
111+
"name": "hex",
112+
"version": "2.1.1",
113+
"qualifiers": null,
114+
"subpath": null
115+
},
116+
"expected_failure": true,
117+
"expected_failure_reason": "Should fail to build an OTP PURL containing a prohibited namespace component"
118+
}
119+
]
120+
}

types-doc/otp-definition.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!-- NOTE: Auto-generated from the JSON PURL type definition.
2+
Do not manually edit this file. Edit the JSON type definition instead. -->
3+
4+
# PURL Type Definition: otp
5+
6+
- **Type Name:** BEAM/OTP Application
7+
- **Description:** BEAM/OTP applications written in Elixir, Erlang, Gleam and other BEAM languages
8+
- **Schema ID:** `https://packageurl.org/types/otp-definition.json`
9+
10+
## PURL Syntax
11+
12+
The structure of a PURL for this package type is:
13+
14+
pkg:otp/<name>@<version>?<qualifiers>#<subpath>
15+
16+
## Repository Information
17+
18+
- **Use Repository:** No
19+
20+
## Namespace definition
21+
22+
- **Requirement:** Prohibited
23+
- **Note:** `The component is unused and MUST be empty`
24+
25+
## Name definition
26+
27+
- **Requirement:** Required
28+
- **Native Label:** name
29+
- **Note:** `The OTP application name from the `.app` file; it is case-insensitive and MUST be lower-cased.`
30+
31+
## Version definition
32+
33+
- **Requirement:** Optional
34+
- **Native Label:** version
35+
- **Note:** `The OTP application version (the `vsn` attribute).`
36+
37+
## Subpath definition
38+
39+
- **Requirement:** Optional
40+
- **Native Label:** May be added to reference a specific file or directory inside the OTP application.
41+
42+
## Qualifiers Definition
43+
44+
| Key | Requirement | Native name | Default Value | Description |
45+
|------|-------------|-------------|---------------|-------------|
46+
| repository_url | Optional | Repository URL | | The canonical origin of the OTP application source. This qualifier is optional, but it should be included whenever the origin is known, and should point to a trusted source repository. |
47+
| platform | Optional | platform | | The target operating system for native code (e.g. ``linux``, ``darwin``, ``freebsd``, ``sunos``, ``win32``; case-insensitive). |
48+
| arch | Optional | arch | | The arch is the qualifiers key for a package architecture. |
49+
50+
## Examples
51+
52+
- `pkg:otp/erts@10.6.3?platform=linux&arch=amd64&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%20https:%2F%2Fgithub.com%2Ferlang%2Fotp.git`
53+
- `pkg:otp/stdlib@3.11.2?repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%20https:%2F%2Fgithub.com%2Ferlang%2Fotp.git`
54+
- `pkg:otp/crypto@4.6.4?platform=darwin&arch=x86_64&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%20https:%2F%2Fgithub.com%2Ferlang%2Fotp.git`
55+
- `pkg:otp/elixir@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%20https:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git`
56+
- `pkg:otp/eex@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%20https:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git`
57+
- `pkg:otp/logger@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%20https:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git`
58+
- `pkg:otp/rebar@3.13.0?repository_url=https:%2F%2Fgithub.com%2Ferlang%2Frebar3&vcs_url=git%20https:%2F%2Fgithub.com%2Ferlang%2Frebar3.git`
59+
- `pkg:otp/hex@2.1.1?repository_url=https:%2F%2Fgithub.com%2Fhexpm%2Fhex&vcs_url=git%20https:%2F%2Fgithub.com%2Fhexpm%2Fhex.git`
60+
61+
## Note
62+
63+
- If the component was fetched from a Hex repository, prefer a ``hex`` purl
64+
because Hex provides a global, collision-free namespace that uniquely ties
65+
the version to the published source.
66+
- There is no default package repository. When the application can be
67+
fetched from a known location, add a general qualifier such as
68+
`repository_url`, `download_url` or `vcs_url`.

types/otp-definition.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"$schema": "https://packageurl.org/schemas/purl-type-definition.schema-1.0.json",
3+
"$id": "https://packageurl.org/types/otp-definition.json",
4+
"type": "otp",
5+
"type_name": "BEAM/OTP Application",
6+
"description": "BEAM/OTP applications written in Elixir, Erlang, Gleam and other BEAM languages",
7+
"note": "- If the component was fetched from a Hex repository, prefer a ``hex`` purl\n because Hex provides a global, collision-free namespace that uniquely ties\n the version to the published source.\n- There is no default package repository. When the application can be\n fetched from a known location, add a general qualifier such as\n `repository_url`, `download_url` or `vcs_url`.",
8+
"repository": {
9+
"use_repository": false
10+
},
11+
"namespace_definition": {
12+
"requirement": "prohibited",
13+
"note": "The component is unused and MUST be empty"
14+
},
15+
"name_definition": {
16+
"case_sensitive": false,
17+
"native_name": "name",
18+
"note": "The OTP application name from the `.app` file; it is case-insensitive and MUST be lower-cased.",
19+
"requirement": "required"
20+
},
21+
"version_definition": {
22+
"native_name": "version",
23+
"note": "The OTP application version (the `vsn` attribute).",
24+
"requirement": "optional"
25+
},
26+
"subpath_definition": {
27+
"case_sensitive": false,
28+
"native_name": "May be added to reference a specific file or directory inside the OTP application.",
29+
"requirement": "optional"
30+
},
31+
"qualifiers_definition": [
32+
{
33+
"key": "repository_url",
34+
"requirement": "optional",
35+
"native_name": "Repository URL",
36+
"description": "The canonical origin of the OTP application source. This qualifier is optional, but it should be included whenever the origin is known, and should point to a trusted source repository."
37+
},
38+
{
39+
"key": "platform",
40+
"requirement": "optional",
41+
"native_name": "platform",
42+
"description": "The target operating system for native code (e.g. ``linux``, ``darwin``, ``freebsd``, ``sunos``, ``win32``; case-insensitive)."
43+
},
44+
{
45+
"key": "arch",
46+
"requirement": "optional",
47+
"native_name": "arch",
48+
"description": "The arch is the qualifiers key for a package architecture."
49+
}
50+
],
51+
"examples": [
52+
"pkg:otp/erts@10.6.3?platform=linux&arch=amd64&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git",
53+
"pkg:otp/stdlib@3.11.2?repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git",
54+
"pkg:otp/crypto@4.6.4?platform=darwin&arch=x86_64&repository_url=https:%2F%2Fgithub.com%2Ferlang%2Fotp&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Fotp.git",
55+
"pkg:otp/elixir@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git",
56+
"pkg:otp/eex@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git",
57+
"pkg:otp/logger@1.10.0?repository_url=https:%2F%2Fgithub.com%2Felixir-lang%2Felixir&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Felixir-lang%2Felixir.git",
58+
"pkg:otp/rebar@3.13.0?repository_url=https:%2F%2Fgithub.com%2Ferlang%2Frebar3&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Ferlang%2Frebar3.git",
59+
"pkg:otp/hex@2.1.1?repository_url=https:%2F%2Fgithub.com%2Fhexpm%2Fhex&vcs_url=git%2Bhttps:%2F%2Fgithub.com%2Fhexpm%2Fhex.git"
60+
]
61+
}

0 commit comments

Comments
 (0)