Karsten Hopp 16bcfe
#!/bin/bash
Karsten Hopp 4a08e5
debug=""
Karsten Hopp 56ffd8
#debug="echo "
Karsten Hopp 16bcfe
Karsten Hopp 722559
cd `dirname $0`
Karsten Hopp 16bcfe
LANG=C
Karsten Hopp 16bcfe
SPEC=vim.spec
Karsten Hopp 56ffd8
CHANGES=1
Karsten Hopp 16bcfe
Karsten Hopp 16bcfe
DATE=`date +"%a %b %d %Y"`
Karsten Hopp 18943c
fedpkg switch-branch master
Karsten Hopp 16bcfe
MAJORVERSION=`grep "define baseversion" vim.spec | cut -d ' ' -f 3`
Karsten Hopp 4a08e5
ORIGPL=`grep "define patchlevel" vim.spec | cut -d ' ' -f 3 | sed -e "s/^0*//g"`
Karsten Hopp 4a08e5
ORIGPLFILLED=`printf "%03d" $ORIGPL`
Karsten Hopp 16bcfe
Karsten Hopp 56ffd8
if [ ! -d vim-upstream ]; then
Karsten Hopp 56ffd8
   git clone https://github.com/vim/vim.git vim-upstream
Karsten Hopp bba8e9
else
Karsten Hopp 56ffd8
   pushd vim-upstream
Karsten Hopp 56ffd8
   git pull
Karsten Hopp 56ffd8
   popd
Karsten Hopp 56ffd8
fi
Karsten Hopp 56ffd8
Karsten Hopp 56ffd8
pushd vim-upstream
Karsten Hopp 871038
# get the latest tag. Might be tricky with other packages, but upstream vim uses just a single branch:
Karsten Hopp 56ffd8
LASTTAG=$(git describe --tags $(git rev-list --tags --max-count=1))
Karsten Hopp 871038
# vim upstream tags have the form v7.4.123. Remove the 'v' and get major release and patchlevel:
Karsten Hopp 56ffd8
UPSTREAMMAJOR=$(echo $LASTTAG | sed -e 's/v\([0-9]*\.[0-9]*\).*/\1/')
Karsten Hopp 56ffd8
LASTPL=`echo $LASTTAG| sed -e 's/.*\.//'`
Karsten Hopp 56ffd8
LASTPLFILLED=`printf "%03d" $LASTPL`
Karsten Hopp 56ffd8
if [ "$ORIGPLFILLED" == "$LASTPLFILLED" ]; then
Karsten Hopp 56ffd8
    echo "No new patchlevel available"
Karsten Hopp 56ffd8
    CHANGES=0
Karsten Hopp 56ffd8
fi
Karsten Hopp 56ffd8
rm -rf dist/* 2>/dev/null
Karsten Hopp 56ffd8
make unixall
Karsten Hopp 871038
# include patchlevel in tarball name so that older sources won't get overwritten:
Karsten Hopp 56ffd8
mv dist/vim-${UPSTREAMMAJOR}.tar.bz2 dist/vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2
Karsten Hopp 871038
# We don't include the full upstream changelog in the rpm changelog, just ship a file with
Karsten Hopp 871038
# the changes:
Karsten Hopp 56ffd8
git log > dist/README.patches
Karsten Hopp 56ffd8
popd
Karsten Hopp 56ffd8
Karsten Hopp 56ffd8
cp -f vim-upstream/dist/README.patches README.patches
Karsten Hopp 56ffd8
cp -f vim-upstream/dist/vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2 .
Karsten Hopp 50ff73
wget https://raw.githubusercontent.com/ignatenkobrain/vim-spec-plugin/master/ftplugin/spec.vim -O ftplugin-spec.vim
Karsten Hopp 50ff73
wget https://raw.githubusercontent.com/ignatenkobrain/vim-spec-plugin/master/syntax/spec.vim -O syntax-spec.vim
Karsten Hopp bcbb2a
if [ $CHANGES -ne 0 ]; then
Karsten Hopp 871038
   CHLOG="* $DATE Karsten Hopp <karsten@redhat.com> $UPSTREAMMAJOR"
Karsten Hopp 871038
   $debug sed -i -e "/Release: /cRelease: 1%{?dist}" $SPEC
Karsten Hopp 871038
   if [ "x$MAJORVERSION" != "x$UPSTREAMMAJOR" ]; then
Karsten Hopp 871038
      $debug sed -i -s "s/define baseversion: $MAJORVERSION/define baseversion: $UPSTREAMMAJOR=/" $SPEC
Karsten Hopp 871038
   fi
Karsten Hopp 871038
   $debug sed -i -e "s/define patchlevel $ORIGPLFILLED/define patchlevel $LASTPLFILLED/" $SPEC
Karsten Hopp 871038
   $debug sed -i -e "/\%changelog/a$CHLOG.$LASTPLFILLED-1\n- patchlevel $LASTPLFILLED\n" $SPEC
Karsten Hopp 871038
   $debug fedpkg new-sources vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2
Karsten Hopp 871038
   $debug git add vim.spec README.patches
Karsten Hopp 871038
   $debug git commit -m "- patchlevel $LASTPL" 
Karsten Hopp 871038
   $debug git push
Karsten Hopp 871038
   if [ $? -eq 0 ]; then
Karsten Hopp 871038
      $debug rm -f $HOME/.koji/config
Karsten Hopp 871038
      $debug fedpkg build
Karsten Hopp 871038
      $debug ln -sf ppc-config $HOME/.koji/config
Karsten Hopp 871038
   else
Karsten Hopp 871038
      echo "GIT push failed"
Karsten Hopp 871038
   fi
Karsten Hopp bba8e9
fi