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