#!/bin/bash

if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
       exit 0
fi

if [ "$NO_BRP_TCL_INDEX_CHECK" = "true" ] ; then
        echo "NO_BRP_TCL_INDEX_CHECK is set: skipping brp tcl index check"
        exit 0
fi

# Check for files named tclIndex and pkgIndex.tcl 
# under /usr/lib and /usr/lib64.

DIRS=( "$RPM_BUILD_ROOT/usr/lib" "$RPM_BUILD_ROOT/usr/lib64" )
FILES=$(find "${DIRS[@]}" -maxdepth 2 -name pkgIndex.tcl 2>/dev/null)
if test -n "$FILES"; then
    echo "Script libraries for Tcl extensions should be in"
    echo "a package-specific subdir of /usr/share/tcl but"
    echo "was/were found in:"
    echo "$FILES"
    echo "Please contact max@suse.de if you need help with this."
    exit 1
fi
