direct-io.hg

changeset 10123:99f880fea7e1

[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@hp.com>
Signed-off-by: Aron Griffis <aron@hp.com>
author awilliam@xenbuild.aw
date Tue May 16 12:54:26 2006 -0600 (2006-05-16)
parents 303406dd9e3b
children 998aa66b6502
files xen/arch/ia64/tools/sparse-merge
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xen/arch/ia64/tools/sparse-merge	Tue May 16 12:54:26 2006 -0600
     1.3 @@ -0,0 +1,137 @@
     1.4 +#!/bin/bash
     1.5 +# Generate a patch for each of the ia64 files in the linux-2.6-xen-sparse tree
     1.6 +
     1.7 +# Path to mercurial tree of upstream Linux
     1.8 +# WARNING: This will do an 'hg up -C' on the upstream Linux tree, you
     1.9 +#          will lose data if there's anything there you care about.
    1.10 +: ${LINUXPATH:=/tmp/linux-2.6}
    1.11 +# Tag of current base upstream image for Xen files
    1.12 +: ${OLDTAG:=v$(awk '/^LINUX_VER/{print $NF}' buildconfigs/mk.linux-2.6-xen)}
    1.13 +# Tag of new upstream base to go to
    1.14 +: ${NEWTAG:=v$(wget -O- -o/dev/null http://kernel.org/kdist/finger_banner \
    1.15 +    | awk '/latest stable/{print $NF}')}
    1.16 +
    1.17 +SPARSEDIR=linux-2.6-xen-sparse
    1.18 +
    1.19 +if [ ! -d $SPARSEDIR ]; then
    1.20 +	echo "Can't find $SPARSEDIR directory."
    1.21 +	exit
    1.22 +fi
    1.23 +
    1.24 +WD=$PWD
    1.25 +# We want the linux upsream tree to be at the OLDTAG to get the OLDTAG-Xen diff.
    1.26 +# Save current revision to restore when done
    1.27 +cd $LINUXPATH
    1.28 +OLDCSET=$(hg parents | awk '/^changeset:/{print($2)}' | cut -f 1 -d :)
    1.29 +for t in $OLDTAG $NEWTAG; do
    1.30 +    if ! hg tags | cut -f1 -d' ' | grep -Fx $t; then
    1.31 +	echo "Tag $t not found, ketching up"
    1.32 +	hg up -C ${t%.*} || exit 1
    1.33 +	ketchup ${t#v} || exit 1
    1.34 +	hg addremove
    1.35 +	hg ci -m $t
    1.36 +	hg tag -l $t
    1.37 +    fi
    1.38 +done
    1.39 +hg up -C $OLDTAG || exit 1
    1.40 +cd $WD
    1.41 +for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep ia64); do
    1.42 +	cd $WD
    1.43 +
    1.44 +	FILENAME=$(basename $i)
    1.45 +	DIRNAME=$(dirname $i)
    1.46 +	DIFFPATH=$(echo $i | sed -e "s,^$SPARSEDIR,$LINUXPATH,")
    1.47 +
    1.48 +	if [ ! -d $DIRNAME ]; then
    1.49 +		echo "Hmm, something bad happened parsing directory name: $i"
    1.50 +		continue
    1.51 +	fi
    1.52 +
    1.53 +	if [ ! -e $DIFFPATH ]; then
    1.54 +		continue
    1.55 +	fi
    1.56 +
    1.57 +	echo -n "$i ... "
    1.58 +
    1.59 +	cd $DIRNAME
    1.60 +	XENDIR=$(pwd)
    1.61 +
    1.62 +	### FIXME ###
    1.63 +	hg revert $FILENAME
    1.64 +
    1.65 +	ORIGPATH=$(echo $i | sed -e "s/^$SPARSEDIR/./")
    1.66 +	APATH=$(echo $i | sed -e "s/^$SPARSEDIR/a/")
    1.67 +	BPATH=$(echo $i | sed -e "s/^$SPARSEDIR/b/")
    1.68 +	cd $LINUXPATH
    1.69 +	hg diff -r $OLDTAG -r $NEWTAG $ORIGPATH | \
    1.70 +	    sed -e "s,^--- $APATH,--- $FILENAME," \
    1.71 +	        -e "s,^+++ $BPATH,+++ $FILENAME," \
    1.72 +	    > $XENDIR/$FILENAME-$OLDTAG-$NEWTAG.diff
    1.73 +	cd $XENDIR
    1.74 +
    1.75 +	# Do we have a diff file?  Did anything change?
    1.76 +	if [ ! -s $FILENAME-$OLDTAG-$NEWTAG.diff ]; then
    1.77 +		echo "SUCCESS (Upstream unchanged)"
    1.78 +		continue
    1.79 +	fi
    1.80 +
    1.81 +	if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1; then
    1.82 +		# It failed, how badly?
    1.83 +		if [ ! -e ${FILENAME}.rej ]; then
    1.84 +			echo "ERROR, Hmm, no .rej file, but diff failed, fix manually"
    1.85 +			continue
    1.86 +		fi
    1.87 +		TONEWREJ=$(wc -l ${FILENAME}.rej | \
    1.88 +		           awk '{print($1)}')
    1.89 +		hg revert $FILENAME
    1.90 +		rm -f ${FILENAME}.rej ${FILENAME}.orig
    1.91 +		diff -uN $DIFFPATH $FILENAME | \
    1.92 +		    sed -e "s,^--- $DIFFPATH,--- $FILENAME," \
    1.93 +		    > $FILENAME-$OLDTAG-Xen.diff
    1.94 +
    1.95 +		if [ ! -e $FILENAME-$OLDTAG-Xen.diff ]; then
    1.96 +			echo "ERROR, failed to create patch file"
    1.97 +			continue
    1.98 +		fi
    1.99 +
   1.100 +		if ! patch -R -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; then
   1.101 +			echo "ERROR, reverting Xen changes failed"
   1.102 +			hg revert $FILENAME
   1.103 +			continue
   1.104 +		fi
   1.105 +
   1.106 +		if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1; then
   1.107 +			echo "ERROR, new upstream patch failed on reverted file"
   1.108 +			hg revert $FILENAME
   1.109 +			continue
   1.110 +		fi
   1.111 +
   1.112 +		if ! patch -f -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; then
   1.113 +			if [ ! -e ${FILENAME}.rej ]; then
   1.114 +				echo "ERROR, Hmm, no .rej file, but diff failed, fix manually"
   1.115 +				continue
   1.116 +			fi
   1.117 +			TOXENREJ=$(wc -l ${FILENAME}.rej | \
   1.118 +			           awk '{print($1)}')
   1.119 +
   1.120 +			if  [ $TOXENREJ -gt $TONEWREJ ]; then
   1.121 +				hg revert $FILENAME
   1.122 +				rm -f ${FILENAME}.rej ${FILENAME}.orig
   1.123 +				patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1
   1.124 +				echo "MANUAL MERGE REQUIRED (Upstream reject)"
   1.125 +			else
   1.126 +				echo "MANUAL MERGE REQUIRED (Xen reject)"
   1.127 +			fi
   1.128 +
   1.129 +		else
   1.130 +			rm -f ${FILENAME}.rej ${FILENAME}.orig
   1.131 +			echo "SUCCESS (Re-applied Xen patch)"
   1.132 +		fi
   1.133 +	else
   1.134 +			rm -f ${FILENAME}.rej ${FILENAME}.orig
   1.135 +			echo "SUCCESS (Upstream applied)"
   1.136 +	fi
   1.137 +done
   1.138 +cd $LINUXPATH
   1.139 +hg up $OLDCSET
   1.140 +cd $WD