From bd663944e5eca74af7855bbf6488ff7e6082a950 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 27 Jan 2010 14:03:10 +0200 Subject: [PATCH] =?utf8?q?Add=20brp-python-hardlink=20script=20-=20hardlin?= =?utf8?q?k=20identical=20.pyc=20and=20.pyo=20files=20to=20same=20some=20s?= =?utf8?q?pace=20-=20not=20enabled=20by=20default=20-=20originally=20from?= =?utf8?q?=20Ville=20Skytt=C3=A4=20for=20redhat-rpm-config=20but=20the=20f?= =?utf8?q?unctionality=20=20=20is=20not=20specific=20to=20Fedora=20or=20de?= =?utf8?q?rivates=20in=20any=20way?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- scripts/Makefile.am | 4 ++-- scripts/brp-python-hardlink | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 scripts/brp-python-hardlink diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 25d5e36..753c4a5 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 0000000..a937529 --- /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 -- 2.7.4