rpms/kernel/devel/scripts rebase.sh,1.1,1.2

Jarod Wilson (jwilson) fedora-extras-commits at redhat.com
Tue Jul 10 16:08:51 UTC 2007


Author: jwilson

Update of /cvs/pkgs/rpms/kernel/devel/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv24434

Modified Files:
	rebase.sh 
Log Message:
Handle all sorts of additional rebase cases. Only case not handled that I've been able to throw at this thing so far is the rc/git -> stable release rebase, but that's easy enough to do by hand...


Index: rebase.sh
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/scripts/rebase.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rebase.sh	3 Jul 2007 20:26:11 -0000	1.1
+++ rebase.sh	10 Jul 2007 16:08:19 -0000	1.2
@@ -1,11 +1,29 @@
 #!/bin/bash
 
-# Is there a new snapshot ?
-export OLD=`grep ^patch upstream | tail -n1 | sed s/patch-// | sed s/\.bz2//`
+# Current kernel bits
+if [ `grep -c ^patch upstream` -ge 1 ]; then
+  export OLD=`grep ^patch upstream | tail -n1 | sed s/patch-// | sed s/\.bz2//`
+else
+  export OLD=`grep linux-2.6 upstream | tail -n1 | sed s/linux-// | sed s/\.tar\.bz2//`
+fi
 export OLDBASE=`echo $OLD | sed s/-/\ /g | sed s/2\.6\.// | awk '{ print $1 }'`
-export OLDRC=`echo $OLD | sed s/-/\ /g | sed s/rc// | awk '{ print $2 }'`
-export OLDGIT=`echo $OLD | sed s/-/\ /g | sed s/git// | awk '{ print $3 }'`
+if [ `echo $OLD | grep -c rc` -ge 1 ]; then
+  export OLDRC=`echo $OLD | sed s/-/\ /g | sed s/rc// | awk '{ print $2 }'`
+  if [ `echo $OLD | grep -c git` -ge 1 ]; then
+    export OLDGIT=`echo $OLD | sed s/-/\ /g | sed s/git// | awk '{ print $3 }'`
+  else
+    export OLDGIT=0
+  fi
+else
+  export OLDRC=0
+  if [ `echo $OLD | grep -c git` -ge 1 ]; then
+    export OLDGIT=`echo $OLD | sed s/-/\ /g | sed s/git// | awk '{ print $2 }'`
+  else
+    export OLDGIT=0
+  fi
+fi
 
+# Is there a new snapshot ?
 NEW=`lynx -dump http://www.kernel.org/kdist/finger_banner | grep "snapshot for the stable"`
 if [ "${?}" != 0 ] ; then
   echo "No new git snapshot of stable branch".
@@ -13,37 +31,66 @@
 fi
 export NEW=`echo $NEW | awk '{ print $11 }'`
 export NEWBASE=`echo $NEW | sed s/-/\ /g | sed s/2\.6\.// | awk '{ print $1 }'`
-export NEWRC=`echo $NEW | sed s/-/\ /g | sed s/rc// | awk '{ print $2 }'`
-export NEWGIT=`echo $NEW | sed s/-/\ /g | sed s/git// | awk '{ print $3 }'`
+if [ `echo $NEW | grep -c rc` -ge 1 ]; then
+  export NEWRC=`echo $NEW | sed s/-/\ /g | sed s/rc// | awk '{ print $2 }'`
+  if [ `echo $NEW | grep -c git` -ge 1 ]; then
+    export NEWGIT=`echo $NEW | sed s/-/\ /g | sed s/git// | awk '{ print $3 }'`
+  else
+    export NEWGIT=0
+  fi
+else
+  export NEWRC=0
+  if [ `echo $NEW | grep -c git` -ge 1 ]; then
+    export NEWGIT=`echo $NEW | sed s/-/\ /g | sed s/git// | awk '{ print $2 }'`
+  else
+    export NEWGIT=0
+  fi
+fi
 
 echo "OLD kernel was $OLD  BASE=$OLDBASE RC=$OLDRC GIT=$OLDGIT"
 echo "NEW kernel is  $NEW  BASE=$NEWBASE RC=$NEWRC GIT=$NEWGIT"
 
