#!/usr/bin/perl # by jolly - who else ? # # find / -type f -exec perl5 Thinner.perl m68k {} \; # %supportedarchitectures = ( 'i386','i386','m68k','m68k','hppa','hppa','sparc','sparc'); $architecture = shift(@ARGV); $supportedarchitectures{$architecture} || die "Don't know architecture $architecture\n"; %magiccookies = ( 0xCAFEBABE,'cafebabe' ); while ( $filename = shift(@ARGV) ) { if( -f $filename ) { if( open(FILE,$filename) ) { if( 8 == read(FILE,$magictest,8) ) { (@stats)=stat(FILE); $fatuid = $stats[4]; $fatgid = $stats[5]; $fatmode = $stats[2]; $fatatime = $stats[8]; $fatmtime = $stats[9]; close(FILE); if( $magiccookies{unpack('N',$magictest)} ) { print STDERR "File $filename seems to be multiarch.\n"; system 'lipo','-thin',$architecture,'-output',$filename.'.'.$architecture, $filename; if( -f $filename.'.'.$architecture ) { print STDERR "Can't change file date \n" if ! utime $fatatime, $fatmtime, $filename.'.'.$architecture ; print STDERR "Can't change file mods \n" if ! chmod $fatmode, $filename.'.'.$architecture ; print STDERR "Can't change file user \n" if ! chown $fatuid, $fatgid, $filename.'.'.$architecture ; system '/bin/mv', '-f', $filename.'.'.$architecture, $filename; } } } else { print STDERR "Can't read $filename - ignoring file\n"; close(FILE); } } else { print STDERR "Can't open $filename - ignoring file \n"; } } }