Просмотр исходного кода

dpkg-genchanges: Use strftime() instead of unportable «date -R»

The latter is not specified in POSIX, and is not widely portable.

We have to temporarily set LC_TIME to 'C', to get the output specified
by RFC-2822.
Guillem Jover лет назад: 11
Родитель
Сommit
23a058153c
2 измененных файлов с 6 добавлено и 4 удалено
  1. 2 0
      debian/changelog
  2. 4 4
      scripts/dpkg-genchanges.pl

+ 2 - 0
debian/changelog

@@ -55,6 +55,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     - Assume a working C99 snprintf on SUS >= v3.
     - Do not try to run the va_copy configure check, just check that the
       symbol is available.
+  * Use strftime() instead of «date -R» in dpkg-genchanges, as the latter
+    is not specified by POSIX and is not widely portable.
 
  -- Guillem Jover <guillem@debian.org>  Tue, 09 Dec 2014 23:53:18 +0100
 

+ 4 - 4
scripts/dpkg-genchanges.pl

@@ -24,7 +24,7 @@ use warnings;
 
 use Carp;
 use Encode;
-use POSIX qw(:errno_h);
+use POSIX qw(:errno_h :locale_h);
 use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::Util qw(:list);
@@ -460,9 +460,9 @@ print { *STDERR } "$Dpkg::PROGNAME: $origsrcmsg\n"
 $fields->{'Format'} = $substvars->get('Format');
 
 if (!defined($fields->{'Date'})) {
-    chomp(my $date822 = `date -R`);
-    subprocerr('date -R') if $?;
-    $fields->{'Date'}= $date822;
+    setlocale(LC_TIME, 'C');
+    $fields->{'Date'} = POSIX::strftime('%a, %d %b %Y %T %z', localtime);
+    setlocale(LC_TIME, '');
 }
 
 $fields->{'Binary'} = join(' ', map { $_->{'Package'} } $control->get_packages());