#! /bin/sh
# Make hydrogen-drumkits upstream tarball from sourceforge

#Please update version number if necessary...
base_version=0.9.3

test -x /usr/bin/wget || (echo "please install wget!" 1>&2 ; exit 1);
date=`date +%Y%m%d`
version="$base_version.$date"

bdir="hydrogen-drumkits-$version"
dir="../$bdir"
arch="../hydrogen-drumkits_$version.orig.tar.gz"
mkdir "$dir"
mkdir "$dir/drumkits"

KITS="\
http://heanet.dl.sourceforge.net/h/hy/hydrogen/3355606.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/DrumkitPack1.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/DrumkitPack2.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/EasternHop-1.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/ErnysPercussion.h2drumkit \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/HardElectro1.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/Millo-Drums_v1.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/MilloDrums-3.zip \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/TD-7.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/Techno-1_kit_demo.ogg \
http://people.64studio.com/~free/hydrogen/UltraAcousticKit.tar.gz \
http://heanet.dl.sourceforge.net/h/hy/hydrogen/default_drumkit.tar.gz \
http://hydrogen-music.org/download/drumkits/YamahaVintageKit.zip \
http://rolandclan.info/media/samples/tr-606/Roland_TR-606.h2drumkit \
http://rolandclan.info/media/samples/tr-707/Roland_TR-707.h2drumkit \
http://rolandclan.info/media/samples/tr-808/Roland_TR-808.h2drumkit \
http://rolandclan.info/media/samples/tr-909/Roland_TR-909.h2drumkit \
http://rolandclan.info/media/samples/tr-626/Roland_TR-626.h2drumkit \
http://rolandclan.info/media/samples/v-synth/V-Synth_VariBreaks.h2drumkit \
http://rolandclan.info/media/samples/dr-110/Boss_DR-110.h2drumkit \
"

for KIT in $KITS; do
    wget -P "$dir/drumkits" -nd -r -l1 "$KIT"
done

#rm -f "$dir/drumkits/index.html"
md5sum drumkits/* > "$dir/md5sums.old"

(cd "$dir" && md5sum drumkits/* >"$dir/md5sums")

if diff --brief "$dir/md5sums.old" "$dir/md5sums" >/dev/null; then
        echo "Old and new version are the same." 1>&2
        echo "Upstream source package not rebuild."
else
        rm "$dir/md5sums.old" "$dir/md5sums"
        tar zcf "$arch" -C.. "$bdir"
        echo "New upstream source package in $arch"
        echo "You can run uupdate $arch $version"
fi
rm -r "$dir"
