teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.14.1-python-brp-bytecompile.patch

Petr Viktorin 3f65cd
diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
Miro Hrončok 364d03
index 894fa34..c06bdfa 100644
Petr Viktorin 3f65cd
--- a/scripts/brp-python-bytecompile
Petr Viktorin 3f65cd
+++ b/scripts/brp-python-bytecompile
Miro Hrončok 364d03
@@ -1,5 +1,6 @@
Miro Hrončok 364d03
 #!/bin/bash
Miro Hrončok 364d03
 errors_terminate=$2
Miro Hrončok 364d03
+extra=$3
Miro Hrončok 364d03
 
Miro Hrončok 364d03
 # If using normal root, avoid changing anything.
Miro Hrončok 364d03
 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
Miro Hrončok 364d03
@@ -79,14 +80,22 @@ do
Miro Hrončok 364d03
 done
Miro Hrončok 364d03
 
Miro Hrončok 364d03
 
Miro Hrončok 364d03
-# Handle other locations in the filesystem using the default python
Miro Hrončok 364d03
-# implementation - if we  have a default python interpreter
Miro Hrončok 364d03
+# Handle other locations in the filesystem using the default python implementation
Miro Hrončok 364d03
+# if extra is set to 0, don't do this
Miro Hrončok 364d03
+if [ 0$extra -eq 0 ]; then
Miro Hrončok 364d03
+	exit 0
Miro Hrončok 364d03
+fi
Miro Hrončok 364d03
 
Miro Hrončok 364d03
+# If we don't have a default python interpreter, we cannot proceed
Miro Hrončok 364d03
 default_python=${1:-/usr/bin/python}
Miro Hrončok 364d03
 if [ ! -x "$default_python" ]; then
Petr Viktorin 3f65cd
 	exit 0
Petr Viktorin 3f65cd
 fi
Petr Viktorin 3f65cd
 
Petr Viktorin 3f65cd
+# Figure out if there are files to be bytecompiled with the default_python at all
Petr Viktorin 3f65cd
+# this prevents unnecessary default_python invocation
Petr Viktorin 3f65cd
+find "$RPM_BUILD_ROOT" -type f -name "*.py" | grep -Ev "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" || exit 0
Petr Viktorin 3f65cd
+
Petr Viktorin 3f65cd
 # Generate normal (.pyc) byte-compiled files.
Petr Viktorin 3f65cd
 python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"
Petr Viktorin 3f65cd
 if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then