From bd663944e5eca74af7855bbf6488ff7e6082a950 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 27 Jan 2010 14:03:10 +0200 Subject: =?UTF-8?q?Add=20brp-python-hardlink=20script=20-=20hardlink=20ide?= =?UTF-8?q?ntical=20.pyc=20and=20.pyo=20files=20to=20same=20some=20space?= =?UTF-8?q?=20-=20not=20enabled=20by=20default=20-=20originally=20from=20V?= =?UTF-8?q?ille=20Skytt=C3=A4=20for=20redhat-rpm-config=20but=20the=20func?= =?UTF-8?q?tionality=20=20=20is=20not=20specific=20to=20Fedora=20or=20deri?= =?UTF-8?q?vates=20in=20any=20way?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/brp-python-hardlink | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 scripts/brp-python-hardlink (limited to 'scripts/brp-python-hardlink') 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 -- cgit v1.2.3