瀏覽代碼

dpkg-buildpackage: Use Dpkg::Control to parse .changes file

This removes a custom parser, replaced by the proper Dpkg::Control
type, which reduces code and will make it easier to handle updates
in the checksums after signing has happened.
Guillem Jover 12 年之前
父節點
當前提交
6222e8f015
共有 1 個文件被更改,包括 7 次插入19 次删除
  1. 7 19
      scripts/dpkg-buildpackage.pl

+ 7 - 19
scripts/dpkg-buildpackage.pl

@@ -35,6 +35,7 @@ use Dpkg::BuildOptions;
 use Dpkg::BuildProfiles qw(set_build_profiles);
 use Dpkg::Compression;
 use Dpkg::Version;
+use Dpkg::Control;
 use Dpkg::Changelog::Parse;
 use Dpkg::Path qw(find_command);
 use Dpkg::IPC;
@@ -482,28 +483,15 @@ push @changes_opts, "-v$since" if defined $since;
 push @changes_opts, "-C$desc" if defined $desc;
 
 my $chg = "../$pva.changes";
+my $changes = Dpkg::Control->new(type => CTRL_FILE_CHANGES);
+
 print { *STDERR } " dpkg-genchanges @changes_opts >$chg\n";
+
 open my $changes_fh, '-|', 'dpkg-genchanges', @changes_opts
     or subprocerr('dpkg-genchanges');
-
-open my $out_fh, '>', $chg or syserr(_g('write changes file'));
-
-my $infiles = my $files = '';
-while ($_ = <$changes_fh>) {
-    print { $out_fh } $_ or syserr(_g('write changes file'));
-    chomp;
-
-    if (/^Files:/i) {
-	$infiles = 1;
-    } elsif ($infiles && /^\s+(.*)$/) {
-	$files .= " $1 ";
-    } elsif ($infiles && /^\S/) {
-	$infiles = 0;
-    }
-}
-
+$changes->parse($changes_fh, _g('parse changes file'));
+$changes->save($chg);
 close $changes_fh or subprocerr(_g('dpkg-genchanges'));
-close $out_fh or syserr(_g('write changes file'));
 
 if ($cleansource) {
     withecho(@rootcommand, @debian_rules, 'clean');
@@ -512,7 +500,7 @@ chdir('..') or syserr('chdir ..');
 withecho('dpkg-source', @source_opts, '--after-build', $dir);
 chdir($dir) or syserr("chdir $dir");
 
-printf "$Dpkg::PROGNAME: %s\n", describe_build($files);
+printf "$Dpkg::PROGNAME: %s\n", describe_build($changes->{'Files'});
 
 if ($check_command) {
     withecho($check_command, @check_opts, $chg);