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

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