Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all PPC libraries, binaries and applications in Snow Leopard

Do you have any pointer on how to write a script that will search my system for applications, libraries (i.e. /usr/local/lib and /usr/local), and binaries that are PPC only?

I upgraded my system from a PPC Mac to a Intel Mac running Leopard 10.5. Then I upgraded to Snow Leopard 10.6 which doesn't come with Rosetta. So I'm only now realising all the old PPC things that are left on my system!

like image 593
Daniel Farrell Avatar asked Sep 10 '09 16:09

Daniel Farrell


2 Answers

The file command can detect what binary types are available in a file.

file -b /usr/bin/atrm
setuid Mach-O universal binary with 3 architectures
/usr/bin/atrm (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/atrm (for architecture i386): Mach-O executable i386
/usr/bin/atrm (for architecture ppc7400): Mach-O executable ppc

So, then, it is just a matter of using find and filtering appropriately. Something like this should find all binaries on the system that have a PPC subsection.

find / -perm -u+x ! -type d -exec file {} \; | grep ppc | awk '{print $1}'

PPC only is a little more difficult. For that, you'll want to do three commands to create 2 files in /tmp, the first containing a list of PPC files and the second a list of 32 or 64 bit x86 files. Conveniently, 'ppc' matches ppc and ppc64.

find / -perm -u+x ! -type d -exec file {} \; | grep ppc | awk '{print $1}' > /tmp/ppc
find / -perm -u+x ! -type d -exec file {} \; | grep i386 | awk '{print $1}' > /tmp/x86
find / -perm -u+x ! -type d -exec file {} \; | grep x86_64 | awk '{print $1}' >> /tmp/x86

Then, sort/uniq a bit (just sorts the paths and makes sure each binary is only listed once):

cat /tmp/x86 | sort | uniq > /tmp/x86.filtered
cat /tmp/ppc | sort | uniq > /tmp/ppc.filtered

Then, use diff (and a bit more processing) to spew the list of files that are ppc only:

diff /tmp/ppc.filtered /tmp/x86.filtered | grep -e '<' | awk '{print $2}' | perl -p -e 's/:$//'

The end result should be a list of files that only contain ppc executable mach-o sections. I would suggest verifying the list before nuking anything.

Some notes:

All of the above is done in the Terminal.

This is just a hack; it worked just fine on my system and I'm glad you asked because I wanted to know the same. But it is just a hack.

like image 76
bbum Avatar answered Sep 28 '22 16:09

bbum


To find Applications, you can use System Profiler (Called System Information in Lion).

Look under "Software" in the sidebar and choose "Applications"...then wait a long time while it gathers info.

like image 45
docwhat Avatar answered Sep 28 '22 15:09

docwhat