From a959c1f92d55d1829a6b1c3d45d765d8a4129551 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 19 Jun 2007 14:20:53 -0400 Subject: [PATCH] =?UTF-8?q?hardlink=20identical=20.pyc=20and=20.pyo=20file?= =?UTF-8?q?s=20to=20save=20some=20space.=20=20patch=20from=20Ville=20Skytt?= =?UTF-8?q?=C3=A4=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- brp-python-hardlink | 19 +++++++++++++++++++ macros | 1 + 2 files changed, 20 insertions(+) create mode 100755 brp-python-hardlink diff --git a/brp-python-hardlink b/brp-python-hardlink new file mode 100755 index 0000000..a937529 --- /dev/null +++ b/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 diff --git a/macros b/macros index 3c34fc1..dc6680a 100644 --- a/macros +++ b/macros @@ -86,6 +86,7 @@ /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \ /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \ /usr/lib/rpm/brp-python-bytecompile \ + /usr/lib/rpm/redhat/brp-python-hardlink \ /usr/lib/rpm/redhat/brp-java-repack-jars \ %{nil}