File: README.md

package info (click to toggle)
liburi-packageurl-perl 2.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,740 kB
  • sloc: perl: 3,555; sh: 72; makefile: 2
file content (211 lines) | stat: -rw-r--r-- 5,018 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
[![Release](https://img.shields.io/github/release/giterlizzi/perl-URI-PackageURL.svg)](https://github.com/giterlizzi/perl-URI-PackageURL/releases) [![Actions Status](https://github.com/giterlizzi/perl-URI-PackageURL/workflows/linux/badge.svg)](https://github.com/giterlizzi/perl-URI-PackageURL/actions) [![License](https://img.shields.io/github/license/giterlizzi/perl-URI-PackageURL.svg)](https://github.com/giterlizzi/perl-URI-PackageURL) [![Starts](https://img.shields.io/github/stars/giterlizzi/perl-URI-PackageURL.svg)](https://github.com/giterlizzi/perl-URI-PackageURL) [![Forks](https://img.shields.io/github/forks/giterlizzi/perl-URI-PackageURL.svg)](https://github.com/giterlizzi/perl-URI-PackageURL) [![Issues](https://img.shields.io/github/issues/giterlizzi/perl-URI-PackageURL.svg)](https://github.com/giterlizzi/perl-URI-PackageURL/issues) [![Coverage Status](https://coveralls.io/repos/github/giterlizzi/perl-URI-PackageURL/badge.svg)](https://coveralls.io/github/giterlizzi/perl-URI-PackageURL)

# URI::PackageURL - Perl extension for PURL (Package URL) and VERS (Version Range)

## Synopsis

```perl
use URI::PackageURL;

# OO-interface

# Encode components in PURL string
$purl = URI::PackageURL->new(
  type      => 'cpan',
  namespace => 'GDT',
  name      => 'URI-PackageURL',
  version   => '2.25'
);

say $purl; # pkg:cpan/GDT/URI-PackageURL@2.25

# Parse a PURL string
$purl = URI::PackageURL->from_string('pkg:cpan/GDT/URI-PackageURL@2.25');


# use setter methods

my $purl = URI::PackageURL->new(type => 'cpan', namespace => 'GDT', name => 'URI-PackageURL');

say $purl; # pkg:cpan/GDT/URI-PackageURL
say $purl->version; # undef

$purl->version('2.25');
say $purl; # pkg:cpan/GDT/URI-PackageURL@2.25
say $purl->version; # 2.25


# exported functions

$purl = decode_purl('pkg:cpan/GDT/URI-PackageURL@2.25');
say $purl->type;  # cpan

$purl_string = encode_purl(type => cpan, namespace => 'GDT', name => 'URI-PackageURL', version => '2.25');
say $purl_string; # pkg:cpan/GDT/URI-PackageURL@2.25


# uses the legacy CPAN PURL type, to be used only for compatibility (will be removed in the future)

$ENV{PURL_LEGACY_CPAN_TYPE} = 1;
URI::PackageURL->new(type => 'cpan', name => 'URI::PackageURL');


# alias

$purl = PURL->new(
  type      => 'cpan',
  namespace => 'GDT',
  name      => 'URI-PackageURL',
  version   => '2.25'
);

$purl = PURL->from_string('pkg:cpan/GDT/URI-PackageURL');


# clone

$cloned = $purl->clone;

$cloned->version('1.00');

say $cloned; # pkg:cpan/GDT/URI-PackageURL@1.00
say $purl;   # pkg:cpan/GDT/URI-PackageURL@2.25
```


## purl-tool a CLI for URI::PackageURL module

Inspect and export "purl" string in various formats (JSON, YAML, Data::Dumper, ENV):

```console
$ purl-tool pkg:cpan/GDT/URI-PackageURL@2.25 --json | jq
{
  "name": "URI-PackageURL",
  "namespace": "GDT",
  "qualifiers": {},
  "subpath": null,
  "type": "cpan",
  "version": "2.25"
}
```


Download package using "purl" string:

```console
$ wget $(purl-tool pkg:cpan/GDT/URI-PackageURL@2.25 --download-url)
```


Use "purl" string in your shell-scripts:

```bash
#!bash

set -e 

PURL="pkg:cpan/GDT/URI-PackageURL@2.25"

eval $(purl-tool "$PURL" --env)

echo "Download $PURL_NAME $PURL_VERSION"
wget $PURL_DOWNLOAD_URL

echo "Build and install module $PURL_NAME $PURL_VERSION"
tar xvf $PURL_NAME-$PURL_VERSION.tar.gz

cd $PURL_NAME-$PURL_VERSION
perl Makefile.PL
make && make install
```


Create on-the-fly a "purl" string:

```console
$ purl-tool --type cpan \
            --namespace GDT \
            --name URI-PackageURL \
            --version 2.25
```


Validate a PURL string:

```bash
if $(purl-tool $PURL_STRING --validate -q); then
    echo "PURL string is valid"
else
    echo "PURL string is not valid"
fi
```


Display information about provided PURL type (allowed components, repository,
examples, etc.):

```console
$ purl-tool --info rpm
```

Display all known PURL types:

```console
$ purl-tool --list
```


## vers-tool a CLI for URI::VersionRange module

Decode a "vers" string:

```console
$ vers-tool "vers:cpan/1.00|>=2.00|<5.00" | jq
```

Check if a version is contained within a range:

```console
$ vers-tool "vers:cpan/1.00|>=2.00|<5.00" --contains "2.20"
```

Humanize "vers":

```console
$ vers-tool "vers:cpan/1.00|>=2.00|<5.00" --human-readable

cpan
- equal 1.00
- greater than or equal 2.00
- less than 5.00
```

## Install

Using Makefile.PL:

To install `URI::PackageURL` distribution, run the following commands.

    perl Makefile.PL
    make
    make test
    make install

Using App::cpanminus:

    cpanm URI::PackageURL


## Documentation

- `perldoc URI::PackageURL`
- `perldoc URI::VersionRange`
- https://metacpan.org/release/URI-PackageURL
- Specification: https://github.com/package-url/purl-spec
- TC54 - Software and system transparency: https://tc54.org
- ECMA-427 - Package-URL (PURL) specification: https://ecma-international.org/publications-and-standards/standards/ecma-427


## Copyright

- Copyright 2022-2026 © Giuseppe Di Terlizzi