| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
if ! git status 2>&1 > /dev/null ; then |
| 4 |
echo "not on a git directory"; |
| 5 |
exit 1; |
| 6 |
fi |
| 7 |
|
| 8 |
if ! git status -b -s | grep debian/ 2>&1 > /dev/null ; then |
| 9 |
echo "not on a debian branch"; |
| 10 |
exit 1; |
| 11 |
fi |
| 12 |
|
| 13 |
DEB_UPSTREAM_MAJOR_VERSION=6 |
| 14 |
UPSTREAMBRANCH="ImageMagick-$DEB_UPSTREAM_MAJOR_VERSION" |
| 15 |
|
| 16 |
DEHS_STATUS=`uscan --report --dehs`; |
| 17 |
if echo $DEHS_STATUS | grep "<status>Newer version available</status>" > /dev/null ; then |
| 18 |
DOWNLOAD_NAME=`echo "$DEHS_STATUS" | grep "<upstream-url>" | sed "s/^<upstream-url>ftp\:\/\/\(.*\)<\/upstream-url>$/\1/g" | sed "s/.*\/\(.*\)/\1/g"` |
| 19 |
if test ! -f ../`echo $DOWNLOAD_NAME`; then |
| 20 |
echo "download new version" |
| 21 |
uscan --download --destdir .. --verbose || (echo "fail to download" && exit 77) |
| 22 |
fi; |
| 23 |
else |
| 24 |
echo "download up to date" |
| 25 |
fi; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
DEB_UPSTREAM_VERSION=`echo "$DEHS_STATUS" | grep "<upstream-version>" | sed "s/<upstream-version>\(.*\)<\/upstream-version>/\1/g"` |
| 30 |
DEB_UPSTREAM_VERSION_CHANGELOG=`echo $DEB_UPSTREAM_VERSION | sed "s/\(.*\)\(\.\)\([:digit:]*\)/\1-\3/g"` |
| 31 |
DEB_VERSION=`dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' '` |
| 32 |
DEB_NOEPOCH_VERSION=`echo $DEB_VERSION | cut -d: -f2-` |
| 33 |
NEW_DEBIAN_VERSION=$DEB_UPSTREAM_VERSION-1 |
| 34 |
|
| 35 |
if git checkout "debian-patches/$NEW_DEBIAN_VERSION" 2>&1 > /dev/null; then |
| 36 |
echo "Debian version for $DEB_UPSTREAM VERSION already commited"; |
| 37 |
exit 1; |
| 38 |
fi |
| 39 |
|
| 40 |
|
| 41 |
#retrieve recent svn commit |
| 42 |
git svn fetch || exit 2 |
| 43 |
git checkout "origin/$UPSTREAMBRANCH" || exit 2 |
| 44 |
SVN_REV=`grep "New version $DEB_UPSTREAM_VERSION_CHANGELOG" ChangeLog | sed "s/.*SVN revision \([0-9]*\).*/\1/g"` |
| 45 |
if test "z$SVN_REV" = "z"; then |
| 46 |
echo "Could not found revision"; |
| 47 |
exit 3; |
| 48 |
fi |
| 49 |
|
| 50 |
echo "find git rev for svn r$SVN_REV:" |
| 51 |
GIT_SVN_REV=`git svn find-rev r$SVN_REV` |
| 52 |
echo "is $GIT_SVN_REV" |
| 53 |
git checkout $GIT_SVN_REV || exit 5 |
| 54 |
# git revision for svn commit |
| 55 |
git checkout -b upstream/$DEB_UPSTREAM_VERSION |
| 56 |
# remove all exept git |
| 57 |
find ./* -path './.git' -prune -o -exec rm -rf '{}' + |
| 58 |
tar --strip 1 -xaf ../imagemagick_$DEB_UPSTREAM_VERSION.orig.tar.bz2 # extract origin |
| 59 |
git add . #add everything |
| 60 |
git commit -a -m "add upstream tar.bz2" # commit new upstream |
| 61 |
pristine-tar commit ../imagemagick_$DEB_UPSTREAM_VERSION.orig.tar.bz2 upstream/$DEB_UPSTREAM_VERSION # pristine tar |
| 62 |
git checkout debian/$DEB_NOEPOCH_VERSION # checkout old debian |
| 63 |
git checkout -b debian/$DEB_UPSTREAM_VERSION-1 # create new version |
| 64 |
# emulate git their |
| 65 |
git merge --no-commit upstream/$DEB_UPSTREAM_VERSION # merge without commit |
| 66 |
find ./* -path './debian' -prune -o -path './.git' -prune -o -exec rm -rf '{}' + # remove all except debian and git |
| 67 |
tar --strip 1 -xaf ../imagemagick_$DEB_UPSTREAM_VERSION.orig.tar.bz2 # use upstream |
| 68 |
git add . |
| 69 |
git commit -a -m 'merge with upstream' # emulate git theirs but safer |
| 70 |
git checkout upstream/$DEB_UPSTREAM_VERSION |
| 71 |
git checkout -b debian-patches/$DEB_UPSTREAM_VERSION-1 |