File get-upstream-patches of Package autofs
#! /bin/bash
# get autofs upstream patched from
# http://www.fht.lkams.kernel.org/pub/linux/daemons/autofs/v5/
# and cat them in one bzipped file
# autofs-$VERSION-upstream-patches-$DATE
# where DATE is the date of the top patch in the series
#
# usage: get-upstream-patches [VERSION]
# default version
VERSION=5.0.4
test -n "$1" && VERSION="$1"
BASE=http://www.fht.lkams.kernel.org/pub/linux/daemons/autofs/v5
SERIES=patch_order-$VERSION
WGET_OPTS=-q
PATCHDIR=upstream-patches-$VERSION
CURRENT=$PWD
DELIMITER=$(mktemp)
test -x /usr/bin/wget || { echo "wget is missing!"; exit 1; }
test -x /usr/bin/bzip2 || { echo "bzip2 is missing!"; exit 1; }
test -x /usr/bin/sed || { echo "sed is missing!"; exit 1; }
test -d $PATCHDIR || mkdir $PATCHDIR
pushd $PATCHDIR > /dev/null 2>&1
rm -f $SERIES
echo "retrieving series file $SERIES"
wget $WGET_OPTS $BASE/$SERIES
while read patch
do
if test -r "$patch"; then
echo "$patch ...skipping"
else
echo "$patch ...retrieving"
wget $WGET_OPTS $BASE/$patch
fi
done < $SERIES
LAST=$(sed -e "/^$/d" $SERIES | tail -n 1)
DATE=$(stat -c "%y" $LAST | cut -d' ' -f 1 | sed "s/-//g")
echo > $DELIMITER
echo "----------" >> $DELIMITER
echo >> $DELIMITER
cat $SERIES $DELIMITER $(cat $SERIES) > $CURRENT/autofs-$VERSION-upstream-patches-$DATE
rm -f $DELIMITER
bzip2 $CURRENT/autofs-$VERSION-upstream-patches-$DATE
popd > /dev/null 2>&1