ia64/xen-unstable

view xen/arch/ia64/tools/sparse-merge @ 10888:5379548bfc79

[NET] Enable TCPv4 segmentation offload in front/back drivers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 01 11:54:45 2006 +0100 (2006-08-01)
parents 0dabd651b856
children
line source
1 #!/bin/bash
2 # Generate a patch for each of the ia64 files in the linux-2.6-xen-sparse tree
4 # Path to mercurial tree of upstream Linux
5 # WARNING: This will do an 'hg up -C' on the upstream Linux tree, you
6 # will lose data if there's anything there you care about.
7 : ${LINUXPATH:=/tmp/linux-2.6}
8 # Tag of current base upstream image for Xen files
9 : ${OLDTAG:=v$(awk '/^LINUX_VER/{print $NF}' buildconfigs/mk.linux-2.6-xen)}
10 # Tag of new upstream base to go to
11 : ${NEWTAG:=v$(wget -O- -o/dev/null http://kernel.org/kdist/finger_banner \
12 | awk '/latest stable/{print $NF}')}
13 # Restrict merge to specific arch (set to . for all)
14 : ${ARCH:=ia64}
16 SPARSEDIR=linux-2.6-xen-sparse
17 WD=$PWD
19 if [ ! -d $SPARSEDIR ]; then
20 echo "Can't find $SPARSEDIR directory."
21 exit
22 fi
24 # Check for modified files in the sparse tree before starting
25 if hg st $SPARSEDIR | head | grep .; then
26 echo
27 echo "$SPARSEDIR contains modifications, please clean it up first"
28 exit
29 fi
31 # We want the linux upstream tree to be at the OLDTAG to get the OLDTAG-Xen diff.
32 # Save current revision to restore when done
33 cd $LINUXPATH || exit 1
34 OLDCSET=$(hg parents | awk '/^changeset:/{print($2)}' | cut -f 1 -d :)
35 for t in $OLDTAG $NEWTAG; do
36 [[ $t == *.* ]] || continue
37 if ! hg tags | cut -f1 -d' ' | grep -Fx $t; then
38 echo "Tag $t not found, ketching up"
39 if [[ $t == *-* ]]; then
40 # rc/pre/git versions start at the previous stable release
41 micro=${t%%-*}; micro=${micro##*.}
42 stable=${t%%-*}; stable=${stable%.*}.$((micro-1))
43 hg up -C $stable
44 else
45 hg up -C ${t%.*} || exit 1
46 fi
47 ketchup ${t#v} || exit 1
48 hg addremove
49 hg ci -m $t
50 hg tag -l $t
51 fi
52 done
53 hg up -C $OLDTAG || exit 1
55 cd $WD
56 for i in $(hg manifest | awk '{print($3)}' | grep $SPARSEDIR | grep "$ARCH"); do
57 cd $WD
59 FILENAME=$(basename $i)
60 DIRNAME=$(dirname $i)
61 DIFFPATH=$(echo $i | sed -e "s,^$SPARSEDIR,$LINUXPATH,")
63 if [ ! -d $DIRNAME ]; then
64 echo "Hmm, something bad happened parsing directory name: $i"
65 continue
66 fi
68 if [ ! -e $DIFFPATH ]; then
69 continue
70 fi
72 echo -n "$i ... "
74 cd $DIRNAME
75 XENDIR=$(pwd)
77 ORIGPATH=$(echo $i | sed -e "s/^$SPARSEDIR/./")
78 APATH=$(echo $i | sed -e "s/^$SPARSEDIR/a/")
79 BPATH=$(echo $i | sed -e "s/^$SPARSEDIR/b/")
80 cd $LINUXPATH
81 hg diff -r $OLDTAG -r $NEWTAG $ORIGPATH | \
82 sed -e "s,^--- $APATH,--- $FILENAME," \
83 -e "s,^+++ $BPATH,+++ $FILENAME," \
84 > $XENDIR/$FILENAME-$OLDTAG-$NEWTAG.diff
85 cd $XENDIR
87 # Do we have a diff file? Did anything change?
88 if [ ! -s $FILENAME-$OLDTAG-$NEWTAG.diff ]; then
89 echo "SUCCESS (Upstream unchanged)"
90 continue
91 fi
93 if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1; then
94 # It failed, how badly?
95 if [ ! -e ${FILENAME}.rej ]; then
96 echo "ERROR, Hmm, no .rej file, but diff failed, fix manually"
97 continue
98 fi
99 TONEWREJ=$(wc -l ${FILENAME}.rej | \
100 awk '{print($1)}')
101 hg st $FILENAME | grep -q . && hg revert $FILENAME
102 rm -f ${FILENAME}.rej ${FILENAME}.orig
103 diff -uN $DIFFPATH $FILENAME | \
104 sed -e "s,^--- $DIFFPATH,--- $FILENAME," \
105 > $FILENAME-$OLDTAG-Xen.diff
107 if [ ! -e $FILENAME-$OLDTAG-Xen.diff ]; then
108 echo "ERROR, failed to create patch file"
109 continue
110 fi
112 if ! patch -R -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; then
113 echo "ERROR, reverting Xen changes failed"
114 hg revert $FILENAME
115 continue
116 fi
118 if ! patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1; then
119 echo "ERROR, new upstream patch failed on reverted file"
120 hg revert $FILENAME
121 continue
122 fi
124 if ! patch -f -i $FILENAME-$OLDTAG-Xen.diff > /dev/null 2>&1; then
125 if [ ! -e ${FILENAME}.rej ]; then
126 echo "ERROR, Hmm, no .rej file, but diff failed, fix manually"
127 continue
128 fi
129 TOXENREJ=$(wc -l ${FILENAME}.rej | \
130 awk '{print($1)}')
132 if [ $TOXENREJ -gt $TONEWREJ ]; then
133 hg revert $FILENAME
134 rm -f ${FILENAME}.rej ${FILENAME}.orig
135 patch -f -i $FILENAME-$OLDTAG-$NEWTAG.diff > /dev/null 2>&1
136 echo "MANUAL MERGE REQUIRED (Upstream reject)"
137 else
138 echo "MANUAL MERGE REQUIRED (Xen reject)"
139 fi
141 else
142 rm -f ${FILENAME}.rej ${FILENAME}.orig
143 echo "SUCCESS (Re-applied Xen patch)"
144 fi
145 else
146 rm -f ${FILENAME}.rej ${FILENAME}.orig
147 echo "SUCCESS (Upstream applied)"
148 fi
149 done
150 find $SPARSEDIR -name \*.diff -empty | xargs -r rm -f
151 cd $LINUXPATH
152 hg up -C $OLDCSET