ubuntu-bots/PackageInfo/update_apt_file

60 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
if [ ! -x "$(which apt-file)" ]; then
echo "Please install apt-file"
exit 1
fi
# Set DIR to the same value as supybot.plugins.PackageInfo.aptdir
if [ -z "$DIR" ]; then
DIR=/home/bot/aptdir
fi
# Be quiet by default
if [ -z "$VERBOSE" ]; then
VERBOSE="no"
fi
# Check command-line arguments
while [ "x$1" != "x" ]; do
case "$1" in
-v|--verbose)
VERBOSE="yes"
;;
-d|--dir)
if [ "x$2" == "x" ]; then
echo "\"-d|--dir\" requires an argument" >&2
exit 1
fi
shift
DIR="$1"
;;
-*)
echo "Unknown option \"$1\"" >&2
exit 1
;;
*)
echo "This script takes no non-argument parameterss" >&2
exit 1
;;
esac
shift
done
for DIST in "$DIR"/*.list; do
test -h $DIST && continue
DIST=${DIST:${#DIR}}
DIST=${DIST/.list}
mkdir -p "$DIR/apt-file/$DIST"
if [ "${VERBOSE}" != "no" ]; then
echo "Processing $DIST"
apt-file -l -c "$DIR/apt-file/$DIST" -s "$DIR/$DIST.list" update
else
apt-file -l -c "$DIR/apt-file/$DIST" -s "$DIR/$DIST.list" update >/dev/null 2>&1
fi
RET=$?
if [ ! $RET ]; then
echo "apt-file failed for $DIST!"
fi
done