#!/bin/bash #set -x NR=0 set -e function ver { eval `cat Makefile | head -4 | perl -pe 's/ //g'` echo $VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION } function gitaddnew { git ls-files -o --exclude-standard | xargs --no-run-if-empty git add } VER=$(ver) if ! [ -d .git ]; then echo first patch run?? >&2 echo ver: $VER CDIR="$HOME/rpm2git-linux.git" if ! [ -d "$CDIR" ]; then git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6-stable.git $CDIR fi ln -s $CDIR/.git .git git remote update git fetch --tags echo adding... gitaddnew echo diffing... if ! git diff v$VER | head -100 | diffstat | grep '^ 0 files changed'; then echo unable to find starting git revision exit 1 fi git reset v$(ver) echo diffstat: git diff v$VER | head -100 | diffstat git describe echo sleeping... sleep 10 VER="" fi PATCHNEXT=false PATCH="$(readlink /proc/self/fd/0)" for arg in "$@"; do if $PATCHNEXT; then PATCH="$arg" break; fi if [ "$arg" == "-i" ]; then PATCHNEXT=true fi; done echo PATCH: "'$PATCH'" { echo my stdin is from \"`readlink /proc/self/fd/0`\" echo PATCH: "'$PATCH'" echo args: "$@" } >> ~/logs/patch.log function cherry_pick { PATCH="$1" COMMIT=$(formail -x Commit-ID < "$PATCH") if [ -z "$COMMIT" ]; then return -1; fi # TODO: check that the patch in git is the # same as the one in the RPM. They are # not always echo cherry picking commit: "'$COMMIT'" if ! git cherry-pick $COMMIT; then echo aborting bad cherry pick git reset --hard HEAD return -2 fi return 0 } function git_am { if ! git am "$PATCH"; then git am --skip git reset --hard HEAD return -2 fi return 0; } # Cherry picking seems like it would be nice to use # but it appears that at least openSUSE rpms have # patches with a 'Commit-ID:' in them that are not # quite the same as the commit in git with that id. # Oh, well. # #if cherry_pick "$PATCH"; then # echo cherry picked patch #el if git_am "$PATCH"; then echo am\'d patch elif /usr/bin/patch "$@"; then gitaddnew git commit -a -m "fill me in" fi; # there is almost certainly a better way of doing this # RET=$? VER2=$(ver) if [ "$VER" == "$VER2" ]; then echo done, `git describe` exit $RET fi echo changing ver from $VER to $VER2 VER=$VER2 #set -x git describe gitaddnew # back out the patch git reset --hard HEAD^ #COMMIT=`git rev-list v$VER -n 1` git merge v$VER git describe exit $RET