Karsten Hopp 16bcfe
#!/bin/bash
Karsten Hopp 16bcfe
Karsten Hopp 16bcfe
LANG=C
Karsten Hopp 16bcfe
SPEC=vim.spec
Karsten Hopp 16bcfe
Karsten Hopp 16bcfe
DATE=`date +"%a %b %d %Y"`
Karsten Hopp 16bcfe
MAJORVERSION=`grep "define baseversion" vim.spec | cut -d ' ' -f 3`
Karsten Hopp 16bcfe
CHLOG="* $DATE Karsten Hopp <karsten@redhat.com> $MAJORVERSION"
Karsten Hopp 16bcfe
ORIGPL=`grep "define patchlevel" vim.spec | cut -d ' ' -f 3`
Karsten Hopp 16bcfe
#ORIGPL=350
Karsten Hopp 16bcfe
PL=$ORIGPL
Karsten Hopp 16bcfe
Karsten Hopp 16bcfe
while true; do
Karsten Hopp 16bcfe
    PL=$((PL+1))
Karsten Hopp 16bcfe
    PNAME="$MAJORVERSION.$PL"
Karsten Hopp 16bcfe
    URL="ftp://ftp.vim.org/pub/vim/patches/$MAJORVERSION/$PNAME"
Karsten Hopp 16bcfe
    wget -nc $URL 2>/dev/null
Karsten Hopp 16bcfe
    if [ "$?" -ne "0" ]; then
Karsten Hopp 16bcfe
        # Patchlevel not yet available, back down
Karsten Hopp 16bcfe
        PL=$((PL-1))
Karsten Hopp 16bcfe
        if [ "$PL" == "$ORIGPL" ]; then
Karsten Hopp 16bcfe
            echo "No new patchlevel available"
Karsten Hopp 16bcfe
            exit
Karsten Hopp 16bcfe
        fi
Karsten Hopp 16bcfe
        break
Karsten Hopp 16bcfe
    else
Karsten Hopp 16bcfe
        # echo "Got patchlevel $MAJORVERSION.$PL, current CVS is at $MAJORVERSION.$ORIGPL"
Karsten Hopp 16bcfe
        cvs add $PNAME
Karsten Hopp 16bcfe
        cvs ci -m "- patchlevel $PL" $PNAME
Karsten Hopp 16bcfe
        sed -i -e "/Patch$((PL-1)): ftp:\/\/ftp.vim.org\/pub\/vim\/patches\/$MAJORVERSION\/$MAJORVERSION.$((PL-1))/aPatch$PL: ftp:\/\/ftp.vim.org\/pub\/vim\/patches\/$MAJORVERSION\/$MAJORVERSION.$PL" $SPEC
Karsten Hopp 16bcfe
        sed -i -e "/patch$((PL-1)) -p0/a%patch$PL -p0" $SPEC
Karsten Hopp 16bcfe
    fi
Karsten Hopp 16bcfe
done
Karsten Hopp 16bcfe
sed -i -e "s/define patchlevel $ORIGPL/define patchlevel $PL/" $SPEC
Karsten Hopp 16bcfe
sed -i -e "/\%changelog/a$CHLOG.$PL-1\n- patchlevel $PL\n" $SPEC
Karsten Hopp 16bcfe
wget ftp://ftp.vim.org/pub/vim/patches/$MAJORVERSION/README -O README.patches
Karsten Hopp 16bcfe
cvs ci -m "- patchlevel $PL" 
Karsten Hopp 16bcfe
make tag
Karsten Hopp 16bcfe
make build