hardlink identical .pyc and .pyo files to save some space. patch from
Ville Skyttä <ville DOT skytta AT iki DOT fi>
This commit is contained in:
parent
9f4238cef9
commit
a959c1f92d
19
brp-python-hardlink
Executable file
19
brp-python-hardlink
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user