rpath_remove_symlinks.sh 723 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. # AltStore has issues with symlinks to dylibs
  3. cd "$CODESIGNING_FOLDER_PATH/$BUNDLE_FRAMEWORKS_FOLDER_PATH"
  4. # find rpath entries that point to symlinks
  5. rpathSymlinks=()
  6. for binary in "../$EXECUTABLE_NAME" $(find . -type f -iname '*.dylib'); do
  7. echo "checking $binary"
  8. # dyld_info sample output: @rpath/libogg.0.dylib
  9. for lib in $(dyld_info -linked_dylibs "$binary" | awk -F / '/@rpath/ {print $2}'); do
  10. if [ -L "$lib" ]; then
  11. echo "- symlink: $lib"
  12. rpathSymlinks+=("$lib")
  13. fi
  14. done
  15. done
  16. # move real files to symlinks location
  17. echo
  18. for symlink in "${rpathSymlinks[@]}"; do
  19. mv -fv "$(readlink "$symlink")" "$symlink"
  20. done
  21. # remove the rest of the useless symlinks
  22. find . -type l -delete