Feb 16, 2011

lipo - OSXのユニバーサルバイナリをダイエット

lipo を使えば、PowerPC用など使わないバイナリを削除できます。

まず、情報をチェック。
$ cd /Applications/CotEditor.app/Contents/MacOS/
$ lipo -detailed_info CotEditor Fat header in: CotEditor
fat_magic 0xcafebabe
nfat_arch 2
architecture ppc
    cputype CPU_TYPE_POWERPC
    cpusubtype CPU_SUBTYPE_POWERPC_ALL
    offset 4096
    size 451032
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 458752
    size 457544
    align 2^12 (4096)

削除してよければ、例えば以下のように。
$ lipo -remove ppc -output CotEditor2 CotEditor

$ ll -h
total 2696
-rwxr-xr-x  1 user  admin   895K  4 26  2009 CotEditor
-rwxr-xr-x  1 user  admin   451K  2 16 23:14 CotEditor2

$ lipo -detailed_info CotEditor2
Fat header in: CotEditor3
fat_magic 0xcafebabe
nfat_arch 1
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 4096
    size 457544
    align 2^12 (4096)

起動してみて問題がなければ元のものと入れ替えます。


参考サイト

http://journal.mycom.co.jp/column/osx/282/index.html

No comments:

Post a Comment