Patchwork fixincludes: handle symlinks with multiple slashes

login
register
mail settings
Submitter Mike Frysinger
Date Dec. 25, 2012, 8:32 a.m.
Message ID <1356424326-17800-1-git-send-email-vapier@gentoo.org>
Download mbox | patch
Permalink /patch/208103/
State New
Headers show

Comments

Mike Frysinger - Dec. 25, 2012, 8:32 a.m.
If you have a symlink in /usr/include like so:
	/usr/include/oracle/10.2.0.3/client -> //usr/lib64/oracle/10.2.0.3/client/include

The fixincludes script gets confused and tries to write to /usr/include.
This is because the logic to walk the path names strips just one slash.
Tweak the sed statement to consume all duplicate slashes instead.

Before this change (and the aforementioned symlink):

$ rm -rf output
$ ./fixinc.sh $PWD/output 2>/dev/null
Fixing headers into /var/tmp/portage/sys-devel/gcc-4.5.4/work/build/build-x86_64-pc-linux-gnu/fixincludes/output for x86_64-pc-linux-gnu target
Forbidden identifiers:
Finding directories and links to directories
 Searching /usr/include/.
 Searching /usr/include/./quicktime
 Searching /usr/include/./schily/scg
 Searching /usr/include/./libpq
 Searching /usr/include/./libunrar
 Searching /usr/include/./cryptopp
 Searching /usr/include/./oracle/10.2.0.3/client
 Searching /usr/include/./postgresql
 Searching /usr/include/./scsilib
Making symbolic directory links
Fixing directory /usr/include into /var/tmp/portage/sys-devel/gcc-4.5.4/work/build/build-x86_64-pc-linux-gnu/fixincludes/output
Fixing directory /usr/include/oracle/10.2.0.3/client into /usr/include
Cleaning up unneeded directories:
fixincludes is done

Notice that second "Fixing directory" is wrong -- it shouldn't be in /usr.

After this fix, that second line correctly reads:
Fixing directory /usr/include/oracle/10.2.0.3/client into /var/tmp/portage/sys-devel/gcc-4.5.4/work/build/build-x86_64-pc-linux-gnu/fixincludes/output/root/usr/lib64/oracle/10.2.0.3/client/include

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

2012-12-25  Mike Frysinger  <vapier@gentoo.org>

	* fixinc.in (dirname): Change sed from 's|[^/]*/||' to
	's|[^/]*//*||'.
---
 fixincludes/fixinc.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in
index f7b8d8f..202fff3 100755
--- a/fixincludes/fixinc.in
+++ b/fixincludes/fixinc.in
@@ -344,7 +344,7 @@  if $LINKS; then
             mkdir $component >/dev/null 2>&1
             cd $component
             dirmade=$dirmade/$component
-            dirname=`echo $dirname | sed -e 's|[^/]*/||'`
+            dirname=`echo $dirname | sed -e 's|[^/]*//*||'`
           done
         fi