Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SWHID as a Package-URL type? #7

Open
zvr opened this issue Nov 15, 2022 · 2 comments
Open

SWHID as a Package-URL type? #7

zvr opened this issue Nov 15, 2022 · 2 comments
Labels
outreach Related to adoption of SWHID

Comments

@zvr
Copy link
Contributor

zvr commented Nov 15, 2022

Do want to work towards defining an encoding of SWHID as a package-url ?

The specification is at https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst

One can see how different other types are handled in https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst

I assume the majority of work would be to see what encoding/decoding has to be specified in the representation.

@zvr
Copy link
Contributor Author

zvr commented Nov 15, 2022

OK, this might not be so hard, after all.

Carefully reading the spec, we have to follow the structure scheme:type/namespace/name@version?qualifiers#subpath.

Simple SWHIDs are pretty easily mappable:

swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2

pkg:swh-1/cnt/94a9ed024d3859793618152ea559a168bbcbb5e2

Identifiers with qualifiers have to be transformed like URL query strings, so:

swh:1:cnt:4d99d2d18326621ccdd70f5ea66c2e2ac236ad8b;
  origin=https://gitorious.org/ocamlp3l/ocamlp3l_cvs.git;
  visit=swh:1:snp:d7f1b9eb7ccb596c2622c4780febaa02549830f9;
  anchor=swh:1:rev:2db189928c94d62a3b4757b3eec68f0a4d4113f0;
  path=/Examples/SimpleFarm/simplefarm.ml;
  lines=9-15

pkg:swh-1/cnt/4d99d2d18326621ccdd70f5ea66c2e2ac236ad8b?
  origin=https%3A%2F%2Fgitorious.org%2Focamlp3l%2Focamlp3l_cvs.git&
  visit=swh%3A1%3Asnp%3Ad7f1b9eb7ccb596c2622c4780febaa02549830f9&
  anchor=swh%3A1%3Arev%3A2db189928c94d62a3b4757b3eec68f0a4d4113f0&
  path=%2FExamples%2FSimpleFarm%2Fsimplefarm.ml&
  lines=9-15

I created and used type of swh-1 since it's not easy to encode the version otherwise. Not ideal (or pretty), but it makes the job done.

@rdicosmo
Copy link
Contributor

Thanks for raising this!
Looking at the intent of purls, which is to identify "packages" I get the impression that we should probably only translate directory, release or revision SWHIDs.

On a side note, it would be great if we could have SWHIDs used in other package managers, instead of naked hashes as we see in the purl examples, but that's for another day I suppose :-)

@rdicosmo rdicosmo added the outreach Related to adoption of SWHID label Mar 18, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
outreach Related to adoption of SWHID
Projects
None yet
Development

No branches or pull requests

2 participants