Skip to contentSkip to conversation

symlink loop for /lib64/libhandle.so

DISCUSSION Jan Ťulák 4 participants 13 messages Jul 9, 2014 – Sep 13, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

when I install xfsprogs from Git, I get a symlink loop:

$ ls -l /lib64/libhandle.so
lrwxrwxrwx. 1 root root 19 Jul  9 09:56 /lib64/libhandle.so
-> /lib64/libhandle.so

I guess it should point to libhandle.so.1.

I'm using this repo: git://oss.sgi.com/xfs/cmds/xfsprogs
And just the usual "make && sudo make install" commands.

Also, I have made sure the libhandle library was not installed before this installation.

Used HW/SW:
- A virtual machine in KVM.
- Fedora 20 x86_64

If it not an intended behavior, I can try to find the source of the bug and make a patch (I'm new here :-).

Thanks,
Jan Tulak

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 17 lines · Jan Ťulák

Hi,

when I install xfsprogs from Git, I get a symlink loop:

$ ls -l /lib64/libhandle.so
lrwxrwxrwx. 1 root root 19 Jul  9 09:56 /lib64/libhandle.so
-> /lib64/libhandle.so

I guess it should point to libhandle.so.1.

I'm using this repo: git://oss.sgi.com/xfs/cmds/xfsprogs
And just the usual "make && sudo make install" commands.

Also, I have made sure the libhandle library was not installed before this installation.

Quoted 7 lines

Used HW/SW:
- A virtual machine in KVM.
- Fedora 20 x86_64

If it not an intended behavior, I can try to find the source of the bug and make a patch (I'm new here :-).

I can reproduce this on fedora rawhide via 'make install-qa.' This is not intended behavior. I couldn't tell you what the problem is, but patches are certainly welcome. :)

Brian

Quoted 7 lines

Thanks,
Jan Tulak

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 7 lines · Brian Foster
Quoted 3 lines

If it not an intended behavior, I can try to find the source of the bug and make a patch (I'm new here :-).

I can reproduce this on fedora rawhide via 'make install-qa.' This is not intended behavior. I couldn't tell you what the problem is, but patches are certainly welcome. :)

This sounds like an fallout from the /lib -> /usr/lib symlink mess in Fedora. Might be worth taking a look at the specfile how Eric worked around that for the RPM..

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Brian Foster
Quoted 2 lines

If it not an intended behavior, I can try to find the source of the bug and make a patch (I'm new here :-).

Quoted 7 lines
Quoted 3 lines

I can reproduce this on fedora rawhide via 'make install-qa.' This is not intended behavior. I couldn't tell you what the problem is, but patches are certainly welcome. :)

This sounds like an fallout from the /lib -> /usr/lib symlink mess in Fedora. Might be worth taking a look at the specfile how Eric worked around that for the RPM..

Yes. I'm trying to find out what exactly is causing the difference. I have tried to use the same tarball which is used in Eric's RPM and it did the same thing as the git version, so it is not something that would change since his last build.

So far It seems that if I add DIST_ROOT, PKG_ROOT_SBIN_DIR and PKG_ROOT_LIB_DIR arguments to the "make install-qa" commandm it works OK and the libhandle.so placed in PKG_ROOT_LIB_DIR points correctly to libandle.so.1.

Does this makes some sense to you?

Jan Tulak

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 7 lines · Jan Ťulák
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Brian Foster
Quoted 2 lines

If it not an intended behavior, I can try to find the source of the bug and make a patch (I'm new here :-).

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

I can reproduce this on fedora rawhide via 'make install-qa.' This is not intended behavior. I couldn't tell you what the problem is, but patches are certainly welcome. :)

This sounds like an fallout from the /lib -> /usr/lib symlink mess in Fedora. Might be worth taking a look at the specfile how Eric worked around that for the RPM..

I'm pretty sure I used a terrible hack in the specfile... ;)

Quoted 4 lines

Yes. I'm trying to find out what exactly is causing the difference. I have tried to use the same tarball which is used in Eric's RPM and it did the same thing as the git version, so it is not something that would change since his last build.

The tarball I use in the RPM is exactly what is provided on oss.sgi.com, there's nothing different in there for Fedora.

Quoted 6 lines

So far It seems that if I add DIST_ROOT, PKG_ROOT_SBIN_DIR and PKG_ROOT_LIB_DIR arguments to the "make install-qa" commandm it works OK and the libhandle.so placed in PKG_ROOT_LIB_DIR points correctly to libandle.so.1.

Does this makes some sense to you?

Here's what the current RPM build does; I don't claim that it's elegant or beautiful:

%install
rm -rf $RPM_BUILD_ROOT

make V=1 DIST_ROOT=$RPM_BUILD_ROOT install install-dev install-qa \
        PKG_ROOT_SBIN_DIR=%{_sbindir} PKG_ROOT_LIB_DIR=%{_libdir}

so that sounds like what you're doing, too.

FWIW, that above change also removed this old cruft, and I don't remember what it was for:

-# fix up symlink to be correct
-rm -f $RPM_BUILD_ROOT/%{_libdir}/libhandle.so
-ln -s ../../%{_lib}/libhandle.so.1 $RPM_BUILD_ROOT/%{_libdir}/libhandle.so

so I'm probably guilty of hacking stuff up too much for Fedora, vs fixing it upstream... :(

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 9 lines · Eric Sandeen

Here's what the current RPM build does; I don't claim that it's elegant or beautiful:

%install
rm -rf $RPM_BUILD_ROOT

make V=1 DIST_ROOT=$RPM_BUILD_ROOT install install-dev install-qa \
        PKG_ROOT_SBIN_DIR=%{_sbindir} PKG_ROOT_LIB_DIR=%{_libdir}

so that sounds like what you're doing, too.

I think I found it. In short: On Fedora, /lib64 is a symlink into /usr/lib64, but "install/buildmacros" script thinks it as two different directories and mess it. Proposed solution: better condition on line 79 to avoid symlink changes.

Long version:

I looked for the variables and maybe found something more in files "include/buildmacros" and "install-sh". In the buildmacros file on line around 80 is command:

../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so;

It is invoked just once and its arguments are [/lib64/libhandle.so] and [/usr/lib64/libhandle.so] (in this order). This is at the end translated into this call in "install-sh" on line 172:

ln -s -f /lib64/libhandle.so //usr/lib64/libhandle.so

It seems to be OK, , but when I put a "ls -li" before and after this command on line 172, this is what I got (I just added few echos):

----------------
before:
1668 lrwxrwxrwx. 1 root root 14 Jul 11 10:36 /lib64/libhandle.so -> libhandle.so.1
1668 lrwxrwxrwx. 1 root root 14 Jul 11 10:36 //usr/lib64/libhandle.so -> libhandle.so.1
......
ln -s -f /lib64/libhandle.so //usr/lib64/libhandle.so
......
after:
1668 lrwxrwxrwx. 1 root root 19 Jul 11 10:36 /lib64/libhandle.so -> /lib64/libhandle.so
1668 lrwxrwxrwx. 1 root root 19 Jul 11 10:36 //usr/lib64/libhandle.so -> /lib64/libhandle.so
-----------

Then I have done "ls -l /" and found the reason:
lrwxrwxrwx. 1 root root 9 Dec 12 2013 lib64 -> usr/lib64

So the loop is because on Fedora, /lib64 and /usr/lib64 are the same directory. The "buildmacros" script does some check before doing the symlinking, but it just checks the paths as strings. I think that a better condition on line 80 of "include/buildmacros" file should fix it. I tried to make a new condition and it works, but I'm not sure about portability of using the "$(shell ...)" extension of GNU Make. Is there some more portable way how to do it and keep the condition short?

Proposed condition:

if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)"\
-a "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))" != "x$(PKG_LIB_DIR)"\
-a "x$(shell readlink -f $(PKG_LIB_DIR))" != "x$(PKG_ROOT_LIB_DIR)";\
then \

Instead of:

if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)"; then \

And by the way: It seems to me that the command on line 83 in "buildmacros" has swapped arguments. In two other symlinks around, PKG_LIB_DIR and PKG_ROOT_LIB_DIR for .a and .la files are in other order. Is this all right?

Jan Tulak

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
Quoted 4 lines · Jan Ťulák

I think I found it. In short: On Fedora, /lib64 is a symlink into /usr/lib64, but "install/buildmacros" script thinks it as two different directories and mess it. Proposed solution: better condition on line 79 to avoid symlink changes.

Just a correction, the file is in "include" directory, not in "install".

And I have created a bug report and added the proposed change as a
patch: http://oss.sgi.com/bugzilla/show_bug.cgi?id=1059

Jan Tulak

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw

2014-07-14 10:26 GMT+02:00 Christoph Hellwig <[email protected]>:

Quoted 5 lines

Can you just send the properly formatted and signed off patch to the list? That's the usual process for XFS changes and makes everyones life simpler.

I hope this is all right.
And sorry Chris, I mistakenly replied just to you instead of into the mailing list.

Reported-by Jan Tulak <jan at tulak.me>
Signed-off-by Jan Tulak <jan at tulak.me>

---
include/buildmacros | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
include/buildmacros +4 -1
index 7a01880..657b82a 100644
@@ -76,7 +76,11 @@ INSTALL_LTLIB_DEV = \
        ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_LIB_DIR)/$(LIBNAME).la ; \
        ../$(INSTALL) -m 755 -d $(PKG_ROOT_LIB_DIR); \
        ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_ROOT_LIB_DIR); \
