#!/bin/sh
#
# $Id$
#
# Runs 'createrepo' to maintain YUM repository metadata. Relies on
# convention that directories with packages named 'RPMS'.
RPM_DIRNAME=RPMS
EXIT_VALUE=0
if [ -z "$1" ]; then
echo "Usage: `basename $0` parent-dir [dir2 ..]" >&2
exit 1
fi
for dir in "$@"; do
if [ ! -d "$dir" ]; then
echo "notice: skipping non-directory: name=$dir" >&2
continue
fi
find "$dir" -type d -name "$RPM_DIRNAME" | while read rpmdir; do
createrepo $rpmdir >/dev/null
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "error: non-zero exit: command=createrepo $rpmdir, status=$STATUS" >&2
EXIT_VALUE=$STATUS
fi
done
done
exit $EXIT_VALUE