f9efe2
#!/bin/bash -e
f9efe2
f9efe2
# If using normal root, avoid changing anything.
f9efe2
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
f9efe2
  exit 0
f9efe2
fi
f9efe2
f9efe2
# Defined as %py_reproducible_pyc_path macro and passed here as
f9efe2
# the first command-line argument
f9efe2
path_to_fix=$1
f9efe2
f9efe2
# First, check that the parser is available:
f9efe2
if [ ! -x /usr/bin/marshalparser ]; then
f9efe2
  echo "ERROR: If %py_reproducible_pyc_path is defined, you have to also BuildRequire: /usr/bin/marshalparser !"
f9efe2
  exit 1
f9efe2
fi
f9efe2
f9efe2
find "$path_to_fix" -type f -name "*.pyc" | xargs /usr/bin/marshalparser --fix --overwrite