From f12c2314856c241c4528a2c9385c796fb0d96c52 Mon Sep 17 00:00:00 2001 From: Artur Frysiak Date: Tue, 15 Feb 2005 13:30:40 +0000 Subject: [PATCH] - added %%py_postclean (idea and implementation by glen) - added %%__spec_install_post_py_hardlink (idea by glen, simplified by me) Changed files: rpm.macros -> 1.189 --- rpm.macros | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rpm.macros b/rpm.macros index dcf1f4b..2a876eb 100644 --- a/rpm.macros +++ b/rpm.macros @@ -429,6 +429,27 @@ echo "Compress kernel modules if any."; \ # Software written in Python language require Python with main version %pyrequires_eq() Requires: python(bytecode) = %py_ver %1 + +# Hardlink binary identical .pyc and .pyo files +# (idea by glen pld-linux org) +%__spec_install_post_py_hardlink {\ +%{!?no_install_post_py_hardlink: +[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \ + b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \ + if cmp -s "$a" "$b"; then \ + ln -f "$a" "$b"; \ + fi; \ +done \ +} } + +# remove python sources, so that check-files won't complain +# (idea by glen pld-linux org) +%py_postclean() \ +for d in %{py_sitescriptdir} %{py_sitedir}; do \ + [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -exec rm {} \; ;\ +done \ +%{nil} + # depmod macro %depmod() { \ umask 022; \ -- 2.44.0