On Tue, Apr 03, 2007 at 01:42:24PM +0300, Ville Skyttä wrote: > Related to recent space saving discussions, I came across PLD's > rpm-build-macros package recently, and found that they hardlink > identical *.pyc and *.pyo. In a lot of cases, they're the same, > and there's some potential for saving some MB "for free", > on my FC6 x86_64 box: > > $ /usr/sbin/hardlink -ncv /usr/lib*/python2.4 2>&1 | tail -n 1 > Would save 11116544 I get more than twice as much on a typical FC6/x86_64 system: 27275264. That's 26 MB on 166MB total, e.g. saving 16%. # du -sc /usr/lib*/python2.4| tail -n 1 170200 total On another system I get 21MB of 144MB total, e.g about 15%. > The PLD implementation looks like this: > > # Hardlink binary identical .pyc and .pyo files > # (idea by glen <at> pld-linux <dot> org) > %__spec_install_post_py_hardlink {\ > %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \ > [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \ > b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \ > if cmp -s "$a" "$b"; then \ > ln -f "$a" "$b"; \ > fi; \ > done \ > }; __spec_install_post_py_hardlink } } > > The use of "cmp" would require diffutils installed. Or the above > could be converted to use hardlink instead (which would have to be made > sure to be around) or maybe sha1sum (in coreutils, pretty much always > around in buildroots). > > I suppose something like the above could be easily added to > redhat-rpm-config or rpm, eg. embedded in brp-python-bytecompile > or run after it in %__os_install_post. brp-python-bytecompile sounds like the best spot since the pyc/pyos are created there. Maybe we should ship an improved brp-python-bytecompile in redhat-rpm-config while lobbying rpm upstream to adopt it? > Worth it? Other comments? A 15% space gain (under python) w/o any drawbacks? Always worth it. :) -- Axel.Thimm at ATrpms.net
Attachment:
pgpIPllnAnT0I.pgp
Description: PGP signature
-- Fedora-packaging mailing list Fedora-packaging@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-packaging