#!/bin/sh
# create_slack_repo.sh
# 2014-01-28
# by Gernot Walzl
# gpg --detach-sig --armor CHECKSUMS.md5
DIR="$1"
print_usage () {
echo "Usage:"
echo " $0 DIR"
}
prgname () {
PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
if [ "$PKGEXT" != "tgz" -a "$PKGEXT" != "txz" ]; then
return 1
fi
NAME=$(echo $1 | rev | cut -f 4- -d - | rev)
echo "$NAME"
}
create_packages () {
FILENAME="PACKAGES.TXT"
DATE=$(date +%Y-%m-%d)
echo "${FILENAME}; ${DATE}" > "$FILENAME"
echo "" >> "$FILENAME"
for PKG in $(find . -name '*.t?z' | sort); do
echo "$PKG"
NAME=$(basename "$PKG")
LOC=$(dirname "$PKG")
PRGNAM=$(prgname "$NAME")
SIZE_C=$(cat "$PKG" | wc -c)
SIZE_C=$(expr $SIZE_C / 1024)
SIZE_U=$(tar xfO "$PKG" | wc -c)
SIZE_U=$(expr $SIZE_U / 1024)
echo "PACKAGE NAME: ${NAME}" >> "$FILENAME"
echo "PACKAGE LOCATION: ${LOC}" >> "$FILENAME"
echo "PACKAGE SIZE (compressed): ${SIZE_C} K" >> "$FILENAME"
echo "PACKAGE SIZE (uncompressed): ${SIZE_U} K" >> "$FILENAME"
echo "PACKAGE DESCRIPTION:" >> "$FILENAME"
tar xfO "$PKG" install/slack-desc | grep "$PRGNAM" >> "$FILENAME"
echo "" >> "$FILENAME"
done
}
create_checksums () {
FILENAME="CHECKSUMS.md5"
find . -name '*.t?z' | sort | xargs md5sum > "$FILENAME"
}
if [ -d "$DIR" ]; then
cd "$1" || exit 1
create_packages
create_checksums
else
print_usage
fi