-
Notifications
You must be signed in to change notification settings - Fork 0
/
getaarch.sh
executable file
·67 lines (58 loc) · 1.57 KB
/
getaarch.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
show_usage(){
echo "Usage: $0 <EXECUTABLE> <AARCH> <OUTPATH>"
}
show_help(){
lines=(
"GETAARCH(1)"
""
"NAME"
" getaarch - Universal Binary Extraction Utility"
""
"SYNOPSIS"
" getaarch [EXECUTABLE] [ARCHITECTURE] [OUTPATH]"
""
"DESCRIPTION"
" The getaarch utility is used for extracting single architecture executables from universal binaries"
""
" The following options are supported"
""
" ┌── -arm, --arm64e Extract a thin arm64e executable from the input file"
" ├── -x86, --x86_64 Extract a thin x86_64 executable from the input file"
" └── -h, --help Show this help message"
""
"PROJECT"
" This script is from the mac-utils repo on GitHub."
" mac-utils is a collection of useful (mostly macOS specific) shell and python scripts."
""
" GitHub: https://github.com/Soliez/mac-utils"
)
printf "%s\n" "${lines[@]}" | less
}
main(){
if [ $# -lt 3 ]; then
show_usage
exit 1
else
exe="$1"
aarch="$2"
outpath="$3"
fi
case "$aarch" in
-arm|-arm64e)
lipo -thin arm64e "$exe" -output "$outpath"
;;
-x86|--x86-64)
lipo -thin x86_64 "$exe" -output "$outpath"
;;
-h|--help)
show_help
exit 0
;;
*)
show_usage
exit 1
;;
esac
}
main "$@"