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