#!/bin/bash

# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
        exit 0
fi

if [ ! -e /usr/include/python/Python.h ]; then
	exit 0
fi

TMPDIR="$(mktemp -d /tmp/ssizecheck-XXXXXX)"

find /usr/src/packages/BUILD/ -iname '**.c' -print0 | \
xargs -r0 python /usr/lib/rpm/brp-check-python.data/ssizecheck.py > "$TMPDIR/$$"

test -f /.buildenv && . /.buildenv

cat "$TMPDIR/$$"

if [ "${BUILD_BASENAME:0:4}" = "beta" ]; then
   test -s "$TMPDIR/$$" && echo "please see http://www.python.org/dev/peps/pep-0353/ for hints"
fi

rm -rf "$TMPDIR"

exit 0
