commit:     975f55449d9ecbac24beb97081273946083168b4
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 23 17:44:30 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Fri Aug 23 18:10:20 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=975f5544

dev-libs/openssl: don't destroy user flags

Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Closes: https://bugs.gentoo.org/671016
Package-Manager: Portage-2.3.72, Repoman-2.3.17
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 dev-libs/openssl/openssl-1.0.2s-r1.ebuild   | 26 +++++++++++++++++---------
 dev-libs/openssl/openssl-1.0.2s-r200.ebuild | 26 +++++++++++++++++---------
 dev-libs/openssl/openssl-1.1.0k-r1.ebuild   | 22 ++++++++++++++--------
 dev-libs/openssl/openssl-1.1.1c-r1.ebuild   | 22 ++++++++++++++--------
 4 files changed, 62 insertions(+), 34 deletions(-)

diff --git a/dev-libs/openssl/openssl-1.0.2s-r1.ebuild 
b/dev-libs/openssl/openssl-1.0.2s-r1.ebuild
index a2cb9f7917e..b4902db7e53 100644
--- a/dev-libs/openssl/openssl-1.0.2s-r1.ebuild
+++ b/dev-libs/openssl/openssl-1.0.2s-r1.ebuild
@@ -187,7 +187,9 @@ multilib_src_configure() {
        [[ -z ${sslout} ]] && config="config"
 
        # Fedora hobbled-EC needs 'no-ec2m', 'no-srp'
-       echoit \
+       # Make sure user flags don't get added *yet* to avoid duplicated
+       # flags.
+       CFLAGS= LDFLAGS= echoit \
        ./${config} \
                ${sslout} \
                $(use cpu_flags_x86_sse2 || echo "no-sse2") \
@@ -216,17 +218,23 @@ multilib_src_configure() {
                || die
 
        # Clean out hardcoded flags that openssl uses
-       local CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
+       local DEFAULT_CFLAGS=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
                -e 's:^CFLAG=::' \
-               -e 's:-fomit-frame-pointer ::g' \
-               -e 's:-O[0-9] ::g' \
-               -e 's:-march=[-a-z0-9]* ::g' \
-               -e 's:-mcpu=[-a-z0-9]* ::g' \
-               -e 's:-m[a-z0-9]* ::g' \
+               -e 's:\(^\| \)-fomit-frame-pointer::g' \
+               -e 's:\(^\| \)-O[^ ]*::g' \
+               -e 's:\(^\| \)-march=[^ ]*::g' \
+               -e 's:\(^\| \)-mcpu=[^ ]*::g' \
+               -e 's:\(^\| \)-m[^ ]*::g' \
+               -e 's:^ *::' \
+               -e 's: *$::' \
+               -e 's: \+: :g' \
+               -e 's:\\:\\\\:g'
        )
+
+       # Now insert clean default flags with user flags
        sed -i \
-               -e "/^CFLAG/s|=.*|=${CFLAG} ${CFLAGS}|" \
-               -e "/^SHARED_LDFLAGS=/s|$| ${LDFLAGS}|" \
+               -e "/^CFLAG/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
+               -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \
                Makefile || die
 }
 

diff --git a/dev-libs/openssl/openssl-1.0.2s-r200.ebuild 
b/dev-libs/openssl/openssl-1.0.2s-r200.ebuild
index 281b169b64b..24f2b3a5663 100644
--- a/dev-libs/openssl/openssl-1.0.2s-r200.ebuild
+++ b/dev-libs/openssl/openssl-1.0.2s-r200.ebuild
@@ -191,7 +191,9 @@ multilib_src_configure() {
        [[ -z ${sslout} ]] && config="config"
 
        # Fedora hobbled-EC needs 'no-ec2m', 'no-srp'
-       echoit \
+       # Make sure user flags don't get added *yet* to avoid duplicated
+       # flags.
+       CFLAGS= LDFLAGS= echoit \
        ./${config} \
                ${sslout} \
                $(use cpu_flags_x86_sse2 || echo "no-sse2") \
@@ -220,17 +222,23 @@ multilib_src_configure() {
                || die
 
        # Clean out hardcoded flags that openssl uses
-       local CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
+       local DEFAULT_CFLAGS=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
                -e 's:^CFLAG=::' \
-               -e 's:-fomit-frame-pointer ::g' \
-               -e 's:-O[0-9] ::g' \
-               -e 's:-march=[-a-z0-9]* ::g' \
-               -e 's:-mcpu=[-a-z0-9]* ::g' \
-               -e 's:-m[a-z0-9]* ::g' \
+               -e 's:\(^\| \)-fomit-frame-pointer::g' \
+               -e 's:\(^\| \)-O[^ ]*::g' \
+               -e 's:\(^\| \)-march=[^ ]*::g' \
+               -e 's:\(^\| \)-mcpu=[^ ]*::g' \
+               -e 's:\(^\| \)-m[^ ]*::g' \
+               -e 's:^ *::' \
+               -e 's: *$::' \
+               -e 's: \+: :g' \
+               -e 's:\\:\\\\:g'
        )
+
+       # Now insert clean default flags with user flags
        sed -i \
-               -e "/^CFLAG/s|=.*|=${CFLAG} ${CFLAGS}|" \
-               -e "/^SHARED_LDFLAGS=/s|$| ${LDFLAGS}|" \
+               -e "/^CFLAG/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
+               -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \
                Makefile || die
 }
 