-       if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)" ; then \
+       if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)"\
+       -a "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))" != "x$(PKG_LIB_DIR)"\
+       -a "x$(shell readlink -f $(PKG_LIB_DIR))" != "x$(PKG_ROOT_LIB_DIR)"\
+       -a "x$(shell readlink -f $(PKG_LIB_DIR))" != "x$(shell

readlink -f $(PKG_ROOT_LIB_DIR))";\

+       then \
        ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a
$(PKG_ROOT_LIB_DIR)/$(LIBNAME)
.a; \
        ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la
$(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
        ../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so

$(PKG_LIB_DIR)/$(LIBNAME).so; \

2014-07-14 10:26 GMT+02:00 Christoph Hellwig <[email protected]>:

Quoted 8 lines · Jan ??ul??k
Quoted 2 lines

And I have created a bug report and added the proposed change as a
patch: http://oss.sgi.com/bugzilla/show_bug.cgi?id=1059

Can you just send the properly formatted and signed off patch to the list? That's the usual process for XFS changes and makes everyones life simpler.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#9 lore raw

Hi Jan,

there were still some small isues with the patch format, I've attached a version of your patch that has the expected format.

Note that I also changed it to only check the canonical names instead of testing the passed in one and the one readlink was called on. This should be enough I think, but please test that it still works for you.

Thanks for tracking this down!

From: Jan Tulak <[email protected]>
Subject: [PATCH] libhandle: fix instalation for symlinked /usr

Canonicalize the pathnames for PKG_LIB_DIR and PKG_ROOT_LIB_DIR before checking if they are the same. This is required for Fedora which doesn't have a separate /usr/lib directory anymore.

include/buildmacros +5 -4
index 7a01880..4e4e8fa 100644
@@ -76,10 +76,11 @@ INSTALL_LTLIB_DEV = \
 	../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_LIB_DIR)/$(LIBNAME).la ; \
 	../$(INSTALL) -m 755 -d $(PKG_ROOT_LIB_DIR); \
 	../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_ROOT_LIB_DIR); \
