Explorar el Código

Dpkg::Control: Add new CTRL_REPO_RELEASE control block type

Guillem Jover hace 14 años
padre
commit
cf66d0e6f0
Se han modificado 4 ficheros con 53 adiciones y 10 borrados
  1. 2 0
      debian/changelog
  2. 17 6
      scripts/Dpkg/Control.pm
  3. 31 4
      scripts/Dpkg/Control/FieldsCore.pm
  4. 3 0
      scripts/Dpkg/Control/Types.pm

+ 2 - 0
debian/changelog

@@ -7,6 +7,8 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
   * Implement delete operator with size argument in dselect, required by the
   * Implement delete operator with size argument in dselect, required by the
     C++14 spec when the size-less delete operator is defined.
     C++14 spec when the size-less delete operator is defined.
   * Use EACCES instead of EWOULDBLOCK for fcntl(2) F_SETLK in dselect.
   * Use EACCES instead of EWOULDBLOCK for fcntl(2) F_SETLK in dselect.
+  * Perl modules:
+    - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
   * Documentation:
   * Documentation:
     - Say value instead of option in deb-control(5).
     - Say value instead of option in deb-control(5).
     - Mark debian changelog format in bold in dpkg-parsechangelog(1).
     - Mark debian changelog format in bold in dpkg-parsechangelog(1).

+ 17 - 6
scripts/Dpkg/Control.pm

