#!/bin/sh
[ $REPOCOP_PKG_NAME = 'service' ] && exit 0
#keydir="$REPOCOP_TEST_STATEDIR/data/$REPOCOP_PKG_KEY"
keydir="$REPOCOP_TEST_STATEDIR/$REPOCOP_PKG_KEY"
# more universal (effective if too many files found)
# if test -n "$(find "$REPOCOP_PKG_ROOT"/etc/rc.d/init.d/ -maxdepth 1 \! -name 'functions-*' -print -quit)"
if stat -t "$REPOCOP_PKG_ROOT"/etc/rc.d/init.d/* >/dev/null 2>&1
then
    mkdir -p "$keydir"
    cp -pL "$REPOCOP_PKG_ROOT"/etc/rc.d/init.d/* "$keydir"
    rm -f "$keydir"/functions-*
    # if empty after rm -f "$keydir"/functions-*
    rmdir "$keydir" 2>/dev/null ||:
fi
