1From eb51497e4b5799f8ab0277426d3e54414acb9d4b Mon Sep 17 00:00:00 2001 2From: Peter Korsgaard <peter@korsgaard.com> 3Date: Thu, 20 Nov 2014 13:24:59 +0100 4Subject: [PATCH] Misc/python-config.sh.in: ensure sed invocations only match 5 beginning of strings 6 7The build/real prefix handling using sed breaks if build != real and the 8standard include / lib directories are used ($prefix/include and $prefix/lib). 9 10E.G. 11 12prefix_build="/usr", libdir="$prefix/lib", includedir="$prefix/include". 13 14If this gets installed with make DESTDIR="/foo" install, then we end up with 15prefix_real = prefix = "/foo/usr" as expected, but 16includedir="/foo/foo/usr/include" and libdir="/foo/foo/usr/lib" because of 17the double sed invocation (prefix is already expanded). Work around it by 18ensuring we only match the beginning of the string. 19 20Submitted upstream: http://bugs.python.org/issue22907 21 22Signed-off-by: Peter Korsgaard <peter@korsgaard.com> 23--- 24 Misc/python-config.sh.in | 13 +++++++------ 25 1 file changed, 7 insertions(+), 6 deletions(-) 26 27diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in 28index 2602fe24c0..a1bc3cd5f7 100644 29--- a/Misc/python-config.sh.in 30+++ b/Misc/python-config.sh.in 31@@ -24,18 +24,19 @@ installed_prefix () 32 echo $RESULT 33 } 34 35+prefix_build="@prefix@" 36 prefix_real=$(installed_prefix "$0") 37 38 # Use sed to fix paths from their built-to locations to their installed-to 39 # locations. Keep prefix & exec_prefix using their original values in case 40 # they are referenced in other configure variables, to prevent double 41 # substitution, issue #22140. 42-prefix="@prefix@" 43-exec_prefix="@exec_prefix@" 44+prefix=$(echo "$prefix_build" | sed "s#^$prefix_build#$prefix_real#") 45+exec_prefix=$(echo "$exec_prefix_build" | sed "s#^$exec_prefix_build#$prefix_real#") 46 exec_prefix_real=${prefix_real} 47-includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#") 48-libdir=$(echo "@libdir@" | sed "s#$prefix#$prefix_real#") 49-CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix#$prefix_real#") 50+includedir=$(echo "@includedir@" | sed "s#^$prefix_build#$prefix_real#") 51+libdir=$(echo "@libdir@" | sed "s#^$prefix_build#$prefix_real#") 52+CFLAGS=$(echo "@CFLAGS@" | sed "s#^$prefix_build#$prefix_real#") 53 VERSION="@VERSION@" 54 LIBM="@LIBM@" 55 LIBC="@LIBC@" 56@@ -49,7 +50,7 @@ OPT="@OPT@" 57 PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" 58 LDVERSION="@LDVERSION@" 59 LIBDEST=${prefix_real}/lib/python${VERSION} 60-LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") 61+LIBPL=$(echo "@LIBPL@" | sed "s#^$prefix_build#$prefix_real#") 62 SO="@EXT_SUFFIX@" 63 PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" 64 INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" 65-- 662.25.1 67 68