Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Thin out Universal binaries via a shell script UNIX
This is a shell command to convert universal binaries to thin. Before you use it, here are a couple things to look out for:
  1. The lipo tool strips setuid and setgid bits.
  2. Frameworks and other linked code needs to be universal to support Rosetta.
The overall savings for this script is probably a few hundred megabytes, which probably would not matter to most people. If you're even thinking about trying this, back up your complete system first.

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...]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[11,342 views]  

Thin out Universal binaries via a shell script | 1 comments | Create New Account
Click here to return to the 'Thin out Universal binaries via a shell script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Thin out Universal binaries via a shell script
Authored by: Marius_Th on May 24, '06 08:05:50AM

Someone's been so kind as to write an drag 'n' droppable application around that shellscript, appropriatly called "TrimTheFat"
http://www.macupdate.com/info.php/id/20404
really handy to quickly strip the FAT off of any Uni Application.



[ Reply to This | # ]