| 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> | ||||||||||||||
| 4 | # | ||||||||||||||
| 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. | ||||||||||||||
| 9 | # | ||||||||||||||
| 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. | ||||||||||||||
| 14 | # | ||||||||||||||
| 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/>. | ||||||||||||||
| 17 | |||||||||||||||
| 18 | =encoding utf8 | ||||||||||||||
| 19 | |||||||||||||||
| 20 | =head1 NAME | ||||||||||||||
| 21 | |||||||||||||||
| 22 | Dpkg::Package - package properties handling | ||||||||||||||
| 23 | |||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||
| 25 | |||||||||||||||
| 26 | This module provides functions to parse and validate package properties. | ||||||||||||||
| 27 | |||||||||||||||
| 28 | B<Note>: This is a private module, its API can change at any time. | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =cut | ||||||||||||||
| 31 | |||||||||||||||
| 32 | package Dpkg::Package 0.01; | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 1 | ▶ | use v5.36; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 35 | |||||||||||||||
| 36 | 1 | our @EXPORT = qw( | |||||||||||||
| 37 | pkg_name_is_invalid | ||||||||||||||
| 38 | |||||||||||||||
| 39 | get_source_name | ||||||||||||||
| 40 | set_source_name | ||||||||||||||
| 41 | ); | ||||||||||||||
| 42 | |||||||||||||||
| 43 | 1 | ▶ | use Exporter qw(import); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 44 | |||||||||||||||
| 45 | 1 | ▶ | use Dpkg::ErrorHandling; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 46 | 1 | ▶ | use Dpkg::Gettext; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 47 | |||||||||||||||
| 48 | 10 | ▶ | sub pkg_name_is_invalid { | ||||||||||||
|
Subroutine
pkg_name_is_invalid: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||
| 49 | 10 | ▶ | my $name = shift // ''; | ||||||||||||
|
Condition100%2/2
shift() // ""
MC/DC100%1/1
shift() // ""
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||
| 50 | |||||||||||||||
| 51 | 10 | ▶ | if ($name eq '') { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 52 | 2 | return g_('may not be empty string'); | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | 8 | ▶ | if ($name =~ m/[^-+.0-9a-z]/op) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 55 | 3 | return sprintf(g_("character '%s' not allowed"), ${^MATCH}); | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | 5 | ▶ | if ($name !~ m/^[0-9a-z]/o) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 58 | 1 | return g_('must start with an alphanumeric character'); | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | |||||||||||||||
| 61 | 4 | return; | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | # XXX: Eventually the following functions should be moved as methods for | ||||||||||||||
| 65 | # Dpkg::Source::Package. | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 1 | my $source_name; | |||||||||||||
| 68 | |||||||||||||||
| 69 | 3 | ▶ | sub get_source_name { | ||||||||||||
|
Subroutine
get_source_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 70 | 3 | return $source_name; | |||||||||||||
| 71 | } | ||||||||||||||
| 72 | |||||||||||||||
| 73 | 4 | ▶ | sub set_source_name { | ||||||||||||
|
Subroutine
set_source_name: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||
| 74 | 4 | my $name = shift; | |||||||||||||
| 75 | |||||||||||||||
| 76 | 4 | my $err = pkg_name_is_invalid($name); | |||||||||||||
| 77 | 4 | ▶ | error(g_("source package name '%s' is invalid %s"), $name, $err) if $err; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 78 | |||||||||||||||
| 79 | 3 | ▶ | if (not defined $source_name) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 80 | 1 | $source_name = $name; | |||||||||||||
| 81 | } elsif ($name ne $source_name) { | ||||||||||||||
| 82 | 1 | error(g_('source package has two conflicting values - %s and %s'), | |||||||||||||
| 83 | $source_name, $name); | ||||||||||||||
| 84 | } | ||||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | =head1 CHANGES | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =head2 Version 0.xx | ||||||||||||||
| 90 | |||||||||||||||
| 91 | This is a private module. | ||||||||||||||
| 92 | |||||||||||||||
| 93 | =cut | ||||||||||||||
| 94 | |||||||||||||||
| 95 | 1 | 1; | |||||||||||||