This is a shell command to convert universal binaries to thin. Before you use it, here are a couple things to look out for:
The first argument to the function is the directory to search, if not the current directory. After that, the architecture could be specified (but defaults to the system architecture). The code must be run as root to affect most system directories. Here's a list of likely directories to thin:
Alternately, you could use ditto to accomplish the same thing, but I do not think ditto preserves set_id bits either.
[robg adds: This script is potentially very dangerous. I have not tested it. As noted, if you are going to, please back up your system first. Proceed at your own risk. Look both ways before crossing the street. Always eat your vegetables...]
- The lipo tool strips setuid and setgid bits.
- Frameworks and other linked code needs to be universal to support Rosetta.
function strip_to_architecture() {
find "${1:-.}" -type f -perm +111 -not -perm +7000 -not -name '*.*' -exec lipo {} -thin "${2:-`arch`}" -output {} \; -print 2>/dev/null
}The first argument to the function is the directory to search, if not the current directory. After that, the architecture could be specified (but defaults to the system architecture). The code must be run as root to affect most system directories. Here's a list of likely directories to thin:
/bin /sbin /usr/bin /usr/sbin /usr/libexec /Applications
On an Intel mac, do not strip any Frameworks folders if you want to leave Rosetta working. On PowerPC Macs that is not an issue. Any file which is not a universal binary is ignored. The -not -perm +7000 ignores any files with a set_id bit. If you want to save a few more megabytes for some reason, change the script to only find a specific set_id bit, then restore the bit after lipo clears it.
Alternately, you could use ditto to accomplish the same thing, but I do not think ditto preserves set_id bits either.
[robg adds: This script is potentially very dangerous. I have not tested it. As noted, if you are going to, please back up your system first. Proceed at your own risk. Look both ways before crossing the street. Always eat your vegetables...]
•
[11,342 views]

