[PATCH v2 02/12] ltmain.in: Handle trailing slashes on install commands correctly

Sam James <[email protected]> Sat, 16 Apr 2022 18:58:15 +0100
Newsgroups gmane.comp.gnu.libtool.patches
Message-ID <[email protected]>
From: Richard Purdie <[email protected]>

A command like:

libtool --mode=install /usr/bin/install -c gck-roots-store-standalone.la '/image/usr/lib/gnome-keyring/standalone/'

where the path ends with a trailing slash currently fails. This occurs in
software like gnome-keyring or pulseaudio and is because the comparision
code doesn't see the paths as equal. Strip both paths to ensure this works
reliably.

Signed-off-by: Richard Purdie <[email protected]>
---
 build-aux/ltmain.in | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index d3a03a53..bc0a3950 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -2381,8 +2381,14 @@ func_mode_install ()
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
+	  # Strip any trailing slash from the destination.
+	  func_stripname '' '/' "$libdir"
+	  destlibdir=$func_stripname_result
+	  func_stripname '' '/' "$destdir"
+	  s_destdir=$func_stripname_result
+
 	  # Determine the prefix the user has applied to our future dir.
-	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+	  inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"`
 
 	  # Don't allow the user to place us outside of our expected
 	  # location b/c this prevents finding dependent libraries that
-- 
2.35.1