[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [IA64] Include automated sparse merge script



# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID 99f880fea7e1c0a8de8205897d635c4a80776696
# Parent  303406dd9e3b8c6ca280969bdca898252ef6da25
[IA64] Include automated sparse merge script

This script automates merging the sparse tree to new upstream
kernel revisions.  When possible the files are automatically
patched to the new version, if that fails, the xen and upstream
patches are tried in reverse order, if that fails, the method
producing the smallest reject is left for manual merging.

Run as:

# LINUXPATH=$HOME/linux-2.6 sparse-merge

Where LINUXPATH is a local mercurial tree of the upstream kernel
(available from http://www.kernel.org/hg/linux-2.6).  NEWTAG and
OLDTAG may also be specified if the autodetection does not work.
By default, NEWTAG will be the latest upstream version.  If NEWTAG
or OLDTAG is an extra-version (ex. 2.6.16.13), ketchup will be
used to update the mercurial tree and add the appropriate tag.

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
Signed-off-by: Aron Griffis <aron@xxxxxx>
---
 xen/arch/ia64/tools/sparse-merge |  137 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+)

diff -r 303406dd9e3b -r 99f880fea7e1 xen/arch/ia64/tools/sparse-merge
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/ia64/tools/sparse-merge  Tue May 16 12:54:26 2006 -0600
@@ -0,0 +1,137 @@
+#!/bin/bash
+# Generate a patch for each of the ia64 files in the linux-2.6-xen-sparse tree
+
+# Path to mercurial tree of upstream Linux
+# WARNING: This will do an 'hg up -C' on the upstream Linux tree, you
+#          will lose data if there's anything there you care about.
+: ${LINUXPATH:=/tmp/linux-2.6}
+# Tag of current base upstream image for Xen files
+: ${OLDTAG:=v$(awk '/^LINUX_VER/{print $NF}' buildconfigs/mk.linux-2.6-xen)}
+# Tag of new upstream base to go to
+: ${NEWTAG:=v$(wget -O- -o/dev/null http://kernel.org/kdist/finger_banner \
+    | awk '/latest stable/{print $NF}')}
+
+SPARSEDIR=linux-2.6-xen-sparse
+
+if [ ! -d $SPARSEDIR ]; then
+       echo "Can't find $SPARSEDIR directory."
+       exit
+fi
+
+WD=$PWD
+# We want the linux upsream tree to be at the OLDTAG to get the OLDTAG-Xen 
diff.
+# Save current revision to restore when done
+cd $LINUXPATH
+OLDCSET=$(hg parents | awk '/^changeset:/{print($2)}' | cut -f 1 -d :)
+for t in $OLDTAG $NEWTAG; do
+    if ! hg tags | cut -f1 -d' ' | grep -Fx $t; then
+       echo "Tag $t not found, ketching up"
+       hg up -C ${t%.*} || exit 1
+       ketchup ${t#v} || exit 1
+       hg addremove
+       hg ci -m $t
+       hg tag -l $t
+    fi
+done
+hg up -C $OLDTAG || exit 1
+cd $WD
+for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep ia64); do
+       cd $WD
+
+       FILENAME=$(basename $i)
+       DIRNAME=$(dirname $i)
+       DIFFPATH=$(echo $i | sed -e "s,^$SPARSEDIR,$LINUXPATH,")
+
+       if [ ! -d $DIRNAME ]; then
+               echo "Hmm, something bad happened parsing directory name: $i"
+               continue
+       fi
+
+       if [ ! -e $DIFFPATH ]; then
+               continue
+       fi
+
+       echo -n "$i ... "
+
+       cd $DIRNAME
+       XENDIR=$(pwd)
+
+       ### FIXME ###
+       hg revert $FILENAME
+
+       ORIGPATH=$(echo $i | sed -e "s/^$SPARSEDIR/./")
+       APATH=$(echo $i | sed -e "s/^$SPARSEDIR/a/")
+       BPATH=$(echo $i | sed -e "s/^$SPARSEDIR/b/")
+       cd $LINUXPATH
+       hg diff -r $OLDTAG -r $NEWTAG $ORIGPATH | \
+           sed -e "s,^--- $APATH,--- $FILENAME," \
+               -e "s,^+++ $BPATH,+++ $FILENAME," \
+           > $XENDIR/$FILENAME-$OLDTAG-$NEWTAG.diff
+       cd $XENDIR
+
+       # Do we have a diff file?  Did anything change?
+       if [ ! -s $FILENAME-$OLDTAG-$NEWTAG.diff ]; then
+               echo "SUCCESS (Upstream unchanged)"
+               continue
+       fi
+
+       if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1; then
+               # It failed, how badly?
+               if [ ! -e ${FILENAME}.rej ]; then
+                       echo "ERROR, Hmm, no .rej file, but diff failed, fix 
manually"
+                       continue
+               fi
+               TONEWREJ=$(wc -l ${FILENAME}.rej | \
+                          awk '{print($1)}')
+               hg revert $FILENAME
+               rm -f ${FILENAME}.rej ${FILENAME}.orig
+               diff -uN $DIFFPATH $FILENAME | \
+                   sed -e "s,^--- $DIFFPATH,--- $FILENAME," \
+                   > $FILENAME-$OLDTAG-Xen.diff
+
+               if [ ! -e $FILENAME-$OLDTAG-Xen.diff ]; then
+                       echo "ERROR, failed to create patch file"
+                       continue
+               fi
+
+               if ! patch -R -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; 
then
+                       echo "ERROR, reverting Xen changes failed"
+                       hg revert $FILENAME
+                       continue
+               fi
+
+               if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 
2>&1; then
+                       echo "ERROR, new upstream patch failed on reverted file"
+                       hg revert $FILENAME
+                       continue
+               fi
+
+               if ! patch -f -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; 
then
+                       if [ ! -e ${FILENAME}.rej ]; then
+                               echo "ERROR, Hmm, no .rej file, but diff 
failed, fix manually"
+                               continue
+                       fi
+                       TOXENREJ=$(wc -l ${FILENAME}.rej | \
+                                  awk '{print($1)}')
+
+                       if  [ $TOXENREJ -gt $TONEWREJ ]; then
+                               hg revert $FILENAME
+                               rm -f ${FILENAME}.rej ${FILENAME}.orig
+                               patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > 
/dev/null 2>&1
+                               echo "MANUAL MERGE REQUIRED (Upstream reject)"
+                       else
+                               echo "MANUAL MERGE REQUIRED (Xen reject)"
+                       fi
+
+               else
+                       rm -f ${FILENAME}.rej ${FILENAME}.orig
+                       echo "SUCCESS (Re-applied Xen patch)"
+               fi
+       else
+                       rm -f ${FILENAME}.rej ${FILENAME}.orig
+                       echo "SUCCESS (Upstream applied)"
+       fi
+done
+cd $LINUXPATH
+hg up $OLDCSET
+cd $WD

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.