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

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