From: Mathieu Parent Date: Sat, 24 Aug 2019 09:52:10 +0000 (+0200) Subject: Fix architecture detection with recent dpkg-buildpackage versions X-Git-Tag: 0.10~7 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=1b2ee66;p=blhc%2Fblhc.git Fix architecture detection with recent dpkg-buildpackage versions [sr: Taken from patch in Debian package 0.09-2 and modified slightly; added a test.] --- diff --git a/NEWS b/NEWS index 89b3906..d550adc 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Version 0.XX ------------ - Sync architecture specific hardening support with dpkg 1.19.7. +- Fix architecture detection with recent dpkg-buildpackage versions; reported + by Ross Vandegrift, patch from Mathieu Parent (Debian bug #929503). Version 0.09 diff --git a/bin/blhc b/bin/blhc index 1794412..4300027 100755 --- a/bin/blhc +++ b/bin/blhc @@ -954,6 +954,10 @@ foreach my $file (@ARGV) { # Detect architecture automatically unless overridden. if (not $arch + and index($line, 'dpkg-buildpackage: info: host architecture ') == 0) { + $arch = substr $line, 43, -1; # -1 to ignore '\n' at the end + # Older versions of dpkg-buildpackage + } elsif (not $arch and index($line, 'dpkg-buildpackage: host architecture ') == 0) { $arch = substr $line, 37, -1; # -1 to ignore '\n' at the end diff --git a/t/logs/dpkg-buildpackage-architecture-new b/t/logs/dpkg-buildpackage-architecture-new new file mode 100644 index 0000000..bfcdf49 --- /dev/null +++ b/t/logs/dpkg-buildpackage-architecture-new @@ -0,0 +1,5 @@ +dpkg-buildpackage: info: source package test +dpkg-buildpackage: info: host architecture ia64 + +gcc -D_FORTIFY_SOURCE=2 -g -O2 -fPIE -Wformat -Wformat-security -Werror=format-security -Wall -c test.c +gcc -fPIE -pie -o test test.o diff --git a/t/tests.t b/t/tests.t index b40bb1b..2e2b9d7 100644 --- a/t/tests.t +++ b/t/tests.t @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 236; +use Test::More tests => 238; sub is_blhc { @@ -857,6 +857,11 @@ LDFLAGS missing (-pie -Wl,-z,relro): gcc -fPIE -o test test.o is_blhc 'dpkg-buildpackage-architecture-old', '', 0, ''; +# architecture in newer buildd logs + +is_blhc 'dpkg-buildpackage-architecture-new', '', 0, + ''; + # correct architecture detection