Blame SOURCES/brp-python-bytecompile-with-scl-python-35

8dc7a2
#!/bin/bash
8dc7a2
# Altered from brp-python-bytecompile
8dc7a2
errors_terminate=$2
8dc7a2
8dc7a2
# If using normal root, avoid changing anything.
8dc7a2
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
8dc7a2
       exit 0
8dc7a2
fi
8dc7a2
8dc7a2
# If we don't have a python interpreter, exit.
8dc7a2
python=$1
8dc7a2
if [ ! -x "$python" ]; then
8dc7a2
       exit 2
8dc7a2
fi
8dc7a2
8dc7a2
# Figure out how deep we need to descend.  We could pick an insanely high
8dc7a2
# number and hope it's enough, but somewhere, somebody's sure to run into it.
8dc7a2
depth=`(find $RPM_BUILD_ROOT -type f -name "*.py" -print0 ; echo /) | \
8dc7a2
       xargs -0 -n 1 dirname | sed 's,[^/],,g' | sort -u | tail -n 1 | wc -c`
8dc7a2
if [ -z "$depth" -o "$depth" -le "1" ]; then
8dc7a2
       exit 0
8dc7a2
fi
8dc7a2
8dc7a2
# Generate normal (.pyc) byte-compiled files.
8dc7a2
$python -c 'import compileall, re, sys; sys.exit (not compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/"'"), quiet=1))'
8dc7a2
if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then
8dc7a2
       # One or more of the files had a syntax error
8dc7a2
      exit 1
8dc7a2
fi
8dc7a2
8dc7a2
# Generate optimized (.pyo) byte-compiled files.
8dc7a2
$python -O -c 'import compileall, re, sys; sys.exit(not compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/"'"), quiet=1))' > /dev/null
8dc7a2
if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then
8dc7a2
       # One or more of the files had a syntax error
8dc7a2
       exit 1
8dc7a2
fi
8dc7a2
exit 0