+2008-01-12 Raphael hertzog <hertzog@debian.org>
+
+ * scripts/Dpkg/Fields.pm: Define variables containing
+ authoritative list of fields for debian/control (one for source
+ stanza, one for package stanza).
+ * scripts/dpkg-genchanges.pl, scripts/dpkg-gencontrol.pl,
+ scripts/dpkg-source.pl: Use the new variables to properly ignore
+ valid fields. Some related cleanup.
+
2008-01-11 Raphael Hertzog <hertzog@debian.org>
* scripts/dpkg-gencontrol.pl: Also force version in ${binary:Version}
use warnings;
use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(capit set_field_importance sort_field_by_importance);
+use Dpkg::Deps qw(@src_dep_fields @pkg_dep_fields);
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(capit set_field_importance sort_field_by_importance
+ %control_src_fields %control_pkg_fields $control_src_field_regex
+ $control_pkg_field_regex);
+our %EXPORT_TAGS = ('list' => [qw(%control_src_fields %control_pkg_fields
+ $control_src_field_regex $control_pkg_field_regex)]);
+
+# Some variables (list of fields)
+our %control_src_fields;
+our %control_pkg_fields;
+$control_src_fields{$_} = 1 foreach (qw(Bugs
+ Homepage Origin Maintainer Priority Section Source Standards-Version
+ Uploaders Vcs-Browser Vcs-Arch Vcs-Bzr Vcs-Cvs Vcs-Darcs Vcs-Git Vcs-Hg
+ Vcs-Mtn Vcs-Svn));
+$control_src_fields{$_} = 1 foreach (@src_dep_fields);
+$control_pkg_fields{$_} = 1 foreach (qw(Architecture Bugs Description Essential
+ Homepage Installer-Menu-Item Kernel-Version Package Package-Type
+ Priority Section Subarchitecture Tag));
+$control_pkg_fields{$_} = 1 foreach (@pkg_dep_fields);
+
+our $control_src_field_regex = "(?:" . join("|", keys %control_src_fields) . ")";
+our $control_pkg_field_regex = "(?:" . join("|", keys %control_pkg_fields) . ")";
+
+# Some functions
sub capit {
my @pieces = map { ucfirst(lc) } split /-/, $_[0];
return join '-', @pieces;
use Dpkg::ErrorHandling qw(warning error failure unknown internerr syserr
subprocerr usageerr);
use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is);
-use Dpkg::Fields qw(capit set_field_importance sort_field_by_importance);
+use Dpkg::Fields qw(:list capit set_field_importance sort_field_by_importance);
use Dpkg::Compression;
use Dpkg::Control;
use Dpkg::Cdata;
my $v = $src_fields->{$_};
if (m/^Source$/) {
set_source_package($v);
+ } elsif (m/^Section$|^Priority$/i) {
+ $sourcedefault{$_} = $v;
+ } elsif (m/^Maintainer$/i) {
+ $fields->{$_} = $v;
+ } elsif (s/^X[BS]*C[BS]*-//i) { # Include XC-* fields
+ $fields->{$_} = $v;
+ } elsif (m/^X[BS]+-/i || m/^$control_src_field_regex$/i) {
+ # Silently ignore valid fields
+ } else {
+ unknown(_g('general section of control info file'));
}
- elsif (m/^Section$|^Priority$/i) { $sourcedefault{$_}= $v; }
- elsif (m/^Maintainer$/i) { $fields->{$_} = $v; }
- elsif (s/^X[BS]*C[BS]*-//i) { $fields->{$_} = $v; }
- elsif (m/^X[BS]+-/i ||
- m/^Build-(Depends|Conflicts)(-Indep)?$/i ||
- m/^(Standards-Version|Uploaders|Homepage|Origin|Bugs)$/i ||
- m/^Vcs-(Browser|Arch|Bzr|Cvs|Darcs|Git|Hg|Mtn|Svn)$/i) {
- }
- else { &unknown(_g('general section of control info file')); }
}
# Scan control info of all binary packages
$f2seccf{$_} = $v foreach (@f);
} elsif (m/^Priority$/) {
$f2pricf{$_} = $v foreach (@f);
- } elsif (s/^X[BS]*C[BS]*-//i) {
+ } elsif (s/^X[BS]*C[BS]*-//i) { # Include XC-* fields
$fields->{$_} = $v;
} elsif (m/^Architecture$/) {
if (not is_sourceonly) {
$v = '';
}
push(@archvalues,$v) unless !$v || $archadded{$v}++;
- } elsif (m/^(Package|Package-Type|Kernel-Version|Essential)$/ ||
- m/^(Homepage|Tag|Installer-Menu-Item|Subarchitecture)$/i ||
- m/^(Pre-Depends|Depends|Recommends|Suggests|Provides)$/ ||
- m/^(Enhances|Conflicts|Breaks|Replaces)$/ ||
- m/^X[BS]+-/i) {
+ } elsif (m/^$control_pkg_field_regex$/ || m/^X[BS]+-/i) {
+ # Silently ignore valid fields
} else {
- &unknown(_g("package's section of control info file"));
+ unknown(_g("package's section of control info file"));
}
}
}
} elsif (s/^X[BS]*C[BS]*-//i) {
$fields->{$_} = $v;
} elsif (!m/^X[BS]+-/i) {
- &unknown(_g("parsed version of changelog"));
+ unknown(_g("parsed version of changelog"));
}
}
subprocerr usageerr);
use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is);
use Dpkg::Deps qw(@pkg_dep_fields %dep_field_type);
-use Dpkg::Fields qw(capit set_field_importance);
+use Dpkg::Fields qw(:list capit set_field_importance);
use Dpkg::Control;
use Dpkg::Substvars;
use Dpkg::Vars;
my $src_fields = $control->get_source();
foreach $_ (keys %{$src_fields}) {
my $v = $src_fields->{$_};
- if (m/^(Origin|Bugs|Maintainer)$/) {
- $fields->{$_} = $v;
- } elsif (m/^(Section|Priority|Homepage)$/) {
+ if (m/^(Origin|Bugs|Maintainer|Section|Priority|Homepage)$/) {
$fields->{$_} = $v;
} elsif (m/^Source$/) {
set_source_package($v);
+ } elsif (s/^X[CS]*B[CS]*-//i) { # Include XB-* fields
+ $fields->{$_} = $v;
+ } elsif (m/^X[CS]+-/i || m/^$control_src_field_regex$/i) {
+ # Silently ignore valid fields
+ } else {
+ unknown(_g('general section of control info file'));
}
- elsif (s/^X[CS]*B[CS]*-//i) { $fields->{$_} = $v; }
- elsif (m/^X[CS]+-/i ||
- m/^Build-(Depends|Conflicts)(-Indep)?$/i ||
- m/^(Standards-Version|Uploaders)$/i ||
- m/^Vcs-(Browser|Arch|Bzr|Cvs|Darcs|Git|Hg|Mtn|Svn)$/i) {
- }
- else { &unknown(_g('general section of control info file')); }
}
# Scan binary package
foreach $_ (keys %{$pkg}) {
my $v = $pkg->{$_};
- if (m/^(Package|Package-Type|Description|Homepage|Tag|Essential)$/ ||
- m/^(Section$|Priority)$/ ||
- m/^(Subarchitecture|Kernel-Version|Installer-Menu-Item)$/) {
- $fields->{$_} = $v;
- } elsif (exists($pkg_dep_fields{$_})) {
+ if (exists($pkg_dep_fields{$_})) {
# Delay the parsing until later
} elsif (m/^Architecture$/) {
my $host_arch = get_host_arch();
$host_arch, "@archlist");
$fields->{$_} = $host_arch;
}
- } elsif (s/^X[CS]*B[CS]*-//i) {
- $fields->{$_}= $v;
+ } elsif (m/^$control_pkg_field_regex$/) {
+ $fields->{$_} = $v;
+ } elsif (s/^X[CS]*B[CS]*-//i) { # Include XB-* fields
+ $fields->{$_} = $v;
} elsif (!m/^X[CS]+-/i) {
- &unknown(_g("package's section of control info file"));
+ unknown(_g("package's section of control info file"));
}
}
} elsif (s/^X[CS]*B[CS]*-//i) {
$fields->{$_} = $v;
} elsif (!m/^X[CS]+-/i) {
- &unknown(_g("parsed version of changelog"));
+ unknown(_g("parsed version of changelog"));
}
}
$warnable_error $quiet_warnings);
use Dpkg::Arch qw(debarch_eq);
use Dpkg::Deps qw(@src_dep_fields %dep_field_type);
-use Dpkg::Fields qw(capit set_field_importance);
+use Dpkg::Fields qw(:list capit set_field_importance);
use Dpkg::Compression;
use Dpkg::Cdata;
use Dpkg::Control;
} elsif (m/^(Standards-Version|Origin|Maintainer|Homepage)$/i ||
m/^Vcs-(Browser|Arch|Bzr|Cvs|Darcs|Git|Hg|Mtn|Svn)$/i) {
$fields->{$_} = $v;
- }
- elsif (m/^Uploaders$/i) { ($fields->{$_} = $v) =~ s/[\r\n]//g; }
- elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) {
+ } elsif (m/^Uploaders$/i) {
+ ($fields->{$_} = $v) =~ s/[\r\n]//g; # Merge in a single-line
+ } elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) {
my $dep;
my $type = $dep_field_type{capit($_)};
$dep = Dpkg::Deps::parse($v, union => $type eq 'union');
$dep->simplify_deps($facts);
$dep->sort();
$fields->{$_} = $dep->dump();
+ } elsif (s/^X[BC]*S[BC]*-//i) { # Include XS-* fields
+ $fields->{$_} = $v;
+ } elsif (m/^$control_src_field_regex$/i || m/^X[BC]+-/i) {
+ # Silently ignore valid fields
+ } else {
+ unknown(_g('general section of control info file'));
}
- elsif (s/^X[BC]*S[BC]*-//i) { $fields->{$_} = $v; }
- elsif (m/^(Section|Priority|Files|Bugs)$/i || m/^X[BC]+-/i) { }
- else { &unknown(_g('general section of control info file')); }
}
# Scan control info of binary packages
}
}
$fields->{'Architecture'}= join(' ',@sourcearch);
- } elsif (s/^X[BC]*S[BC]*-//i) {
+ } elsif (s/^X[BC]*S[BC]*-//i) { # Include XS-* fields
$fields->{$_} = $v;
- } elsif (m/^(Package|Package-Type|Essential|Kernel-Version)$/ ||
- m/^(Homepage|Subarchitecture|Installer-Menu-Item)$/i ||
- m/^(Pre-Depends|Depends|Provides)$/i ||
- m/^(Recommends|Suggests|Conflicts|Replaces)$/i ||
- m/^(Breaks|Enhances|Description|Tag|Section|Priority)$/i ||
- m/^X[BC]+-/i) {
+ } elsif (m/^$control_pkg_field_regex$/ ||
+ m/^X[BC]+-/i) { # Silently ignore valid fields
} else {
- &unknown(_g("package's section of control info file"));
+ unknown(_g("package's section of control info file"));
}
}
}
} elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/i ||
m/^X[BS]+-/i) {
} else {
- &unknown(_g("parsed version of changelog"));
+ unknown(_g("parsed version of changelog"));
}
}