No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fixQualifiedLibraryPaths.sh 1.0KB

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