@@ -18,13 +18,14 @@ package Dpkg::Control;
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 our @EXPORT = qw(
 our @EXPORT = qw(
     CTRL_UNKNOWN
     CTRL_UNKNOWN
     CTRL_INFO_SRC
     CTRL_INFO_SRC
     CTRL_INFO_PKG
     CTRL_INFO_PKG
     CTRL_INDEX_SRC
     CTRL_INDEX_SRC
     CTRL_INDEX_PKG
     CTRL_INDEX_PKG
+    CTRL_REPO_RELEASE
     CTRL_PKG_SRC
     CTRL_PKG_SRC
     CTRL_PKG_DEB
     CTRL_PKG_DEB
     CTRL_FILE_CHANGES
     CTRL_FILE_CHANGES
@@ -76,6 +77,10 @@ a Debian source package.
 Corresponds to subsequent blocks of information in a F<debian/control> file
 Corresponds to subsequent blocks of information in a F<debian/control> file
 in a Debian source package.
 in a Debian source package.
 
 
+=item CTRL_REPO_RELEASE
+
+Corresponds to a Release file in a repository.
+
 =item CTRL_INDEX_SRC
 =item CTRL_INDEX_SRC
 
 
 Corresponds to an entry in a F<Sources> file of a source package
 Corresponds to an entry in a F<Sources> file of a source package
@@ -142,10 +147,10 @@ sub new {
 
 
 Changes the value of one or more options. If the "type" option is changed,
 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
 it is used first to define default values for others options. The option
-"allow_pgp" is set to 1 for CTRL_PKG_SRC and CTRL_FILE_CHANGES 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" is set to a textual
-description of the type of control information.
+"allow_pgp" is set to 1 for CTRL_PKG_SRC, 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"
+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
 The output order is also set to match the ordered list returned by
 Dpkg::Control::Fields::field_ordered_list($type).
 Dpkg::Control::Fields::field_ordered_list($type).
@@ -156,7 +161,7 @@ sub set_options {
     my ($self, %opts) = @_;
     my ($self, %opts) = @_;
     if (exists $opts{type}) {
     if (exists $opts{type}) {
         my $t = $opts{type};
         my $t = $opts{type};
-        $$self->{allow_pgp} = ($t & (CTRL_PKG_SRC | CTRL_FILE_CHANGES)) ? 1 : 0;
+        $$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;
         $$self->{drop_empty} = ($t & (CTRL_INFO_PKG | CTRL_INFO_SRC)) ?  0 : 1;
         if ($t == CTRL_INFO_SRC) {
         if ($t == CTRL_INFO_SRC) {
             $$self->{name} = g_('general section of control info file');
             $$self->{name} = g_('general section of control info file');
@@ -164,6 +169,8 @@ sub set_options {
             $$self->{name} = g_("package's section of control info file");
             $$self->{name} = g_("package's section of control info file");
         } elsif ($t == CTRL_CHANGELOG) {
         } elsif ($t == CTRL_CHANGELOG) {
             $$self->{name} = g_('parsed version of changelog');
             $$self->{name} = g_('parsed version of changelog');
+        } elsif ($t == CTRL_REPO_RELEASE) {
+            $$self->{name} = sprintf(g_("repository's %s file"), 'Release');
         } elsif ($t == CTRL_INDEX_SRC) {
         } elsif ($t == CTRL_INDEX_SRC) {
             $$self->{name} = sprintf(g_("entry in repository's %s file"), 'Sources');
             $$self->{name} = sprintf(g_("entry in repository's %s file"), 'Sources');
         } elsif ($t == CTRL_INDEX_PKG) {
         } elsif ($t == CTRL_INDEX_PKG) {
@@ -202,6 +209,10 @@ sub get_type {
 
 
 =head1 CHANGES
 =head1 CHANGES
 
 
+=head2 Version 1.01 (dpkg 1.18.5)
+
+New types: CTRL_REPO_RELEASE.
+
 =head2 Version 1.00 (dpkg 1.15.6)
 =head2 Version 1.00 (dpkg 1.15.6)
 
 
 Mark the module as public.
 Mark the module as public.

+ 31 - 4
scripts/Dpkg/Control/FieldsCore.pm

@@ -68,6 +68,10 @@ our %FIELDS = (
         allowed => (ALL_PKG | ALL_SRC | CTRL_FILE_CHANGES) & (~CTRL_INFO_SRC),
         allowed => (ALL_PKG | ALL_SRC | CTRL_FILE_CHANGES) & (~CTRL_INFO_SRC),
         separator => FIELD_SEP_SPACE,
         separator => FIELD_SEP_SPACE,
     },
     },
+    'Architectures' => {
+        allowed => CTRL_REPO_RELEASE,
+        separator => FIELD_SEP_SPACE,
+    },
     'Binary' => {
     'Binary' => {
         allowed => CTRL_PKG_SRC | CTRL_FILE_CHANGES,
         allowed => CTRL_PKG_SRC | CTRL_FILE_CHANGES,
         # XXX: This field values are separated either by space or comma
         # XXX: This field values are separated either by space or comma
@@ -142,6 +146,9 @@ our %FIELDS = (
     'Changed-By' => {
     'Changed-By' => {
         allowed => CTRL_FILE_CHANGES,
         allowed => CTRL_FILE_CHANGES,
     },
     },
+    'Changelogs' => {
+        allowed => CTRL_REPO_RELEASE,
+    },
     'Changes' => {
     'Changes' => {
         allowed => ALL_CHANGES,
         allowed => ALL_CHANGES,
     },
     },
@@ -149,6 +156,13 @@ our %FIELDS = (
         allowed => ALL_CHANGES,
         allowed => ALL_CHANGES,
         separator => FIELD_SEP_SPACE,
         separator => FIELD_SEP_SPACE,
     },
     },
+    'Codename' => {
+        allowed => CTRL_REPO_RELEASE,
+    },
+    'Components' => {
+        allowed => CTRL_REPO_RELEASE,
+        separator => FIELD_SEP_SPACE,
+    },
     'Conffiles' => {
     'Conffiles' => {
         allowed => CTRL_FILE_STATUS,
         allowed => CTRL_FILE_STATUS,
         separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
         separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
@@ -163,7 +177,7 @@ our %FIELDS = (
         dep_order => 6,
         dep_order => 6,
     },
     },
     'Date' => {
     'Date' => {
-        allowed => ALL_CHANGES,
+        allowed => ALL_CHANGES | CTRL_REPO_RELEASE,
     },
     },
     'Depends' => {
     'Depends' => {
         allowed => ALL_PKG,
         allowed => ALL_PKG,
@@ -172,7 +186,7 @@ our %FIELDS = (
         dep_order => 2,
         dep_order => 2,
     },
     },
     'Description' => {
     'Description' => {
-        allowed => ALL_PKG | CTRL_FILE_CHANGES,
+        allowed => ALL_PKG | CTRL_FILE_CHANGES | CTRL_REPO_RELEASE,
     },
     },
     'Directory' => {
     'Directory' => {
         allowed => CTRL_INDEX_SRC,
         allowed => CTRL_INDEX_SRC,
@@ -212,8 +226,11 @@ our %FIELDS = (
     'Kernel-Version' => {
     'Kernel-Version' => {
         allowed => ALL_PKG,
         allowed => ALL_PKG,
     },
     },
+    'Label' => {
+        allowed => CTRL_REPO_RELEASE,
+    },
     'Origin' => {
     'Origin' => {
-        allowed => (ALL_PKG | ALL_SRC) & (~CTRL_INFO_PKG),
+        allowed => (ALL_PKG | ALL_SRC | CTRL_REPO_RELEASE) & (~CTRL_INFO_PKG),
     },
     },
     'Maintainer' => {
     'Maintainer' => {
         allowed => CTRL_PKG_DEB| CTRL_FILE_STATUS | ALL_SRC  | ALL_CHANGES,
         allowed => CTRL_PKG_DEB| CTRL_FILE_STATUS | ALL_SRC  | ALL_CHANGES,
@@ -282,6 +299,9 @@ our %FIELDS = (
     'Subarchitecture' => {
     'Subarchitecture' => {
         allowed => ALL_PKG,
         allowed => ALL_PKG,
     },
     },
+    'Suite' => {
+        allowed => CTRL_REPO_RELEASE,
+    },
     'Suggests' => {
     'Suggests' => {
         allowed => ALL_PKG,
         allowed => ALL_PKG,
         separator => FIELD_SEP_COMMA,
         separator => FIELD_SEP_COMMA,
@@ -314,6 +334,9 @@ our %FIELDS = (
     'Urgency' => {
     'Urgency' => {
         allowed => ALL_CHANGES,
         allowed => ALL_CHANGES,
     },
     },
+    'Valid-Until' => {
+        allowed => CTRL_REPO_RELEASE,
+    },
     'Vcs-Browser' => {
     'Vcs-Browser' => {
         allowed => ALL_SRC,
         allowed => ALL_SRC,
     },
     },
@@ -357,7 +380,7 @@ my @checksum_fields = map { &field_capitalize("Checksums-$_") } checksums_get_li
 my @sum_fields = map { $_ eq 'md5' ? 'MD5sum' : &field_capitalize($_) }
 my @sum_fields = map { $_ eq 'md5' ? 'MD5sum' : &field_capitalize($_) }
                  checksums_get_list();
                  checksums_get_list();
 &field_register($_, CTRL_PKG_SRC | CTRL_FILE_CHANGES) foreach @checksum_fields;
 &field_register($_, CTRL_PKG_SRC | CTRL_FILE_CHANGES) foreach @checksum_fields;
-&field_register($_, CTRL_INDEX_PKG,
+&field_register($_, CTRL_INDEX_PKG | CTRL_REPO_RELEASE,
                 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE) foreach @sum_fields;
                 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE) foreach @sum_fields;
 
 
 our %FIELD_ORDER = (
 our %FIELD_ORDER = (
@@ -392,6 +415,10 @@ our %FIELD_ORDER = (
         Conflicts Enhances Conffiles Description Triggers-Pending
         Conflicts Enhances Conffiles Description Triggers-Pending
         Triggers-Awaited)
         Triggers-Awaited)
     ],
     ],
+    CTRL_REPO_RELEASE() => [
+        qw(Origin Label Suite Codename Changelogs Date Valid-Until
+        Architectures Components Description), @sum_fields
+    ],
 );
 );
 # Order for CTRL_INDEX_PKG is derived from CTRL_PKG_DEB
 # Order for CTRL_INDEX_PKG is derived from CTRL_PKG_DEB
 $FIELD_ORDER{CTRL_INDEX_PKG()} = [ @{$FIELD_ORDER{CTRL_PKG_DEB()}} ];
 $FIELD_ORDER{CTRL_INDEX_PKG()} = [ @{$FIELD_ORDER{CTRL_PKG_DEB()}} ];

+ 3 - 0
scripts/Dpkg/Control/Types.pm

@@ -21,6 +21,7 @@ our @EXPORT = qw(
     CTRL_UNKNOWN
     CTRL_UNKNOWN
     CTRL_INFO_SRC
     CTRL_INFO_SRC
     CTRL_INFO_PKG
     CTRL_INFO_PKG
+    CTRL_REPO_RELEASE
     CTRL_INDEX_SRC
     CTRL_INDEX_SRC
     CTRL_INDEX_PKG
     CTRL_INDEX_PKG
     CTRL_PKG_SRC
     CTRL_PKG_SRC
@@ -61,6 +62,8 @@ use constant {
     CTRL_FILE_VENDOR => 128, # File in $Dpkg::CONFDIR/origins
     CTRL_FILE_VENDOR => 128, # File in $Dpkg::CONFDIR/origins
     CTRL_FILE_STATUS => 256, # $Dpkg::ADMINDIR/status
     CTRL_FILE_STATUS => 256, # $Dpkg::ADMINDIR/status
     CTRL_CHANGELOG => 512,   # Output of dpkg-parsechangelog
     CTRL_CHANGELOG => 512,   # Output of dpkg-parsechangelog
+    # Repository's (In)Release file.
+    CTRL_REPO_RELEASE => 1024,
 };
 };
 
 
 =head1 CHANGES
 =head1 CHANGES