1 # Copyright © 2006 Frank Lichtenheld <djpig@debian.org>
2 # Copyright © 2007-2009, 2012-2013 Guillem Jover <guillem@debian.org>
3 # Copyright © 2007 Raphaël Hertzog <hertzog@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
22 Dpkg::Package - package properties handling
26 This module provides functions to parse and validate package properties.
28 B<Note>: This is a private module, its API can change at any time.
32 package Dpkg
::Package
0.01;
44 use Exporter
qw(import);
46 use Dpkg
::ErrorHandling
;
49 sub pkg_name_is_illegal
($) {
50 my $name = shift // '';
53 return g_
('may not be empty string');
55 if ($name =~ m/[^-+.0-9a-z]/op) {
56 return sprintf(g_
("character '%s' not allowed"), ${^MATCH
});
58 if ($name !~ m/^[0-9a-z]/o) {
59 return g_
('must start with an alphanumeric character');
65 # XXX: Eventually the following functions should be moved as methods for
66 # Dpkg::Source::Package.
77 my $err = pkg_name_is_illegal
($name);
78 error
(g_
("source package name '%s' is illegal: %s"), $name, $err) if $err;
80 if (not defined $source_name) {
82 } elsif ($name ne $source_name) {
83 error
(g_
('source package has two conflicting values - %s and %s'),
92 This is a private module.