Skip to contentSkip to conversation

Hotfix for make install

PATCH New Zdenek Kabelac 1 participant 4 messages Apr 15, 2010

lore
Share & tools
lore
#0 lore raw

cover Hotfix for make install

Patchset fixes relative linkage of libraries between usrlibdir and libdir.
Also fixes usage of DESTDIR for infodir and mandir.

Zdenek Kabelac (3):
Hotfix: $(datarootdir) has already $(DESTDIR)
Script to create proper relative path
Use relative paths for creating links .so

 make.tmpl.in       |    7 ++++---
 scripts/relpath.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 tools/Makefile.in  |    2 +-
 3 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100755 scripts/relpath.sh
#1 lore raw

PATCH 1/3 Hotfix: $(datarootdir) has already $(DESTDIR)

FIXME: We should use DESTDIR only for $(INSTALL) commands to allow user-override of commonly known variables and still be able to honor $(DESTDIR).

---
 make.tmpl.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
make.tmpl.in +2 -2
index 87e8505..a6b00fc 100644
@@ -57,8 +57,8 @@ usrlibdir = $(DESTDIR)@usrlibdir@
 sbindir = $(DESTDIR)@sbindir@
 usrsbindir = $(DESTDIR)@usrsbindir@
 datarootdir = $(DESTDIR)@datarootdir@
-infodir = $(DESTDIR)@infodir@
-mandir = $(DESTDIR)@mandir@
+infodir = $(datarootdir)/info
+mandir = $(datarootdir)/man
 localedir = $(DESTDIR)@LOCALEDIR@
 staticdir = $(DESTDIR)@STATICDIR@
 udevdir = $(DESTDIR)@udevdir@
Signature · 1 line
1.7.0.1
#2 lore raw

PATCH 2/3 Script to create proper relative path

In reply to Zdenek Kabelac

This script takes two real paths and calculates relative path between them. Script is used for creation of relative path /usr/lib/lib.so -> /lib/lib.so.1.2

i.e. relpath.sh a/b/c/d a/b/e/f/g/g -> ../../e/f/g/g/

---
 scripts/relpath.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100755 scripts/relpath.sh
scripts/relpath.sh new file +49 -0
new file mode 100755
index 0000000..3e79a0d
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# usage: relpath from to
+#
+# modified script from to avoid print of ./:
+# http://stackoverflow.com/questions/2564634/bash-convert-absolute-path-into-relative-path-given-a-current-directory 
+# 
+
+from=${1%%/}
+to=${2%%/}
+
+test "$from" == "$to" && exit
+
+IFS="/"
+
+current=($from)
+absolute=($to)
+
+abssize=${#absolute[@]}
+cursize=${#current[@]}
+
+while [[ ${absolute[$level]} == ${current[$level]} ]]
+do
+    (( level++ ))
+    if (( level > abssize || level > cursize ))
+    then
+        break
+    fi
+done
+
+for ((i = level; i < cursize; i++))
+do
+    if ((i > level))
+    then
+        newpath=$newpath"/"
+    fi
+    newpath=$newpath".."
+done
+
+for ((i = level; i < abssize; i++))
+do
+    if [[ -n $newpath ]]
+    then
+        newpath=$newpath"/"
+    fi
+    newpath=$newpath${absolute[i]}
+done
+
+echo "$newpath/"
Signature · 1 line
1.7.0.1
#3 lore raw

PATCH 3/3 Use relative paths for creating links .so

In reply to Zdenek Kabelac

Using relpath.sh to generate link path between libs.

---
 make.tmpl.in      |    3 ++-
 tools/Makefile.in |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
make.tmpl.in +2 -1
index a6b00fc..b3b54f4 100644
@@ -62,6 +62,7 @@ mandir = $(datarootdir)/man
 localedir = $(DESTDIR)@LOCALEDIR@
 staticdir = $(DESTDIR)@STATICDIR@
 udevdir = $(DESTDIR)@udevdir@
+USRLIB_RELPATH = $(shell $(top_srcdir)/scripts/relpath.sh $(abspath $(usrlibdir) $(libdir)))
 
 # Setup vpath search paths for some suffixes
 vpath %.c $(srcdir)
@@ -301,7 +302,7 @@ $(LIB_SHARED): $(LIB_SHARED).$(LIB_VERSION)
 install_lib_shared: $(LIB_SHARED)
 	$(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
 	$(INSTALL) -d $(usrlibdir)
-	$(LN_S) -f $(libdir)/$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
+	$(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
 
 # FIXME: plugins are currently installed with .so suffix only
 install_lib_shared_plugin: $(LIB_SHARED)
tools/Makefile.in +1 -1
index 0a4d75f..47fa2db 100644
@@ -169,7 +169,7 @@ install_cmdlib_include: $(srcdir)/lvm2cmd.h
 install_cmdlib_dynamic: liblvm2cmd.$(LIB_SUFFIX)
 	$(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
 	$(INSTALL) -d $(usrlibdir)
-	$(LN_S) -f $(libdir)/$<.$(LIB_VERSION) $(usrlibdir)/$(<F)
+	$(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
 
 install_cmdlib_static: liblvm2cmd-static.a
 	$(INSTALL_DATA) -D $< $(usrlibdir)/liblvm2cmd.a
Signature · 1 line
1.7.0.1