-if [ "$OLDBASE" = "$NEWBASE" ]; then
-  echo Same base
-else
-  echo "Rebasing across point releases not yet done."
-  exit
+if [ "$OLDRC" -eq 0 -a "$OLDGIT" -eq 0 -a "$OLDGIT" -ne "$NEWGIT" ]; then
+  echo "Rebasing from a stable release to a new git snapshot"
+  perl -p -i -e 's/^%define\ released_kernel\ 1/\%define\ released_kernel\ 0/' kernel-2.6.spec
+  # force these to zero in this case, they may not have been when we rebased to stable
+  perl -p -i -e 's/^%define\ rcrev.*/\%define\ rcrev\ 0/' kernel-2.6.spec
+  perl -p -i -e 's/^%define\ gitrev.*/\%define\ gitrev\ 0/' kernel-2.6.spec
 fi
 
 if [ "$OLDRC" != "$NEWRC" ]; then
   echo "Different rc. Rebasing from $OLDRC to $NEWRC"
-  perl -p -i -e 's/^%define\ rcrev\ $ENV{"OLDRC"}/\%define\ rcrev\ $ENV{"NEWRC"}/' kernel-2.6.spec
+  perl -p -i -e 's/^%define\ rcrev.*/\%define\ rcrev\ $ENV{"NEWRC"}/' kernel-2.6.spec
+  if [ `grep -c patch-2.6.$NEWBASE-rc$NEWRC.bz2 upstream` -eq 0 ]; then
+    echo patch-2.6.$NEWBASE-rc$NEWRC.bz2 >> .cvsignore
+    echo patch-2.6.$NEWBASE-rc$NEWRC.bz2 >> upstream
+  fi
 fi
 
 if [ "$OLDGIT" != "$NEWGIT" ]; then
-  echo "Different git. Rebasing from git$OLDGIT to git$NEWGIT"
-  perl -p -i -e 's/^%define\ gitrev\ $ENV{"OLDGIT"}/\%define\ gitrev\ $ENV{"NEWGIT"}/' kernel-2.6.spec
-  perl -p -i -e 's/$ENV{OLD}/$ENV{NEW}/' .cvsignore
-  perl -p -i -e 's/$ENV{OLD}/$ENV{NEW}/' upstream
-  #TODO: Remove the $OLD line from sources
+  if [ "$OLDRC" -eq 0 -a "$OLDGIT" -eq 0 ]; then
+    echo "Rebasing to pre-rc git$NEWGIT"
+  else
+    echo "Different git. Rebasing from git$OLDGIT to git$NEWGIT"
+  fi
+  perl -p -i -e 's/^%define\ gitrev.*/\%define\ gitrev\ $ENV{"NEWGIT"}/' kernel-2.6.spec
+  if [ "$OLDGIT" -ne 0 ]; then
+    perl -p -i -e 's/$ENV{OLD}/$ENV{NEW}/' .cvsignore
+    perl -p -i -e 's/$ENV{OLD}/$ENV{NEW}/' upstream
+    grep -v patch-$OLD.bz2 sources > .sources.tmp; mv .sources.tmp sources
+  else
+    echo patch-$NEW.bz2 >> .cvsignore
+    echo patch-$NEW.bz2 >> upstream
+  fi
 
   make download
   make upload FILES=patch-$NEW.bz2
 
   cvs add patch-$NEW.bz2.sign
-  rm -f patch-$OLD.bz2
-  rm -f patch-$OLD.bz2.sign
+  if [ "$OLDGIT" -ne 0 ]; then
+    rm -f patch-$OLD.bz2
+    rm -f patch-$OLD.bz2.sign
+  fi
   cvs remove patch-$OLD.bz2.sign
 fi
 




More information about the scm-commits mailing list