[dpkg] 152/187: dpkg-gencontrol: Delegate open/close operations to save() method
Reiner Herrmann
reiner at reiner-h.de
Sun Nov 6 12:46:39 UTC 2016
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository dpkg.
commit 158f94e8cdc9aed56d29c625ab2a3edfcf30c8b7
Author: Guillem Jover <guillem at debian.org>
Date: Wed Nov 2 01:31:09 2016 +0100
dpkg-gencontrol: Delegate open/close operations to save() method
---
scripts/dpkg-gencontrol.pl | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index 9157e94..7d7386d 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -369,6 +369,10 @@ for my $f (keys %remove) {
$fields->apply_substvars($substvars);
+if (not $stdout) {
+ $outputfile //= "$packagebuilddir/DEBIAN/control";
+}
+
my $sversion = $fields->{'Version'};
$sversion =~ s/^\d+://;
$forcefilename //= sprintf('%s_%s_%s.%s', $fields->{'Package'}, $sversion,
@@ -408,22 +412,13 @@ rename("$fileslistfile.new", $fileslistfile)
# Release the lock
close($lockfh) or syserr(g_('cannot close %s'), $lockfile);
-my $cf;
-my $fh_output;
-if (!$stdout) {
- $cf = $outputfile // "$packagebuilddir/DEBIAN/control";
- open($fh_output, '>', "$cf.new")
- or syserr(g_("cannot open new output control file '%s'"), "$cf.new");
+if ($stdout) {
+ $fields->output(\*STDOUT);
} else {
- $fh_output = \*STDOUT;
-}
-
-$fields->output($fh_output);
+ $fields->save("$outputfile.new");
-if (!$stdout) {
- close($fh_output) or syserr(g_('cannot close %s'), "$cf.new");
- rename("$cf.new", "$cf")
- or syserr(g_("cannot install output control file '%s'"), $cf);
+ rename "$outputfile.new", $outputfile
+ or syserr(g_("cannot install output control file '%s'"), $outputfile);
}
$substvars->warn_about_unused();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list