0010-Misc-python-config.sh.in-ensure-sed-invocations-only.patch 2.6 KB

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