diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-01-27 14:03:10 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-01-27 14:03:10 +0200 |
commit | bd663944e5eca74af7855bbf6488ff7e6082a950 (patch) | |
tree | 81a1c5a138e764556476e2af092a19f3ce67151e /scripts/brp-python-hardlink | |
parent | 79859ff04fc31a04fb8dfd61020bc5bca4408198 (diff) | |
download | librpm-tizen-bd663944e5eca74af7855bbf6488ff7e6082a950.tar.gz librpm-tizen-bd663944e5eca74af7855bbf6488ff7e6082a950.tar.bz2 librpm-tizen-bd663944e5eca74af7855bbf6488ff7e6082a950.zip |
Add brp-python-hardlink script
- hardlink identical .pyc and .pyo files to same some space
- not enabled by default
- originally from Ville Skyttä for redhat-rpm-config but the functionality
is not specific to Fedora or derivates in any way
Diffstat (limited to 'scripts/brp-python-hardlink')
-rwxr-xr-x | scripts/brp-python-hardlink | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/brp-python-hardlink b/scripts/brp-python-hardlink new file mode 100755 index 000000000..a9375291c --- /dev/null +++ b/scripts/brp-python-hardlink @@ -0,0 +1,19 @@ +#!/bin/sh + +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +# Hardlink identical *.pyc and *.pyo, originally from PLD's rpm-build-macros +# Modified to use sha1sum instead of cmp to avoid a diffutils dependency. +find "$RPM_BUILD_ROOT" -type f -name "*.pyc" | while read pyc ; do + pyo="$(echo $pyc | sed -e 's/.pyc$/.pyo/')" + if [ -f "$pyo" ] ; then + csha="$(sha1sum -b $pyc | cut -d' ' -f 1)" && \ + osha="$(sha1sum -b $pyo | cut -d' ' -f 1)" && \ + if [ "$csha" = "$osha" ] ; then + ln -f "$pyc" "$pyo" + fi + fi +done |