Created
February 17, 2024 15:18
-
-
Save shannah/ee01ab9024b9166510b00bcd7f248e31 to your computer and use it in GitHub Desktop.
Script to list all dylibs in an .app bundle that depend on JavaNativeFoundation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage message | |
usage() { | |
echo "Usage: $0 [-v] <directory>" | |
echo " -v Verbose mode. Display files and their JavaNativeFoundation dependencies." | |
} | |
# Check for verbose flag | |
VERBOSE=0 | |
while getopts ":v" opt; do | |
case ${opt} in | |
v ) | |
VERBOSE=1 | |
;; | |
\? ) | |
usage | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND -1)) | |
# Check if a directory was provided | |
if [ -z "$1" ]; then | |
usage | |
exit 1 | |
fi | |
# Directory to search | |
SEARCH_DIR=$1 | |
# Function to check and optionally display dependency | |
check_file() { | |
local file="$1" | |
local deps=$(otool -L "$file" 2>/dev/null | grep 'JavaNativeFoundation' || true) | |
if [[ ! -z "$deps" ]]; then | |
if [ "$VERBOSE" -eq 1 ]; then | |
echo "$file depends on:" | |
echo "$deps" | |
echo # empty line for better readability | |
else | |
echo "$file" | |
fi | |
fi | |
} | |
export -f check_file | |
export VERBOSE | |
# Find all dylibs and executables, then check each one | |
find "$SEARCH_DIR" \( -name "*.dylib" -o -perm +111 \) -type f -exec bash -c 'check_file "$0"' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example usage | |
bash check_jnf_linkage.sh /path/to/MyApp.app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment