Whamcloud - gitweb
LU-3208 tests: Fix typo in replay-single/70b
[fs/lustre-release.git] / lustre / kernel_patches / scripts / new-kernel
1 #!/bin/sh
2
3 usage()
4 {
5         echo "Usage: new-kernel linux-2.4.2-pre2 linux-2.4.3-pre3 linux-2.4.3 patch.gz cvs-dir"
6         exit 1
7 }
8
9 wantdir()
10 {
11         if [ x$1 = x ]
12         then
13                 usage
14         fi
15         if [ ! -d $1 ]
16         then
17                 echo "directory $1 does not exist"
18                 usage
19         fi
20 }
21
22 wantfile()
23 {
24         if [ x$1 = x ]
25         then
26                 usage
27         fi
28         if [ ! -f $1 ]
29         then
30                 echo "file $1 does not exist"
31                 usage
32         fi
33 }
34
35 doit()
36 {
37         echo $* 1>&2
38         $* || {
39                 echo oops
40                 exit 1 
41         }
42 }
43
44
45 CURRENT_KERNEL=$1
46 NEXT_KERNEL=$2
47 BASE_KERNEL=$3
48 PATCH_FILE=$4
49 CVS_DIR=$5
50
51 TEMP_PATCH=$(mktemp /tmp/patch-XXXXXX)
52 MY_DIFF="$CURRENT_KERNEL"--"$NEXT_KERNEL"
53
54 wantdir $CURRENT_KERNEL
55 wantdir $BASE_KERNEL
56 wantdir $CVS_DIR
57 wantfile $PATCH_FILE
58
59 doit rm -rf $NEXT_KERNEL
60 doit cp -a $BASE_KERNEL $NEXT_KERNEL
61 doit rm -f $TEMP_PATCH
62 doit gunzip < $PATCH_FILE > $TEMP_PATCH
63 cd $NEXT_KERNEL
64 doit patch -p1 --dry-run -i $TEMP_PATCH
65 doit patch -p1 -s -i $TEMP_PATCH
66 echo cd ..
67 cd ..
68
69 echo diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL
70 diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL > $MY_DIFF
71
72 echo cd $CVS_DIR
73 cd $CVS_DIR
74 doit patch -p1 --dry-run -s -i ../$MY_DIFF
75 doit patch -p1 -s -i ../$MY_DIFF
76 cvs-take-patch ../$MY_DIFF
77 cvs commit -m "'doing $NEXT_KERNEL'"
78 cvs update -ko -d -P
79
80 TAG=$(echo $NEXT_KERNEL | sed -e 's@\.@_@g')
81 cvs tag $TAG
82 rm -f $TEMP_PATCH