File: delete-all-rpaths.sh

package info (click to toggle)
julia 1.5.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 91,132 kB
  • sloc: lisp: 278,486; ansic: 60,186; cpp: 29,801; sh: 2,403; makefile: 1,998; pascal: 1,313; objc: 647; javascript: 516; asm: 226; python: 161; xml: 34
file content (33 lines) | stat: -rwxr-xr-x 925 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# This file is a part of Julia. License is MIT: https://julialang.org/license

[ "$(uname)" = Darwin ] || { echo "Requires Darwin." 2>&1; exit 1; }

if [ $# -lt 1 ]; then
  echo "usage: $(basename $0) lib1 [lib2 ...]" 2>&1
  exit 1
fi

LIBS=''

# filter out symlinks
for lib in "$@" ; do
  if [ ! -L "$lib" ]; then
    LIBS="$LIBS $lib"
  fi
done

# regex to match and capture the path in a LC_RPATH as output by `otool -l`.
rpath_r="^ +path ([[:print:]]+) \(offset [[:digit:]]+\)$"

for lib in $LIBS ; do
  # Find the LC_RPATH commands, with two lines of trailing
  # context, and for each line look for the path to delete it.
  otool -l "$lib" | grep LC_RPATH -A2 |
  while IFS='' read -r line || [ -n "$line" ]; do
    if [[ $line =~ $rpath_r ]]; then
      echo $(basename $lib) deleting rpath "${BASH_REMATCH[1]}" \""$lib"\"
      install_name_tool -delete_rpath "${BASH_REMATCH[1]}" "$lib"
    fi
  done
done