Skip to content

Commit

Permalink
[all] Test trailing slash patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ileanadumitrescu95 committed Oct 24, 2024
1 parent 04f646b commit 1c49c71
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ git clone --depth 2 -b "$branch" https://git.savannah.gnu.org/git/"$package".git
git clone --depth 1 https://git.savannah.gnu.org/git/gnulib.git

# Apply patches.
# (cd "$package" && patch -p1 < ../patches/<patch>)
(cd "$package" && patch -p1 < ../patches/0001-ltmain.in-Handle-trailing-slashes-on-install-command.patch && \
patch -p1 < ../patches/0002-libtool-Test-trailing-slash-in-destination.patch)

export GNULIB_SRCDIR=`pwd`/gnulib
cd "$package"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 05f0f2faf4cb3184dcf0ea14ed63f9f8d73accf6 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Sat, 16 Apr 2022 18:58:15 +0100
Subject: [PATCH 1/2] ltmain.in: Handle trailing slashes on install commands

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.

* build-aux/ltmain.in: Strip trailing slashes on install commands.
---
build-aux/ltmain.in | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 4e2a63fd..be94b032 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -2405,8 +2405,15 @@ 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.45.2

67 changes: 67 additions & 0 deletions patches/0002-libtool-Test-trailing-slash-in-destination.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From 6ed296d6d796912647d7a2ccd10e7e51faf93386 Mon Sep 17 00:00:00 2001
From: Ileana Dumitrescu <ileanadumitrescu95@gmail.com>
Date: Thu, 24 Oct 2024 20:43:03 +0300
Subject: [PATCH 2/2] libtool: Test trailing slash in destination

This test is added to ensure path comparisons pass when
installing to a destination, specifically when there is a
trailing slash in the destination.

* tests/destdir.at: Add test for trailing slash in destination.
---
tests/destdir.at | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

diff --git a/tests/destdir.at b/tests/destdir.at
index f109f149..df0d8ba8 100644
--- a/tests/destdir.at
+++ b/tests/destdir.at
@@ -137,4 +137,45 @@ fi

AT_CLEANUP

+AT_SETUP([trailing slash in destination])
+AT_KEYWORDS([libtool])
+
+AT_DATA([configure.ac],
+[[
+AC_INIT([foo], [0])
+AM_INIT_AUTOMAKE([foreign])
+AC_PROG_CC
+LT_INIT
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_MACRO_DIRS([m4])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.am],
+[[
+lib_LTLIBRARIES = libbase.la
+libbase_la_SOURCES = foo.c
+# Path with trailing slash for test
+bardir = /usr/lib/bar/extensions/
+bar_LTLIBRARIES = foo.la
+foo_la_SOURCES = foo.c
+foo_la_LDFLAGS = -module -avoid-version
+foo_la_LIBADD = libbase.la
+]])
+
+AT_DATA([foo.c],
+[[
+int unused;
+]])
+
+LT_AT_LIBTOOLIZE([--force --copy --install])
+LT_AT_AUTORECONF([--force --verbose --install])
+LT_AT_CONFIGURE([])
+# Use local 'tmp' directory as destination
+sysroot=`pwd`/tmp
+AT_CHECK([$MAKE], [0], [ignore], [ignore])
+AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore])
+
+AT_CLEANUP
+
m4_popdef([_LT_DIRSETUP])
--
2.45.2

0 comments on commit 1c49c71

Please sign in to comment.