summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-01-27 14:03:10 +0200
committerPanu Matilainen <pmatilai@redhat.com>2010-01-27 14:03:10 +0200
commitbd663944e5eca74af7855bbf6488ff7e6082a950 (patch)
tree81a1c5a138e764556476e2af092a19f3ce67151e /scripts
parent79859ff04fc31a04fb8dfd61020bc5bca4408198 (diff)
downloadlibrpm-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')
-rw-r--r--scripts/Makefile.am4
-rwxr-xr-xscripts/brp-python-hardlink19
2 files changed, 21 insertions, 2 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 25d5e36be..753c4a5c4 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -6,7 +6,7 @@ CLEANFILES =
EXTRA_DIST = \
brp-compress brp-python-bytecompile brp-java-gcjcompile \
- brp-strip brp-strip-comment-note \
+ brp-strip brp-strip-comment-note brp-python-hardlink \
brp-strip-shared brp-strip-static-archive \
check-files check-prereqs \
check-buildroot check-rpaths check-rpaths-worker \
@@ -24,7 +24,7 @@ EXTRA_DIST = \
rpmconfig_SCRIPTS = \
brp-compress brp-python-bytecompile brp-java-gcjcompile \
- brp-strip brp-strip-comment-note \
+ brp-strip brp-strip-comment-note brp-python-hardlink \
brp-strip-shared brp-strip-static-archive \
check-files check-prereqs \
check-buildroot check-rpaths check-rpaths-worker \
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