-	if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)" ; then \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
-	../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
+	if [ "x$(shell readlink -f $(PKG_LIB_DIR))" != \
+	     "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))"; ]; then \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
+		../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
 	fi
 else
 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#10 lore raw
Quoted 11 lines · Christoph Hellwig

Hi Jan,

there were still some small isues with the patch format, I've attached a version of your patch that has the expected format.

Note that I also changed it to only check the canonical names instead of testing the passed in one and the one readlink was called on. This should be enough I think, but please test that it still works for you.

Thanks for tracking this down!
<libhandle.diff>

Hi Christoph,

thanks for the checking. This version works too, so it can be used.

I’m glad I could help.

Jan
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#11 lore raw
In reply to Christoph Hellwig

Dave, can you pick up this patch for xfsprogs?

Quoted 42 lines · Christoph Hellwig

Hi Jan,

there were still some small isues with the patch format, I've attached a version of your patch that has the expected format.

Note that I also changed it to only check the canonical names instead of testing the passed in one and the one readlink was called on. This should be enough I think, but please test that it still works for you.

Thanks for tracking this down!

From: Jan Tulak <[email protected]>
Subject: [PATCH] libhandle: fix instalation for symlinked /usr

Canonicalize the pathnames for PKG_LIB_DIR and PKG_ROOT_LIB_DIR before checking if they are the same. This is required for Fedora which doesn't have a separate /usr/lib directory anymore.

include/buildmacros +5 -4
index 7a01880..4e4e8fa 100644
@@ -76,10 +76,11 @@ INSTALL_LTLIB_DEV = \
 	../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_LIB_DIR)/$(LIBNAME).la ; \
 	../$(INSTALL) -m 755 -d $(PKG_ROOT_LIB_DIR); \
 	../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_ROOT_LIB_DIR); \
-	if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)" ; then \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
-	../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
+	if [ "x$(shell readlink -f $(PKG_LIB_DIR))" != \
+	     "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))"; ]; then \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
+		../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
 	fi
 else
 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#12 lore raw

ping?

Quoted 45 lines · Christoph Hellwig

Dave, can you pick up this patch for xfsprogs?

Quoted 41 lines · Christoph Hellwig

Hi Jan,

there were still some small isues with the patch format, I've attached a version of your patch that has the expected format.

Note that I also changed it to only check the canonical names instead of testing the passed in one and the one readlink was called on. This should be enough I think, but please test that it still works for you.

Thanks for tracking this down!

From: Jan Tulak <[email protected]>
Subject: [PATCH] libhandle: fix instalation for symlinked /usr

Canonicalize the pathnames for PKG_LIB_DIR and PKG_ROOT_LIB_DIR before checking if they are the same. This is required for Fedora which doesn't have a separate /usr/lib directory anymore.

include/buildmacros +5 -4
index 7a01880..4e4e8fa 100644
@@ -76,10 +76,11 @@ INSTALL_LTLIB_DEV = \
 	../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_LIB_DIR)/$(LIBNAME).la ; \
 	../$(INSTALL) -m 755 -d $(PKG_ROOT_LIB_DIR); \
 	../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_ROOT_LIB_DIR); \
-	if test "x$(PKG_LIB_DIR)" != "x$(PKG_ROOT_LIB_DIR)" ; then \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
-	../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
-	../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
+	if [ "x$(shell readlink -f $(PKG_LIB_DIR))" != \
+	     "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))"; ]; then \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
+		../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
+		../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
 	fi
 else
 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
Quoted 6 lines
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---

---end quoted text---

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs