Преглед изворни кода

scripts: Use a variable instead of a literal string for the lock file

Guillem Jover пре 13 година
родитељ
комит
6aae0f7fbf
2 измењених фајлова са 12 додато и 10 уклоњено
  1. 6 5
      scripts/dpkg-distaddfile.pl
  2. 6 5
      scripts/dpkg-gencontrol.pl

+ 6 - 5
scripts/dpkg-distaddfile.pl

@@ -3,7 +3,7 @@
 # dpkg-distaddfile
 #
 # Copyright © 1996 Ian Jackson
-# Copyright © 2006-2008,2010,2012 Guillem Jover <guillem@debian.org>
+# Copyright © 2006-2008,2010,2012-2013 Guillem Jover <guillem@debian.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -78,9 +78,10 @@ my ($file, $section, $priority) = @ARGV;
 # Obtain a lock on debian/control to avoid simultaneous updates
 # of debian/files when parallel building is in use
 my $lockfh;
-sysopen($lockfh, 'debian/control', O_WRONLY) ||
-    syserr(_g('cannot write %s'), 'debian/control');
-file_lock($lockfh, 'debian/control');
+my $lockfile = 'debian/control';
+sysopen($lockfh, $lockfile, O_WRONLY) ||
+    syserr(_g('cannot write %s'), $lockfile);
+file_lock($lockfh, $lockfile);
 
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
 open(my $fileslistnew_fh, '>', "$fileslistfile.new") ||
@@ -103,4 +104,4 @@ rename("$fileslistfile.new", $fileslistfile) ||
     syserr(_g('install new files list file'));
 
 # Release the lock
-close($lockfh) || syserr(_g('cannot close %s'), 'debian/control');
+close($lockfh) || syserr(_g('cannot close %s'), $lockfile);

+ 6 - 5
scripts/dpkg-gencontrol.pl

@@ -4,7 +4,7 @@
 #
 # Copyright © 1996 Ian Jackson
 # Copyright © 2000,2002 Wichert Akkerman
-# Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
+# Copyright © 2006-2013 Guillem Jover <guillem@debian.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -356,9 +356,10 @@ for my $f (keys %remove) {
 # Obtain a lock on debian/control to avoid simultaneous updates
 # of debian/files when parallel building is in use
 my $lockfh;
-sysopen($lockfh, 'debian/control', O_WRONLY) ||
-    syserr(_g('cannot write %s'), 'debian/control');
-file_lock($lockfh, 'debian/control');
+my $lockfile = 'debian/control';
+sysopen($lockfh, $lockfile, O_WRONLY) ||
+    syserr(_g('cannot write %s'), $lockfile);
+file_lock($lockfh, $lockfile);
 
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
 open(my $fileslistnew_fh, '>', "$fileslistfile.new") ||
@@ -394,7 +395,7 @@ close($fileslistnew_fh) || syserr(_g('close new files list file'));
 rename("$fileslistfile.new", $fileslistfile) || syserr(_g('install new files list file'));
 
 # Release the lock
-close($lockfh) || syserr(_g('cannot close %s'), 'debian/control');
+close($lockfh) || syserr(_g('cannot close %s'), $lockfile);
 
 my $cf;
 my $fh_output;