This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=e2ea6529c426ed18ae3ecc67785f2665e762f4b1 commit e2ea6529c426ed18ae3ecc67785f2665e762f4b1 (HEAD -> main) Author: Guillem Jover <guil...@debian.org> AuthorDate: Tue Dec 12 23:58:49 2023 +0100 Dpkg::Control::Types: Add aliases for type enumerations Refer to the debian/control file as the template file (CTRL_TMPL_ prefix). Refer to .dsc and .deb as CTRL_DSC and CTRL_DEB, as using the CTRL_PKG_ prefix is very confusing given that we use _PKG to denote binary package types. Refer to the Packages and Sources repository indices using the CTRL_REPO_ prefix, as the CTRL_INFO_ prefix is rather confusing. --- scripts/Dpkg/Control.pm | 82 ++++++++++++++++++++++++---------- scripts/Dpkg/Control/FieldsCore.pm | 90 +++++++++++++++++++------------------- scripts/Dpkg/Control/Info.pm | 4 +- scripts/Dpkg/Control/Types.pm | 41 ++++++++++++----- scripts/Dpkg/Index.pm | 16 +++---- scripts/Dpkg/Source/Package.pm | 2 +- scripts/dpkg-genchanges.pl | 2 +- scripts/dpkg-gencontrol.pl | 2 +- scripts/dpkg-name.pl | 2 +- scripts/dpkg-scanpackages.pl | 2 +- scripts/dpkg-scansources.pl | 4 +- scripts/t/Dpkg_BuildAPI.t | 2 +- scripts/t/Dpkg_Control.t | 2 +- scripts/t/Dpkg_Control_Fields.t | 14 +++--- 14 files changed, 159 insertions(+), 106 deletions(-) diff --git a/scripts/Dpkg/Control.pm b/scripts/Dpkg/Control.pm index 6305d4bf6..29dd577af 100644 --- a/scripts/Dpkg/Control.pm +++ b/scripts/Dpkg/Control.pm @@ -36,12 +36,12 @@ list: This type is the default type, it indicates that the type of control information is not yet known. -=item CTRL_INFO_SRC +=item CTRL_TMPL_SRC Corresponds to the first source package stanza in a F<debian/control> file in a Debian source package. -=item CTRL_INFO_PKG +=item CTRL_TMPL_PKG Corresponds to subsequent binary package stanza in a F<debian/control> file in a Debian source package. @@ -50,21 +50,21 @@ in a Debian source package. Corresponds to a F<Release> file in a repository. -=item CTRL_INDEX_SRC +=item CTRL_REPO_SRC Corresponds to a stanza in a F<Sources> file of a source package repository. -=item CTRL_INDEX_PKG +=item CTRL_REPO_PKG Corresponds to a stanza in a F<Packages> file of a binary package repository. -=item CTRL_PKG_SRC +=item CTRL_DSC Corresponds to a .dsc file of a Debian source package. -=item CTRL_PKG_DEB +=item CTRL_DEB Corresponds to the F<control> file generated by dpkg-gencontrol (F<DEBIAN/control>) and to the same file inside .deb packages. @@ -108,24 +108,48 @@ machine readable format. Corresponds to a source package tests control file in F<debian/tests/control>. +=item CTRL_INFO_SRC + +Alias for B<CTRL_TMPL_SRC>. + +=item CTRL_INFO_PKG + +Alias for B<CTRL_TMPL_PKG>. + +=item CTRL_PKG_SRC + +Alias for B<CTRL_DSC>. + +=item CTRL_PKG_DEB + +Alias for B<CTRL_DEB>. + +=item CTRL_INDEX_SRC + +Alias for B<CTRL_REPO_SRC>. + +=item CTRL_INDEX_PKG + +Alias for B<CTRL_REPO_PKG>. + =back =cut -package Dpkg::Control 1.03; +package Dpkg::Control 1.04; use strict; use warnings; our @EXPORT = qw( CTRL_UNKNOWN - CTRL_INFO_SRC - CTRL_INFO_PKG - CTRL_INDEX_SRC - CTRL_INDEX_PKG + CTRL_TMPL_SRC + CTRL_TMPL_PKG CTRL_REPO_RELEASE - CTRL_PKG_SRC - CTRL_PKG_DEB + CTRL_REPO_SRC + CTRL_REPO_PKG + CTRL_DSC + CTRL_DEB CTRL_FILE_BUILDINFO CTRL_FILE_CHANGES CTRL_FILE_VENDOR @@ -135,6 +159,13 @@ our @EXPORT = qw( CTRL_COPYRIGHT_FILES CTRL_COPYRIGHT_LICENSE CTRL_TESTS + + CTRL_INFO_SRC + CTRL_INFO_PKG + CTRL_PKG_SRC + CTRL_PKG_DEB + CTRL_INDEX_SRC + CTRL_INDEX_PKG ); use Exporter qw(import); @@ -176,9 +207,9 @@ sub new { Changes the value of one or more options. If the "type" option is changed, it is used first to define default values for others options. The option -"allow_pgp" is set to 1 for CTRL_PKG_SRC, CTRL_FILE_CHANGES and +"allow_pgp" is set to 1 for CTRL_DSC, CTRL_FILE_CHANGES and CTRL_REPO_RELEASE and to 0 otherwise. The option "drop_empty" is set to 0 -for CTRL_INFO_PKG and CTRL_INFO_SRC and to 1 otherwise. The option "name" +for CTRL_TMPL_SRC and CTRL_TMPL_PKG and to 1 otherwise. The option "name" is set to a textual description of the type of control information. The output order is also set to match the ordered list returned by @@ -190,11 +221,11 @@ sub set_options { my ($self, %opts) = @_; if (exists $opts{type}) { my $t = $opts{type}; - $$self->{allow_pgp} = ($t & (CTRL_PKG_SRC | CTRL_FILE_CHANGES | CTRL_REPO_RELEASE)) ? 1 : 0; - $$self->{drop_empty} = ($t & (CTRL_INFO_PKG | CTRL_INFO_SRC)) ? 0 : 1; - if ($t == CTRL_INFO_SRC) { + $$self->{allow_pgp} = ($t & (CTRL_DSC | CTRL_FILE_CHANGES | CTRL_REPO_RELEASE)) ? 1 : 0; + $$self->{drop_empty} = ($t & (CTRL_TMPL_SRC | CTRL_TMPL_PKG)) ? 0 : 1; + if ($t == CTRL_TMPL_SRC) { $$self->{name} = g_('source package stanza of template control file'); - } elsif ($t == CTRL_INFO_PKG) { + } elsif ($t == CTRL_TMPL_PKG) { $$self->{name} = g_('binary package stanza of template control file'); } elsif ($t == CTRL_CHANGELOG) { $$self->{name} = g_('parsed version of changelog'); @@ -208,13 +239,13 @@ sub set_options { $$self->{name} = g_('source package tests control file'); } elsif ($t == CTRL_REPO_RELEASE) { $$self->{name} = sprintf(g_("repository's %s file"), 'Release'); - } elsif ($t == CTRL_INDEX_SRC) { + } elsif ($t == CTRL_REPO_SRC) { $$self->{name} = sprintf(g_("stanza in repository's %s file"), 'Sources'); - } elsif ($t == CTRL_INDEX_PKG) { + } elsif ($t == CTRL_REPO_PKG) { $$self->{name} = sprintf(g_("stanza in repository's %s file"), 'Packages'); - } elsif ($t == CTRL_PKG_SRC) { + } elsif ($t == CTRL_DSC) { $$self->{name} = g_('source package control file'); - } elsif ($t == CTRL_PKG_DEB) { + } elsif ($t == CTRL_DEB) { $$self->{name} = g_('binary package control file'); } elsif ($t == CTRL_FILE_BUILDINFO) { $$self->{name} = g_('build information file'); @@ -248,6 +279,11 @@ sub get_type { =head1 CHANGES +=head2 Version 1.04 (dpkg 1.22.2) + +New types: CTRL_TMPL_SRC, CTRL_TMPL_PKG, CTRL_REPO_SRC, CTRL_REPO_PKG, +CTRL_DSC, CTRL_DEB. + =head2 Version 1.03 (dpkg 1.18.11) New type: CTRL_FILE_BUILDINFO. diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm index 5b1756f1b..0c024ab6e 100644 --- a/scripts/Dpkg/Control/FieldsCore.pm +++ b/scripts/Dpkg/Control/FieldsCore.pm @@ -60,8 +60,8 @@ use Dpkg::ErrorHandling; use Dpkg::Control::Types; use constant { - ALL_PKG => CTRL_INFO_PKG | CTRL_INDEX_PKG | CTRL_PKG_DEB | CTRL_FILE_STATUS, - ALL_SRC => CTRL_INFO_SRC | CTRL_INDEX_SRC | CTRL_PKG_SRC, + ALL_PKG => CTRL_TMPL_PKG | CTRL_REPO_PKG | CTRL_DEB | CTRL_FILE_STATUS, + ALL_SRC => CTRL_TMPL_SRC | CTRL_REPO_SRC | CTRL_DSC, ALL_FILE_MANIFEST => CTRL_FILE_BUILDINFO | CTRL_FILE_CHANGES, ALL_CHANGES => CTRL_FILE_CHANGES | CTRL_CHANGELOG, ALL_COPYRIGHT => CTRL_COPYRIGHT_HEADER | CTRL_COPYRIGHT_FILES | CTRL_COPYRIGHT_LICENSE, @@ -85,7 +85,7 @@ our %FIELDS = ( }, 'architecture' => { name => 'Architecture', - allowed => (ALL_PKG | ALL_SRC | ALL_FILE_MANIFEST | CTRL_TESTS) & (~CTRL_INFO_SRC), + allowed => (ALL_PKG | ALL_SRC | ALL_FILE_MANIFEST | CTRL_TESTS) & (~CTRL_TMPL_SRC), separator => FIELD_SEP_SPACE, }, 'architectures' => { @@ -95,12 +95,12 @@ our %FIELDS = ( }, 'auto-built-package' => { name => 'Auto-Built-Package', - allowed => ALL_PKG & ~CTRL_INFO_PKG, + allowed => ALL_PKG & ~CTRL_TMPL_PKG, separator => FIELD_SEP_SPACE, }, 'binary' => { name => 'Binary', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | ALL_FILE_MANIFEST, + allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST, # XXX: This field values are separated either by space or comma # depending on the context. separator => FIELD_SEP_SPACE | FIELD_SEP_COMMA, @@ -122,7 +122,7 @@ our %FIELDS = ( }, 'bugs' => { name => 'Bugs', - allowed => (ALL_PKG | CTRL_INFO_SRC | CTRL_FILE_VENDOR) & (~CTRL_INFO_PKG), + allowed => (ALL_PKG | CTRL_TMPL_SRC | CTRL_FILE_VENDOR) & (~CTRL_TMPL_PKG), }, 'build-architecture' => { name => 'Build-Architecture', @@ -192,7 +192,7 @@ our %FIELDS = ( }, 'build-profiles' => { name => 'Build-Profiles', - allowed => CTRL_INFO_PKG, + allowed => CTRL_TMPL_PKG, separator => FIELD_SEP_SPACE, }, 'build-tainted-by' => { @@ -230,15 +230,15 @@ our %FIELDS = ( }, 'checksums-md5' => { name => 'Checksums-Md5', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | ALL_FILE_MANIFEST, + allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST, }, 'checksums-sha1' => { name => 'Checksums-Sha1', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | ALL_FILE_MANIFEST, + allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST, }, 'checksums-sha256' => { name => 'Checksums-Sha256', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | ALL_FILE_MANIFEST, + allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST, }, 'classes' => { name => 'Classes', @@ -304,7 +304,7 @@ our %FIELDS = ( }, 'directory' => { name => 'Directory', - allowed => CTRL_INDEX_SRC, + allowed => CTRL_REPO_SRC, }, 'distribution' => { name => 'Distribution', @@ -333,17 +333,17 @@ our %FIELDS = ( }, 'filename' => { name => 'Filename', - allowed => CTRL_INDEX_PKG, + allowed => CTRL_REPO_PKG, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'files' => { name => 'Files', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | CTRL_FILE_CHANGES | CTRL_COPYRIGHT_FILES, + allowed => CTRL_DSC | CTRL_REPO_SRC | CTRL_FILE_CHANGES | CTRL_COPYRIGHT_FILES, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'format' => { name => 'Format', - allowed => CTRL_PKG_SRC | CTRL_INDEX_SRC | ALL_FILE_MANIFEST | CTRL_COPYRIGHT_HEADER, + allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST | CTRL_COPYRIGHT_HEADER, }, 'homepage' => { name => 'Homepage', @@ -358,7 +358,7 @@ our %FIELDS = ( }, 'installed-size' => { name => 'Installed-Size', - allowed => ALL_PKG & ~CTRL_INFO_PKG, + allowed => ALL_PKG & ~CTRL_TMPL_PKG, }, 'installer-menu-item' => { name => 'Installer-Menu-Item', @@ -378,16 +378,16 @@ our %FIELDS = ( }, 'origin' => { name => 'Origin', - allowed => (ALL_PKG | ALL_SRC | CTRL_REPO_RELEASE) & (~CTRL_INFO_PKG), + allowed => (ALL_PKG | ALL_SRC | CTRL_REPO_RELEASE) & (~CTRL_TMPL_PKG), }, 'maintainer' => { name => 'Maintainer', - allowed => CTRL_PKG_DEB | CTRL_INDEX_PKG | CTRL_FILE_STATUS | ALL_SRC | ALL_CHANGES, + allowed => CTRL_DEB | CTRL_REPO_PKG | CTRL_FILE_STATUS | ALL_SRC | ALL_CHANGES, }, 'md5sum' => { # XXX: Wrong capitalization due to historical reasons. name => 'MD5sum', - allowed => CTRL_INDEX_PKG | CTRL_REPO_RELEASE, + allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'multi-arch' => { @@ -404,11 +404,11 @@ our %FIELDS = ( }, 'package' => { name => 'Package', - allowed => ALL_PKG | CTRL_INDEX_SRC, + allowed => ALL_PKG | CTRL_REPO_SRC, }, 'package-list' => { name => 'Package-List', - allowed => ALL_SRC & ~CTRL_INFO_SRC, + allowed => ALL_SRC & ~CTRL_TMPL_SRC, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'package-type' => { @@ -428,7 +428,7 @@ our %FIELDS = ( }, 'priority' => { name => 'Priority', - allowed => CTRL_INFO_SRC | CTRL_INDEX_SRC | ALL_PKG, + allowed => CTRL_TMPL_SRC | CTRL_REPO_SRC | ALL_PKG, }, 'protected' => { name => 'Protected', @@ -462,34 +462,34 @@ our %FIELDS = ( }, 'rules-requires-root' => { name => 'Rules-Requires-Root', - allowed => CTRL_INFO_SRC, + allowed => CTRL_TMPL_SRC, separator => FIELD_SEP_SPACE, }, 'section' => { name => 'Section', - allowed => CTRL_INFO_SRC | CTRL_INDEX_SRC | ALL_PKG, + allowed => CTRL_TMPL_SRC | CTRL_REPO_SRC | ALL_PKG, }, 'sha1' => { # XXX: Wrong capitalization due to historical reasons. name => 'SHA1', - allowed => CTRL_INDEX_PKG | CTRL_REPO_RELEASE, + allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'sha256' => { # XXX: Wrong capitalization due to historical reasons. name => 'SHA256', - allowed => CTRL_INDEX_PKG | CTRL_REPO_RELEASE, + allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'size' => { name => 'Size', - allowed => CTRL_INDEX_PKG, + allowed => CTRL_REPO_PKG, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, }, 'source' => { name => 'Source', allowed => (ALL_PKG | ALL_SRC | ALL_CHANGES | CTRL_COPYRIGHT_HEADER | CTRL_FILE_BUILDINFO) & - (~(CTRL_INDEX_SRC | CTRL_INFO_PKG)), + (~(CTRL_REPO_SRC | CTRL_TMPL_PKG)), }, 'standards-version' => { name => 'Standards-Version', @@ -636,7 +636,7 @@ our %FIELDS = ( 'version' => { name => 'Version', allowed => (ALL_PKG | ALL_SRC | CTRL_FILE_BUILDINFO | ALL_CHANGES | CTRL_REPO_RELEASE) & - (~(CTRL_INFO_SRC | CTRL_INFO_PKG)), + (~(CTRL_TMPL_SRC | CTRL_TMPL_PKG)), }, ); @@ -691,7 +691,7 @@ my @bin_checksums_fields = qw( ); our %FIELD_ORDER = ( - CTRL_INFO_SRC() => [ + CTRL_TMPL_SRC() => [ qw( source section @@ -713,7 +713,7 @@ our %FIELD_ORDER = ( description ), ], - CTRL_INFO_PKG() => [ + CTRL_TMPL_PKG() => [ qw( package package-type @@ -738,7 +738,7 @@ our %FIELD_ORDER = ( description ), ], - CTRL_PKG_SRC() => [ + CTRL_DSC() => [ qw( format source @@ -763,7 +763,7 @@ our %FIELD_ORDER = ( files ), ], - CTRL_PKG_DEB() => [ + CTRL_DEB() => [ qw( package package-type @@ -794,7 +794,7 @@ our %FIELD_ORDER = ( task ), ], - CTRL_INDEX_SRC() => [ + CTRL_REPO_SRC() => [ qw( format package @@ -822,7 +822,7 @@ our %FIELD_ORDER = ( files ), ], - CTRL_INDEX_PKG() => [ + CTRL_REPO_PKG() => [ qw( package package-type @@ -1099,12 +1099,12 @@ $from L<Dpkg::Control> object to the $to L<Dpkg::Control> object. Official fields are copied only if the field is allowed in both types of objects. Custom fields are treated in a specific manner. When the target -is not among CTRL_PKG_SRC, CTRL_PKG_DEB or CTRL_FILE_CHANGES, then they +is not among CTRL_DSC, CTRL_DEB or CTRL_FILE_CHANGES, then they are always copied as is (the X- prefix is kept). Otherwise they are not copied except if the target object matches the target destination encoded in the field name. The initial X denoting custom fields can be followed by -one or more letters among "S" (Source: corresponds to CTRL_PKG_SRC), "B" -(Binary: corresponds to CTRL_PKG_DEB) or "C" (Changes: corresponds to +one or more letters among "S" (Source: corresponds to CTRL_DSC), "B" +(Binary: corresponds to CTRL_DEB) or "C" (Changes: corresponds to CTRL_FILE_CHANGES). Returns undef if nothing has been copied or the name of the new field @@ -1128,16 +1128,16 @@ sub field_transfer_single($$;$) { return $field; } elsif ($field =~ /^X([SBC]*)-/i) { my $dest = $1; - if (($dest =~ /B/i and $to_type == CTRL_PKG_DEB) or - ($dest =~ /S/i and $to_type == CTRL_PKG_SRC) or + if (($dest =~ /B/i and $to_type == CTRL_DEB) or + ($dest =~ /S/i and $to_type == CTRL_DSC) or ($dest =~ /C/i and $to_type == CTRL_FILE_CHANGES)) { my $new = $field; $new =~ s/^X([SBC]*)-//i; $to->{$new} = $from->{$field}; return $new; - } elsif ($to_type != CTRL_PKG_DEB and - $to_type != CTRL_PKG_SRC and + } elsif ($to_type != CTRL_DEB and + $to_type != CTRL_DSC and $to_type != CTRL_FILE_CHANGES) { $to->{$field} = $from->{$field}; @@ -1204,8 +1204,8 @@ sub field_parse_binary_source($) { my $ctrl = shift; my $ctrl_type = $ctrl->get_type(); - if ($ctrl_type != CTRL_INDEX_PKG and - $ctrl_type != CTRL_PKG_DEB and + if ($ctrl_type != CTRL_REPO_PKG and + $ctrl_type != CTRL_DEB and $ctrl_type != CTRL_FILE_CHANGES and $ctrl_type != CTRL_FILE_BUILDINFO and $ctrl_type != CTRL_FILE_STATUS) { @@ -1245,7 +1245,7 @@ sub field_list_src_dep() { } sort { $FIELDS{$a}{dep_order} <=> $FIELDS{$b}{dep_order} } grep { - field_is_allowed_in($_, CTRL_PKG_SRC) and + field_is_allowed_in($_, CTRL_DSC) and exists $FIELDS{$_}{dependency} } keys %FIELDS; return @list; @@ -1265,7 +1265,7 @@ sub field_list_pkg_dep() { } sort { $FIELDS{$a}{dep_order} <=> $FIELDS{$b}{dep_order} } grep { - field_is_allowed_in($_, CTRL_PKG_DEB) and + field_is_allowed_in($_, CTRL_DEB) and exists $FIELDS{$_}{dependency} } keys %FIELDS; return @list; diff --git a/scripts/Dpkg/Control/Info.pm b/scripts/Dpkg/Control/Info.pm index efb78cae2..11eec7386 100644 --- a/scripts/Dpkg/Control/Info.pm +++ b/scripts/Dpkg/Control/Info.pm @@ -102,7 +102,7 @@ The data in the object is reset before parsing new control files. sub parse { my ($self, $fh, $desc) = @_; $self->reset(); - my $cdata = Dpkg::Control->new(type => CTRL_INFO_SRC); + my $cdata = Dpkg::Control->new(type => CTRL_TMPL_SRC); return if not $cdata->parse($fh, $desc); $self->{source} = $cdata; unless (exists $cdata->{Source}) { @@ -110,7 +110,7 @@ sub parse { 'Source'); } while (1) { - $cdata = Dpkg::Control->new(type => CTRL_INFO_PKG); + $cdata = Dpkg::Control->new(type => CTRL_TMPL_PKG); last if not $cdata->parse($fh, $desc); push @{$self->{packages}}, $cdata; unless (exists $cdata->{Package}) { diff --git a/scripts/Dpkg/Control/Types.pm b/scripts/Dpkg/Control/Types.pm index a3139c6fe..4a867350c 100644 --- a/scripts/Dpkg/Control/Types.pm +++ b/scripts/Dpkg/Control/Types.pm @@ -36,13 +36,13 @@ use warnings; our @EXPORT = qw( CTRL_UNKNOWN - CTRL_INFO_SRC - CTRL_INFO_PKG + CTRL_TMPL_SRC + CTRL_TMPL_PKG CTRL_REPO_RELEASE - CTRL_INDEX_SRC - CTRL_INDEX_PKG - CTRL_PKG_SRC - CTRL_PKG_DEB + CTRL_REPO_SRC + CTRL_REPO_PKG + CTRL_DSC + CTRL_DEB CTRL_FILE_BUILDINFO CTRL_FILE_CHANGES CTRL_FILE_VENDOR @@ -52,6 +52,13 @@ our @EXPORT = qw( CTRL_COPYRIGHT_FILES CTRL_COPYRIGHT_LICENSE CTRL_TESTS + + CTRL_INFO_SRC + CTRL_INFO_PKG + CTRL_PKG_SRC + CTRL_PKG_DEB + CTRL_INDEX_SRC + CTRL_INDEX_PKG ); use Exporter qw(import); @@ -59,17 +66,17 @@ use Exporter qw(import); use constant { CTRL_UNKNOWN => 0, # First source package control stanza in debian/control. - CTRL_INFO_SRC => 1 << 0, + CTRL_TMPL_SRC => 1 << 0, # Subsequent binary package control stanza in debian/control. - CTRL_INFO_PKG => 1 << 1, + CTRL_TMPL_PKG => 1 << 1, # Entry in repository's Sources files. - CTRL_INDEX_SRC => 1 << 2, + CTRL_REPO_SRC => 1 << 2, # Entry in repository's Packages files. - CTRL_INDEX_PKG => 1 << 3, + CTRL_REPO_PKG => 1 << 3, # .dsc file of source package. - CTRL_PKG_SRC => 1 << 4, + CTRL_DSC => 1 << 4, # DEBIAN/control in binary packages. - CTRL_PKG_DEB => 1 << 5, + CTRL_DEB => 1 << 5, # .changes file. CTRL_FILE_CHANGES => 1 << 6, # File in $Dpkg::CONFDIR/origins. @@ -92,6 +99,16 @@ use constant { CTRL_FILE_BUILDINFO => 1 << 15, }; +# Backwards compatibility aliases. +use constant { + CTRL_INFO_SRC => CTRL_TMPL_SRC, + CTRL_INFO_PKG => CTRL_TMPL_PKG, + CTRL_PKG_SRC => CTRL_DSC, + CTRL_PKG_DEB => CTRL_DEB, + CTRL_INDEX_SRC => CTRL_REPO_SRC, + CTRL_INDEX_PKG => CTRL_REPO_PKG, +}; + =head1 CHANGES =head2 Version 0.xx diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm index 535b1b318..3f898af12 100644 --- a/scripts/Dpkg/Index.pm +++ b/scripts/Dpkg/Index.pm @@ -87,21 +87,21 @@ The "get_key_func" function used depends on the type: =item * -for CTRL_INFO_SRC, it is the Source field; +for CTRL_TMPL_SRC, it is the Source field; =item * -for CTRL_INDEX_SRC and CTRL_PKG_SRC it is the Package and Version fields +for CTRL_REPO_SRC and CTRL_DSC it is the Package and Version fields (concatenated with "_") when "unique_tuple_key" is true (the default), or otherwise the Package field; =item * -for CTRL_INFO_PKG it is simply the Package field; +for CTRL_TMPL_PKG it is simply the Package field; =item * -for CTRL_INDEX_PKG and CTRL_PKG_DEB it is the Package, Version and +for CTRL_REPO_PKG and CTRL_DEB it is the Package, Version and Architecture fields (concatenated with "_") when "unique_tuple_key" is true (the default) or otherwise the Package field; @@ -143,9 +143,9 @@ sub set_options { # Default values based on type if (exists $opts{type}) { my $t = $opts{type}; - if ($t == CTRL_INFO_PKG) { + if ($t == CTRL_TMPL_PKG) { $self->{get_key_func} = sub { return $_[0]->{Package}; }; - } elsif ($t == CTRL_INFO_SRC) { + } elsif ($t == CTRL_TMPL_SRC) { $self->{get_key_func} = sub { return $_[0]->{Source}; }; } elsif ($t == CTRL_CHANGELOG) { $self->{get_key_func} = sub { @@ -163,7 +163,7 @@ sub set_options { $self->{get_key_func} = sub { return scalar @{$self->{order}}; }; - } elsif ($t == CTRL_INDEX_SRC or $t == CTRL_PKG_SRC) { + } elsif ($t == CTRL_REPO_SRC or $t == CTRL_DSC) { if ($opts{unique_tuple_key} // $self->{unique_tuple_key}) { $self->{get_key_func} = sub { return $_[0]->{Package} . '_' . $_[0]->{Version}; @@ -173,7 +173,7 @@ sub set_options { return $_[0]->{Package}; }; } - } elsif ($t == CTRL_INDEX_PKG or $t == CTRL_PKG_DEB) { + } elsif ($t == CTRL_REPO_PKG or $t == CTRL_DEB) { if ($opts{unique_tuple_key} // $self->{unique_tuple_key}) { $self->{get_key_func} = sub { return $_[0]->{Package} . '_' . $_[0]->{Version} . '_' . diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index bf1294948..3427383ec 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -209,7 +209,7 @@ sub new { my ($this, %args) = @_; my $class = ref($this) || $this; my $self = { - fields => Dpkg::Control->new(type => CTRL_PKG_SRC), + fields => Dpkg::Control->new(type => CTRL_DSC), format => Dpkg::Source::Format->new(), options => {}, checksums => Dpkg::Checksums->new(), diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index d724dea9e..10a8ceb47 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -278,7 +278,7 @@ if (build_has_any(BUILD_SOURCE)) { my $dsc = "${spackage}_${sversion}.dsc"; my $dsc_pathname = "$uploadfilesdir/$dsc"; - my $dsc_fields = Dpkg::Control->new(type => CTRL_PKG_SRC); + my $dsc_fields = Dpkg::Control->new(type => CTRL_DSC); $dsc_fields->load($dsc_pathname) or error(g_('%s is empty'), $dsc_pathname); $checksums->add_from_file($dsc_pathname, key => $dsc); $checksums->add_from_control($dsc_fields, use_files_for_md5 => 1); diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 8c210f9c4..fb69fab5b 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -166,7 +166,7 @@ $substvars->set_vendor_substvars(); $substvars->set_arch_substvars(); $substvars->load('debian/substvars') if -e 'debian/substvars' and not $substvars_loaded; my $control = Dpkg::Control::Info->new($controlfile); -my $fields = Dpkg::Control->new(type => CTRL_PKG_DEB); +my $fields = Dpkg::Control->new(type => CTRL_DEB); # Old-style bin-nmus change the source version submitted to # set_version_substvars() diff --git a/scripts/dpkg-name.pl b/scripts/dpkg-name.pl index 0fc4b324f..0d23ddd6a 100755 --- a/scripts/dpkg-name.pl +++ b/scripts/dpkg-name.pl @@ -96,7 +96,7 @@ sub getfields($) # Read the fields open(my $cdata_fh, '-|', 'dpkg-deb', '-f', '--', $filename) or syserr(g_('cannot open %s'), $filename); - my $fields = Dpkg::Control->new(type => CTRL_PKG_DEB); + my $fields = Dpkg::Control->new(type => CTRL_DEB); $fields->parse($cdata_fh, sprintf(g_('binary control file %s'), $filename)); close($cdata_fh); diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl index 2b2296d63..36389cc94 100755 --- a/scripts/dpkg-scanpackages.pl +++ b/scripts/dpkg-scanpackages.pl @@ -158,7 +158,7 @@ sub load_override_extra sub process_deb { my ($pathprefix, $fn) = @_; - my $fields = Dpkg::Control->new(type => CTRL_INDEX_PKG); + my $fields = Dpkg::Control->new(type => CTRL_REPO_PKG); open my $output_fh, '-|', 'dpkg-deb', '-I', $fn, 'control' or syserr(g_('cannot fork for %s'), 'dpkg-deb'); diff --git a/scripts/dpkg-scansources.pl b/scripts/dpkg-scansources.pl index c4bd5df5d..994beaeb4 100755 --- a/scripts/dpkg-scansources.pl +++ b/scripts/dpkg-scansources.pl @@ -213,9 +213,9 @@ sub process_dsc { $dir = '.' if $dir eq ''; # Parse ‘.dsc’ file. - my $fields = Dpkg::Control->new(type => CTRL_PKG_SRC); + my $fields = Dpkg::Control->new(type => CTRL_DSC); $fields->load($file); - $fields->set_options(type => CTRL_INDEX_SRC); + $fields->set_options(type => CTRL_REPO_SRC); # Get checksums my $checksums = Dpkg::Checksums->new(); diff --git a/scripts/t/Dpkg_BuildAPI.t b/scripts/t/Dpkg_BuildAPI.t index 8765aa928..b948a8a33 100644 --- a/scripts/t/Dpkg_BuildAPI.t +++ b/scripts/t/Dpkg_BuildAPI.t @@ -33,7 +33,7 @@ my $datadir = test_get_data_path(); sub test_load_ctrl { my $file = shift; - my $ctrl = Dpkg::Control::Info->new(type => CTRL_INFO_SRC); + my $ctrl = Dpkg::Control::Info->new(type => CTRL_TMPL_SRC); $ctrl->load("$datadir/$file"); return $ctrl; diff --git a/scripts/t/Dpkg_Control.t b/scripts/t/Dpkg_Control.t index d1ffa895e..29311b8c8 100644 --- a/scripts/t/Dpkg_Control.t +++ b/scripts/t/Dpkg_Control.t @@ -43,7 +43,7 @@ sub parse_ctrl { sub parse_dsc { my $path = shift; - return parse_ctrl(CTRL_PKG_SRC, $path); + return parse_ctrl(CTRL_DSC, $path); } my $c = Dpkg::Control::Info->new("$datadir/control-1"); diff --git a/scripts/t/Dpkg_Control_Fields.t b/scripts/t/Dpkg_Control_Fields.t index 1c699e373..800e64902 100644 --- a/scripts/t/Dpkg_Control_Fields.t +++ b/scripts/t/Dpkg_Control_Fields.t @@ -96,7 +96,7 @@ my @test_fields = qw( ); my %fields = ( - CTRL_INFO_SRC() => { + CTRL_TMPL_SRC() => { name => 'debian/control source stanza', fields => [ qw( @@ -121,7 +121,7 @@ my %fields = ( ), ], }, - CTRL_INFO_PKG() => { + CTRL_TMPL_PKG() => { name => 'debian/control binary stanza', fields => [ qw( @@ -149,7 +149,7 @@ my %fields = ( ), ], }, - CTRL_PKG_SRC() => { + CTRL_DSC() => { name => '.dsc', fields => [ qw( @@ -174,7 +174,7 @@ my %fields = ( @src_files, ], }, - CTRL_PKG_DEB() => { + CTRL_DEB() => { name => 'DEBIAN/control', fields => [ qw( @@ -208,7 +208,7 @@ my %fields = ( ), ], }, - CTRL_INDEX_SRC() => { + CTRL_REPO_SRC() => { name => 'Sources', fields => [ qw( @@ -236,7 +236,7 @@ my %fields = ( @src_files, ], }, - CTRL_INDEX_PKG() => { + CTRL_REPO_PKG() => { name => 'Packages', fields => [ qw( @@ -518,7 +518,7 @@ foreach my $type (sort keys %fields) { # Check deb822 field parsers -my $ctrl = Dpkg::Control->new(type => CTRL_PKG_DEB); +my $ctrl = Dpkg::Control->new(type => CTRL_DEB); my ($source, $version); -- Dpkg.Org's dpkg