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