Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Nov 2021 21:16:53 GMT
From:      Joseph Mingrone <jrm@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 6ff48ecff7f5 - main - Mk/Scripts/qa.sh: Turn off pipefail when piping to grep -q
Message-ID:  <202111192116.1AJLGr95070474@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6ff48ecff7f5a179e16ee4aaf6e7affac69bb93e

commit 6ff48ecff7f5a179e16ee4aaf6e7affac69bb93e
Author:     Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2021-07-17 15:55:13 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2021-11-19 21:13:26 +0000

    Mk/Scripts/qa.sh: Turn off pipefail when piping to grep -q
    
    The pipeline
    
       readelf -d "${dep_file}" | grep -q SONAME
    
    can fail because grep -q closes the output early resulting sigpipe being
    sent to readelf.  Other possible solutions are to turn off pipefail for
    the file or remove the -q grep argument.
    
    Credit to ashish@ for the detective work to discover the root cause of
    this.
    
    Differential Revision: https://reviews.freebsd.org/D31211
    
    Reviewed by:    emaste
    Approved by:    bapt (portmgr) mat (portmgr)
---
 Mk/Scripts/qa.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh
index 13548ddb38c7..9caf01581b47 100644
--- a/Mk/Scripts/qa.sh
+++ b/Mk/Scripts/qa.sh
@@ -663,9 +663,13 @@ proxydeps() {
 
 				# Check that the .so we need has a SONAME
 				if [ "${dep_file_pkg}" != "${PKGORIGIN}" ]; then
+					# When grep -q finds a match it will close the pipe immediately.
+					# This may cause the test to fail when pipefail is turned on.
+					set +o pipefail
 					if ! readelf -d "${dep_file}" | grep -q SONAME; then
 						err "${file} is linked to ${dep_file} which does not have a SONAME.  ${dep_file_pkg} needs to be fixed."
 					fi
+					set -o pipefail
 				fi
 
 				# If we don't already depend on it, and we don't provide it



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111192116.1AJLGr95070474>