This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

commit 43dc5fa95f5241ce790b727c405f96caaad12c19
Author: Guillem Jover <guil...@debian.org>
Date:   Sat May 5 02:50:03 2018 +0200

    Dpkg::Changelog::Parse: Stop using tail(1) to read the end of the file
    
    Instead of relying on the tail command, simply read the end of the
    file ourselves, assuming a packed set of 80 character lines, reading
    4096 bytes before the end, implies around 51 lines, which is close
    to the 40 lines currently used.
    
    This should be both faster and should improve portability, because even
    if we are using the POSIX -n option, some systems do not have a POSIX
    compliant tail(1) on the default path, such as Solaris.
    
    Analysis-by: James Clarke <jrt...@debian.org>
---
 debian/changelog                |  4 ++++
 scripts/Dpkg/Changelog/Parse.pm | 10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 8eb639c..36b5594 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -99,6 +99,10 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
       alias. Emit a specific perl warning until 1.20.x so that users can check
       whether the semantic change has any impact on the code, which can then
       be quiesced. Closes: #895004
+    - Dpkg::Changelog::Parse: When detecting the changelog format, read the
+      last 4KiB of the file instead of using «tail -n40», which should be
+      both faster and more portable, as the default tail(1) is not POSIX
+      compliant on all systems (c.f. Solaris).
   * Documentation:
     - Update gettext minimal version in README.
     - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph.
diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm
index e107dcf..28bb689 100644
--- a/scripts/Dpkg/Changelog/Parse.pm
+++ b/scripts/Dpkg/Changelog/Parse.pm
@@ -56,12 +56,16 @@ sub _changelog_detect_format {
     if ($file ne '-') {
         local $_;
 
-        open my $format_fh, '-|', 'tail', '-n', '40', $file
-            or syserr(g_('cannot create pipe for %s'), 'tail');
+        open my $format_fh, '<', $file
+            or syserr(g_('cannot open file %s'), $file);
+        if (-s $format_fh > 4096) {
+            seek $format_fh, -4096, 2
+                or syserr(g_('cannot seek into file %s'), $file);
+        }
         while (<$format_fh>) {
             $format = $1 if m/\schangelog-format:\s+([0-9a-z]+)\W/;
         }
-        close $format_fh or subprocerr(g_('tail of %s'), $file);
+        close $format_fh;
     }
 
     return $format;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/dpkg/dpkg.git

Reply via email to