File: macos-import-arch.sh

package info (click to toggle)
swi-prolog 9.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 82,408 kB
  • sloc: ansic: 387,503; perl: 359,326; cpp: 6,613; lisp: 6,247; java: 5,540; sh: 3,147; javascript: 2,668; python: 1,900; ruby: 1,594; yacc: 845; makefile: 428; xml: 317; sed: 12; sql: 6
file content (40 lines) | stat: -rwxr-xr-x 706 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
#!/bin/zsh

from=$1

usage()
{
cat <<_EOF_
Usage: $0 dir
_EOF_
exit 1
}

if [ ! -d $from ]; then
    usage
fi

files=( $(find . -type f \( -perm -0700 -o -name '*.dylib' -o -name '*.so' \) -a \! -name '*.pl' -a \! -name '*.la') )

for f in $files; do
    if file $f | grep Mach-O > /dev/null; then
	if [ -f $f -a -f $from/$f ]; then
	    if lipo -info $f | grep -q x86_64; then
		echo "$f already contains x86_64"
	    else
		echo -n "Joining $f and $from/$f ... "
		if lipo -create $f $from/$f -output $f.U; then
		    mv $f.U $f
		    echo ok
		else
		    echo "FAILED"
		fi
	    fi
	else
	    echo "WARNING: Cannot find $from/$f"
	fi
    else
	echo "WARNING: $f is not a native executable"
    fi
done