Browse Source

added fixqualifiedpaths

egradman 4 years ago
parent
commit
dd691568ea
1 changed files with 44 additions and 0 deletions
  1. 44
    0
      fixQualifiedLibraryPaths.sh

+ 44
- 0
fixQualifiedLibraryPaths.sh View File

@@ -0,0 +1,44 @@
1
+#!/bin/bash
2
+#This script is ugly, feel free to fix it
3
+
4
+if [ "$#" -ne 2 ]; then
5
+    echo "usage ./cmd target-rootfs target-toolchain"
6
+    exit -1
7
+fi
8
+
9
+#passed args
10
+ROOTFS=$1
11
+TOOLCHAIN=$2
12
+
13
+if [ -x $TOOLCHAIN ]; then
14
+    echo "Passed valid toolchain"
15
+    MACHINE=$($TOOLCHAIN -dumpmachine)
16
+    DEB_MULTI_ARCH_MADNESS=$ROOTFS/usr/lib/$MACHINE
17
+fi
18
+
19
+CURRENTDIR=$PWD
20
+
21
+function adjustSymLinks
22
+{
23
+    echo "Adjusting the symlinks in $1 to be relative"
24
+    cd $1
25
+    find . -maxdepth 1 -type l | while read i;
26
+    do qualifies=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | grep ^/lib)
27
+    if [ -n "$qualifies" ]; then
28
+    newPath=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | sed -e "s,\`,,g" | sed -e "s,',,g" | sed -e "s,^/lib,$2/lib,g");
29
+    echo $i
30
+    echo $newPath;
31
+    sudo rm $i;
32
+    sudo ln -s $newPath $i;
33
+    fi
34
+    done
35
+}
36
+
37
+adjustSymLinks $ROOTFS/usr/lib "../.."
38
+
39
+if [ -n "$DEB_MULTI_ARCH_MADNESS" -a -d "$DEB_MULTI_ARCH_MADNESS" ]; then
40
+    echo "Debian multiarch dir exists, adjusting"
41
+    adjustSymLinks $DEB_MULTI_ARCH_MADNESS "../../.."
42
+fi
43
+
44
+cd $CURRENTDIR

Loading…
Cancel
Save