Debian Codegraph @

bin/purl-tool

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use utf8;
6
7 use URI::PackageURL::App;
8
9 exit URI::PackageURL::App->run(@ARGV) unless caller();
10
11 1;
12
13 __END__
14 =encoding utf-8
15
16 =head1 NAME
17
18 purl-tool - Package URL tool
19
20 =head1 SYNOPSIS
21
22 purl-tool [OPTIONS]...STRING
23 purl-tool --type STRING [--namespace STRING] --name STRING [--version STRING] [--subpath STRING] [--qualifier KEY=VALUE [...]]
24
25 purl-tool [--help|--man|-v]
26
27 Options:
28 --info TYPE Display information about provided PURL type
29 --list Display known PURL type
30 --help Brief help message
31 --man Full documentation
32 -v Print version
33
34 -q, --quiet Suppress output
35
36 "purl" string encode options:
37
38 --type=STRING Type
39 --namespace=STRING Namespace (optional)
40 --name=STRING Name
41 --version=STRING Version (optional)
42 --qualifier KEY=VALUE Qualifier key-value (optional)
43
44 "purl" string decode options:
45
46 --download-url Download URL
47 --repository-url Repository URL
48
49 -0, --null Return NULL char instead of new line
50
51 --format=FORMAT Output format
52 --dumper Data::Dumper format (--format=dumper)
53 --json JSON output format (--format=json)
54 --yaml YAML output format (--format=yaml)
55 --env ENV output format (--format=env)
56
57 "purl" validation options:
58
59 --validate Validate a PURL string and return the exit code
60
61 Examples:
62
63 Parse the given Package URL string and return JSON and send the STDOUT to jq:
64
65 purl-tool pkg:cpan/GDT/[email protected] --json | jq
66
67 Download the package from the repository using PURL string:
68
69 wget $(purl-tool pkg:cpan/GDT/[email protected] --download-url)
70
71 Create a canonical PURL string
72
73 purl-tool --type cpan \
74 --namespace GDT \
75 --name URI-PackageURL \
76 --version 2.24
77
78 Validate a PURL string:
79
80 if $(purl-tool $PURL_STRING --validate -q); then
81 echo "PURL string is valid"
82 else
83 echo "PURL string is not valid"
84 fi
85
86 Display information about provided PURL type (allowed components, repository,
87 examples, etc.):
88
89 purl-tool --info rpm
90
91 Display all known PURL types:
92
93 purl-tool --list
94
95
96 =head1 DESCRIPTION
97
98 C<purl-tool> Package URL tool
99
100 A Package URL (aka "purl") is a URL string used to identify and locate a software
101 package in a mostly universal and uniform way across programing languages,
102 package managers, packaging conventions, tools, APIs and databases.
103
104 L<https://github.com/package-url/purl-spec>
105
106 A purl is a URL composed of seven components:
107
108 scheme:type/namespace/name@version?qualifiers#subpath
109
110 Components are separated by a specific character for unambiguous parsing.
111
112 The definition for each components is:
113
114 =over
115
116 =item * "scheme": this is the URL scheme with the constant value of "pkg".
117 One of the primary reason for this single scheme is to facilitate the future
118 official registration of the "pkg" scheme for package URLs. Required.
119
120 =item * "type": the package "type" or package "protocol" such as cpan, maven, npm,
121 nuget, gem, pypi, etc. Required.
122
123 =item * "namespace": some name prefix such as a Maven groupid, a Docker image
124 owner, a GitHub user or organization. Optional and type-specific.
125
126 =item * "name": the name of the package. Required.
127
128 =item * "version": the version of the package. Optional.
129
130 =item * "qualifiers": extra qualifying data for a package such as an OS,
131 architecture, a distro, etc. Optional and type-specific.
132
133 =item * "subpath": extra subpath within a package, relative to the package root.
134 Optional.
135
136 =back
137
138 =head1 EXAMPLES
139
140 Parse the given PURL string and return JSON and send the STDOUT to L<jq>:
141
142 purl-tool pkg:cpan/GDT/[email protected] --json | jq
143
144 Download the package from the repository using Package URL string:
145
146 wget $(purl-tool pkg:cpan/GDT/[email protected] --download-url)
147
148 Create a canonical Package URL string:
149
150 purl-tool --type cpan \
151 --namespace GDT \
152 --name URI-PackageURL \
153 --version 2.24
154
155 Display information about provided PURL type (allowed components, repository,
156 examples, etc.):
157
158 purl-tool --info rpm
159
160 =head1 AUTHOR
161
162 L<Giuseppe Di Terlizzi|https://metacpan.org/author/gdt>
163
164 =head1 COPYRIGHT AND LICENSE
165
166 Copyright © 2022-2025 L<Giuseppe Di Terlizzi|https://metacpan.org/author/gdt>
167
168 You may use and distribute this module according to the same terms
169 that Perl is distributed under.