From 4c01feffd3f467a63f934568f0c8762ed33580d4 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Tue, 1 Jan 2008 18:13:07 +0100 Subject: [PATCH] Update all scripts to use Dpkg::Changelog::parse_changelog * scripts/dpkg-buildpackage.pl, scripts/dpkg-checkbuilddeps.pl, scripts/dpkg-genchanges.pl, scripts/dpkg-gencontrol.pl, scripts/dpkg-gensymbols.pl, scripts/dpkg-source.pl: Update scripts to use Dpkg::Changelog::parse_changelog instead of the old controllib.pl's parsechangelog. With this last change controllib.pl is no more used by any script. --- scripts/dpkg-buildpackage.pl | 3 --- scripts/dpkg-checkbuilddeps.pl | 3 --- scripts/dpkg-genchanges.pl | 38 ++++++++++++++------------------- scripts/dpkg-gencontrol.pl | 39 +++++++++++++++------------------- scripts/dpkg-gensymbols.pl | 11 +++------- scripts/dpkg-source.pl | 38 ++++++++++++++------------------- 6 files changed, 52 insertions(+), 80 deletions(-) diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index a21c5af1..7e373685 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -13,9 +13,6 @@ use Dpkg::ErrorHandling qw(warning error failure syserr subprocerr usageerr use Dpkg::BuildOptions; use Dpkg::Version qw(check_version); -push (@INC, $dpkglibdir); -require 'controllib.pl'; - textdomain("dpkg-dev"); sub showversion { diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index eea28fe2..b89fd21b 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -12,9 +12,6 @@ use Dpkg::Arch qw(get_host_arch); use Dpkg::Deps; use Dpkg::Control; -push(@INC,$dpkglibdir); -require 'controllib.pl'; - textdomain("dpkg-dev"); sub usage { diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 165d28b4..39e2818a 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -17,11 +17,7 @@ use Dpkg::Control; use Dpkg::Cdata; use Dpkg::Substvars; use Dpkg::Vars; - -push(@INC,$dpkglibdir); -require 'controllib.pl'; - -our (%fi); +use Dpkg::Changelog qw(parse_changelog); textdomain("dpkg-dev"); @@ -184,10 +180,10 @@ while (@ARGV) { } } -parsechangelog($changelogfile, $changelogformat, $since); +my $changelog = parse_changelog($changelogfile, $changelogformat, $since); my $control = Dpkg::Control->new($controlfile); my $fields = Dpkg::Fields::Object->new(); -$substvars->set_version_substvars($fi{"L Version"}); +$substvars->set_version_substvars($changelog->{"Version"}); if (not is_sourceonly) { open(FL,"<",$fileslistfile) || &syserr(_g("cannot read files list file")); @@ -305,21 +301,19 @@ foreach my $pkg ($control->get_packages()) { } } -for $_ (keys %fi) { - my $v = $fi{$_}; - - if (s/^L //) { - if (m/^Source$/i) { - set_source_package($v); - } elsif (m/^Maintainer$/i) { - $fields->{"Changed-By"} = $v; - } elsif (m/^(Version|Changes|Urgency|Distribution|Date|Closes)$/i) { - $fields->{$_} = $v; - } elsif (s/^X[BS]*C[BS]*-//i) { - $fields->{$_} = $v; - } elsif (!m/^X[BS]+-/i) { - &unknown(_g("parsed version of changelog")); - } +# Scan fields of dpkg-parsechangelog +foreach $_ (keys %{$changelog}) { + my $v = $changelog->{$_}; + if (m/^Source$/i) { + set_source_package($v); + } elsif (m/^Maintainer$/i) { + $fields->{"Changed-By"} = $v; + } elsif (m/^(Version|Changes|Urgency|Distribution|Date|Closes)$/i) { + $fields->{$_} = $v; + } elsif (s/^X[BS]*C[BS]*-//i) { + $fields->{$_} = $v; + } elsif (!m/^X[BS]+-/i) { + &unknown(_g("parsed version of changelog")); } } diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index eedadc33..d927a8c0 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -15,11 +15,7 @@ use Dpkg::Fields qw(capit set_field_importance); use Dpkg::Control; use Dpkg::Substvars; use Dpkg::Vars; - -push(@INC,$dpkglibdir); -require 'controllib.pl'; - -our %fi; +use Dpkg::Changelog qw(parse_changelog); textdomain("dpkg-dev"); @@ -125,8 +121,8 @@ while (@ARGV) { } } -parsechangelog($changelogfile, $changelogformat); -$substvars->set_version_substvars($fi{"L Version"}); +my $changelog = parse_changelog($changelogfile, $changelogformat); +$substvars->set_version_substvars($changelog->{"Version"}); $substvars->parse($varlistfile) if -e $varlistfile; my $control = Dpkg::Control->new($controlfile); my $fields = Dpkg::Fields::Object->new(); @@ -201,21 +197,20 @@ foreach $_ (keys %{$pkg}) { } } -for $_ (keys %fi) { - my $v = $fi{$_}; - - if (s/^L //) { - if (m/^Source$/) { - set_source_package($v); - } elsif (m/^Version$/) { - $sourceversion = $v; - $fields->{$_} = $v unless defined($forceversion); - } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/) { - } elsif (s/^X[CS]*B[CS]*-//i) { - $fields->{$_} = $v; - } elsif (!m/^X[CS]+-/i) { - $_ = "L $_"; &unknown(_g("parsed version of changelog")); - } +# Scan fields of dpkg-parsechangelog +foreach $_ (keys %{$changelog}) { + my $v = $changelog->{$_}; + + if (m/^Source$/) { + set_source_package($v); + } elsif (m/^Version$/) { + $sourceversion = $v; + $fields->{$_} = $v unless defined($forceversion); + } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/) { + } elsif (s/^X[CS]*B[CS]*-//i) { + $fields->{$_} = $v; + } elsif (!m/^X[CS]+-/i) { + &unknown(_g("parsed version of changelog")); } } diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl index 309950fb..592ea25f 100755 --- a/scripts/dpkg-gensymbols.pl +++ b/scripts/dpkg-gensymbols.pl @@ -11,15 +11,10 @@ use Dpkg::Shlibs::SymbolFile; use Dpkg::Gettext; use Dpkg::ErrorHandling qw(warning error syserr usageerr); use Dpkg::Control; +use Dpkg::Changelog qw(parse_changelog); textdomain("dpkg-dev"); -push(@INC, $dpkglibdir); -require 'controllib.pl'; - -our %fi; -our %p2i; - my $changelogfile = 'debian/changelog'; my $packagebuilddir = 'debian/tmp'; @@ -114,8 +109,8 @@ if (exists $ENV{DPKG_GENSYMBOLS_CHECK_LEVEL}) { } if (not defined($sourceversion)) { - parsechangelog($changelogfile); - $sourceversion = $fi{"L Version"}; + my $changelog = parse_changelog($changelogfile); + $sourceversion = $changelog->{"Version"}; } if (not defined($oppackage)) { my $control = Dpkg::Control->new(); diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index caf104dc..6458007e 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -17,6 +17,7 @@ use Dpkg::Control; use Dpkg::Substvars; use Dpkg::Version qw(check_version); use Dpkg::Vars; +use Dpkg::Changelog qw(parse_changelog); my @filesinarchive; my %dirincluded; @@ -113,12 +114,6 @@ use English; use File::Temp qw (tempfile); use Cwd; -push (@INC, $dpkglibdir); -require 'controllib.pl'; - -our (%fi); -our @src_dep_fields; - textdomain("dpkg-dev"); my @dsc_fields = (qw(Format Source Binary Architecture Version Origin @@ -296,7 +291,7 @@ if ($opmode eq 'build') { $changelogfile= "$dir/debian/changelog" unless defined($changelogfile); $controlfile= "$dir/debian/control" unless defined($controlfile); - parsechangelog($changelogfile, $changelogformat); + my $changelog = parse_changelog($changelogfile, $changelogformat); my $control = Dpkg::Control->new($controlfile); my $fields = Dpkg::Fields::Object->new(); @@ -379,22 +374,21 @@ if ($opmode eq 'build') { } } - for $_ (keys %fi) { - my $v = $fi{$_}; + # Scan fields of dpkg-parsechangelog + foreach $_ (keys %{$changelog}) { + my $v = $changelog->{$_}; - if (s/^L //) { - if (m/^Source$/) { - set_source_package($v); - } elsif (m/^Version$/) { - check_version($v); - $fields->{$_} = $v; - } elsif (s/^X[BS]*C[BS]*-//i) { - $fields->{$_} = $v; - } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/i || - m/^X[BS]+-/i) { - } else { - &unknown(_g("parsed version of changelog")); - } + if (m/^Source$/) { + set_source_package($v); + } elsif (m/^Version$/) { + check_version($v); + $fields->{$_} = $v; + } elsif (s/^X[BS]*C[BS]*-//i) { + $fields->{$_} = $v; + } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/i || + m/^X[BS]+-/i) { + } else { + &unknown(_g("parsed version of changelog")); } } -- 2.39.5