Saving space thread
-
Ok, here's a thread for detailing saving space, albeit tiny amounts.
Here is a starter, save 40KB by using minigzip instead of gzip, gzip is only used in decompressing the zoneinfo file and during image install so:
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
becomes:
exec('/bin/cat /tmp/zoneinfo.tgz | /usr/bin/minigzip -d | /usr/bin/tar tf -', $timezonelist);
:D
-
All binaries for embedded platforms should have debug information removed by strip, this usually happens via "install -s" in the install scripts. However a couple more extra KB can be squeezed out using the following:
# ls -l -r-xr-xr-x 1 root wheel 827500 Jun 30 23:11 python # strip --remove-section=.note --remove-section=.comment python # ls -l -r-xr-xr-x 1 root wheel 823968 Jun 30 23:11 python
:P
-
Yes, we made this change weeks ago, thanks.
-
Three scripts, subtle modifications to m0n0's mklibs.pl:
used_libs.pl: same as mklibs.pl but smaller
#!/usr/bin/perl $dir = 'freesbie-fs'; use File::Find; # check_libs(path) sub check_libs { $mode = stat[2]; @libs{`/usr/bin/ldd -f "%p\n" $_ 2>/dev/null`} = () if (-f $_); } # walk the directory tree find(\&check_libs, $dir); print sort keys %libs; #alternative: strip leading slash #print map { substr($_, 1); } sort keys %libs;
blame_libs.pl: which binaries require each library
#!/usr/bin/perl $dir = 'freesbie-fs'; use File::Find; # check_libs(path) sub check_libs { $mode = stat[2]; if (-f $_) { foreach $lib (`/usr/bin/ldd -f "%p\n" $_ 2>/dev/null`) { chop($lib); $libs{$lib} = [] unless (exists $libs{$lib}); push @{ $libs{$lib} }, $_; } } } # walk the directory tree find(\&check_libs, $dir); foreach $lib (sort keys %libs) { print "$lib:\n"; foreach (sort @{ $libs{$lib} }) { print "\t$_\n"; } print "\n"; } [/code] [b]unused_libs.pl[/b]: opposite of used_libs.pl attempting iterative recursion on dependencies. [code] #!/usr/bin/perl $dir = 'freesbie-fs'; use File::Find; # check_libs(path) sub check_libs { $mode = stat[2]; if (-f $_ && ! -l $_) { $fname = substr($File::Find::name, length($dir)); if (/\.so(\.|$)/) { $liblist{$fname} = (); } else { $nonlist{$fname} = (); } foreach $lib (`/usr/bin/ldd -f "%p\n" $_ 2>/dev/null`) { chop($lib); $lib = readlink($lib) if (-l $lib); $libs{$lib}{$fname} = (); } } } # walk the directory tree find(\&check_libs, $dir); $pass = 0; do { $pass++; $pending = 0; # print "pass $pass\n"; foreach $lib (sort keys %liblist) { $count = (exists $libs{$lib}) ? scalar keys %{ $libs{$lib} } : 0; if ($count == 0) { # print "\t$lib\n"; delete $liblist{$lib}; $unusedlist{$lib} = (); foreach $lib2 (sort keys %liblist) { if (exists $libs{$lib2}{$lib}) { # print "\t\t$lib2\n"; delete $libs{$lib2}{$lib}; $pending++; } } next; } } } while ($pending > 0); #print "unused libraries:\n\n"; foreach (sort keys %unusedlist) { print "$_\n"; } [/code]