diff --git a/dev-libs/openssl/openssl-1.1.0k-r1.ebuild 
b/dev-libs/openssl/openssl-1.1.0k-r1.ebuild
index 937d3b7ed11..7bcd5d03e7e 100644
--- a/dev-libs/openssl/openssl-1.1.0k-r1.ebuild
+++ b/dev-libs/openssl/openssl-1.1.0k-r1.ebuild
@@ -176,7 +176,9 @@ multilib_src_configure() {
        # 'srp' was restricted until early 2017 as well.
        # "disable-deprecated" option breaks too many consumers.
        # Don't set it without thorough revdeps testing.
-       echoit \
+       # Make sure user flags don't get added *yet* to avoid duplicated
+       # flags.
+       CFLAGS= LDFLAGS= echoit \
        ./${config} \
                ${sslout} \
                $(use cpu_flags_x86_sse2 || echo "no-sse2") \
@@ -203,16 +205,20 @@ multilib_src_configure() {
                || die
 
        # Clean out hardcoded flags that openssl uses
-       # Fix quoting for sed
        local DEFAULT_CFLAGS=$(grep ^CFLAGS= Makefile | LC_ALL=C sed \
                -e 's:^CFLAGS=::' \
-               -e 's:-fomit-frame-pointer ::g' \
-               -e 's:-O[0-9] ::g' \
-               -e 's:-march=[-a-z0-9]* ::g' \
-               -e 's:-mcpu=[-a-z0-9]* ::g' \
-               -e 's:-m[a-z0-9]* ::g' \
-               -e 's:\\:\\\\:g' \
+               -e 's:\(^\| \)-fomit-frame-pointer::g' \
+               -e 's:\(^\| \)-O[^ ]*::g' \
+               -e 's:\(^\| \)-march=[^ ]*::g' \
+               -e 's:\(^\| \)-mcpu=[^ ]*::g' \
+               -e 's:\(^\| \)-m[^ ]*::g' \
+               -e 's:^ *::' \
+               -e 's: *$::' \
+               -e 's: \+: :g' \
+               -e 's:\\:\\\\:g'
        )
+
+       # Now insert clean default flags with user flags
        sed -i \
                -e "/^CFLAGS=/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
                -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \

diff --git a/dev-libs/openssl/openssl-1.1.1c-r1.ebuild 
b/dev-libs/openssl/openssl-1.1.1c-r1.ebuild
index 683c5707566..a3a0f2a2c06 100644
--- a/dev-libs/openssl/openssl-1.1.1c-r1.ebuild
+++ b/dev-libs/openssl/openssl-1.1.1c-r1.ebuild
@@ -172,7 +172,9 @@ multilib_src_configure() {
        # 'srp' was restricted until early 2017 as well.
        # "disable-deprecated" option breaks too many consumers.
        # Don't set it without thorough revdeps testing.
-       echoit \
+       # Make sure user flags don't get added *yet* to avoid duplicated
+       # flags.
+       CFLAGS= LDFLAGS= echoit \
        ./${config} \
                ${sslout} \
                $(use cpu_flags_x86_sse2 || echo "no-sse2") \
@@ -199,16 +201,20 @@ multilib_src_configure() {
                || die
 
        # Clean out hardcoded flags that openssl uses
-       # Fix quoting for sed
        local DEFAULT_CFLAGS=$(grep ^CFLAGS= Makefile | LC_ALL=C sed \
                -e 's:^CFLAGS=::' \
-               -e 's:-fomit-frame-pointer ::g' \
-               -e 's:-O[0-9] ::g' \
-               -e 's:-march=[-a-z0-9]* ::g' \
-               -e 's:-mcpu=[-a-z0-9]* ::g' \
-               -e 's:-m[a-z0-9]* ::g' \
-               -e 's:\\:\\\\:g' \
+               -e 's:\(^\| \)-fomit-frame-pointer::g' \
+               -e 's:\(^\| \)-O[^ ]*::g' \
+               -e 's:\(^\| \)-march=[^ ]*::g' \
+               -e 's:\(^\| \)-mcpu=[^ ]*::g' \
+               -e 's:\(^\| \)-m[^ ]*::g' \
+               -e 's:^ *::' \
+               -e 's: *$::' \
+               -e 's: \+: :g' \
+               -e 's:\\:\\\\:g'
        )
+
+       # Now insert clean default flags with user flags
        sed -i \
                -e "/^CFLAGS=/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
                -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \

Reply via email to