| #!/bin/bash |
| debug="" |
| |
| branches=( "f25" "f26" "f27" "master" ) |
| releases=( "fc26" "fc26" "fc27" "fc28" ) |
| branches_count=4 |
| releases_regexp=fc25\\\|fc26\\\|fc27\\\|fc28 |
| branches_index=0 |
| release_index=0 |
| |
| cd `dirname $0` |
| LANG=C |
| SPEC=vim.spec |
| CHANGES=1 |
| force=0 |
| |
| if [ "x$1" == "x--force" ]; then |
| force=1 |
| fi |
| |
| DATE=`date +"%a %b %d %Y"` |
| fedpkg switch-branch "${branches[@]: $branches_index: 1}" |
| |
| |
| if [ $? -ne 0 ]; then |
| echo "Error with switching branch" |
| exit 1 |
| fi |
| |
| MAJORVERSION=`grep "define baseversion" vim.spec | cut -d ' ' -f 3` |
| ORIGPL=`grep "define patchlevel" vim.spec | cut -d ' ' -f 3 | sed -e "s/^0*//g"` |
| ORIGPLFILLED=`printf "%03d" $ORIGPL` |
| |
| if [ ! -d vim-upstream ]; then |
| git clone https://github.com/vim/vim.git vim-upstream |
| else |
| pushd vim-upstream |
| git pull |
| popd |
| fi |
| |
| pushd vim-upstream |
| |
| LASTTAG=$(git describe --tags $(git rev-list --tags --max-count=1)) |
| |
| UPSTREAMMAJOR=$(echo $LASTTAG | sed -e 's/v\([0-9]*\.[0-9]*\).*/\1/') |
| LASTPL=`echo $LASTTAG| sed -e 's/.*\.//;s/^0*//'` |
| LASTPLFILLED=`printf "%03d" $LASTPL` |
| if [ $force -ne 1 -a "$ORIGPLFILLED" == "$LASTPLFILLED" ]; then |
| echo "No new patchlevel available" |
| CHANGES=0 |
| fi |
| rm -rf dist/* 2>/dev/null |
| make unixall |
| |
| mv dist/vim-${UPSTREAMMAJOR}.tar.bz2 dist/vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2 |
| |
| |
| git log > dist/README.patches |
| popd |
| |
| cp -f vim-upstream/dist/README.patches README.patches |
| cp -f vim-upstream/dist/vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2 . |
| |
| |
| if [ $CHANGES -ne 0 ]; then |
| CHLOG="* $DATE Karsten Hopp <karsten@redhat.com> $UPSTREAMMAJOR" |
| $debug sed -i -e "/Release: /cRelease: 1%{?dist}" $SPEC |
| if [ "x$MAJORVERSION" != "x$UPSTREAMMAJOR" ]; then |
| $debug sed -i -s "s/define baseversion: $MAJORVERSION/define baseversion: $UPSTREAMMAJOR=/" $SPEC |
| fi |
| $debug sed -i -e "s/define patchlevel $ORIGPLFILLED/define patchlevel $LASTPLFILLED/" $SPEC |
| $debug sed -i -e "/\%changelog/a$CHLOG.$LASTPLFILLED-1\n- patchlevel $LASTPLFILLED\n" $SPEC |
| $debug fedpkg new-sources vim-${UPSTREAMMAJOR}-${LASTPLFILLED}.tar.bz2 |
| $debug git add vim.spec README.patches |
| $debug git commit -m "- patchlevel $LASTPL" |
| |
| $debug fedpkg mockbuild |
| if [ $? -ne 0 ]; then |
| echo "Error: fedpkg mockbuild" |
| exit 1 |
| fi |
| |
| $debug fedpkg push |
| if [ $? -ne 0 ]; then |
| echo "Error: fedpkg push" |
| exit 1 |
| fi |
| |
| |
| pending_update=`bodhi updates query --packages vim --status pending \ |
| | grep $releases_regexp` |
| testing_update=`bodhi updates query --packages vim --status testing \ |
| | grep $releases_regexp` |
| |
| releases_regexp=${releases_regexp#*|} |
| |
| if [ "$pending_update" == "" ] && [ "$testing_update" == "" ]; then |
| fedpkg build |
| if [ $? -eq 0 ]; then |
| bodhi updates new --user zdohnal --type enhancement --notes "The newest upstream commit" --request testing --autokarma --stable-karma 3 --unstable-karma -3 vim-${UPSTREAMMAJOR}.${LASTPLFILLED}-1.${releases[@]: $release_index: 1} |
| else |
| echo "Error when building package in $branch" |
| exit 1 |
| fi |
| else |
| echo "There are pending/testing updates, do not build package." |
| fi |
| |
| let "release_index+=1" |
| |
| for branch in "${branches[@]:(1)}"; |
| do |
| |
| $debug fedpkg switch-branch $branch |
| |
| $debug bash -c "git merge ${branches[@]: $branches_index: 1} <<<':x'" |
| if [ $? -ne 0 ]; then |
| echo "Error: git merge ${branches[@]: $branches_index: 1}" |
| exit 1 |
| fi |
| |
| $debug fedpkg mockbuild |
| if [ $? -ne 0 ]; then |
| echo "Error: fedpkg mockbuild failed" |
| exit 1 |
| fi |
| |
| $debug fedpkg push |
| if [ $? -ne 0 ]; then |
| echo "Error: fedpkg push" |
| exit 1 |
| fi |
| |
| |
| pending_update=`bodhi updates query --packages vim --status pending \ |
| | grep $releases_regexp` |
| testing_update=`bodhi updates query --packages vim --status testing \ |
| | grep $releases_regexp` |
| if [ "$pending_update" == "" ] && [ "$testing_update" == "" ]; then |
| fedpkg build |
| if [ $? -eq 0 ]; then |
| if [ $branch != "master" ]; then |
| bodhi updates new --user zdohnal --type enhancement --notes "The newest upstream commit" --request testing --autokarma --stable-karma 3 --unstable-karma -3 vim-${UPSTREAMMAJOR}.${LASTPLFILLED}-1.${releases[@]: $release_index: 1} |
| fi |
| else |
| echo "Error when building package for $branch" |
| exit 1 |
| fi |
| fi |
| |
| |
| let "branches_index+=1" |
| let "release_index+=1" |
| releases_regexp=${releases_regexp#*|} |
| done |
| |
| |
| |
| |
| |
| |
| |
| |
| fi |
| exit 0 |