#!/bin/sh
#
# apply-series.sh by Davide Libenzi (applies a quilt patch serie)
# Copyright (C) 2002  Davide Libenzi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Davide Libenzi <davidel@xmailserver.org>
#

if [ $# -lt 2 ]; then
    echo "use: $0 SERIEDIR DESTDIR"
    exit 1
fi

SDIR=$1
DDIR=$2

if [ ! -f "$SDIR/series" ]; then
    echo "missing $SDIR/series file"
    exit 2
fi

FILES=`cat $SDIR/series | xargs`

if [ ! -d "$DDIR" ]; then
    echo "invalid destination directory $DDIR"
    exit 3
fi

for p in $FILES; do
    CFILE=$SDIR/$p
    echo ">>> applying $p"
    patch -d $DDIR -p1 < $CFILE
done


