Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[fs/lustre-release.git] / lustre / kernel_patches / scripts / pushpatch
1 #!/bin/sh
2
3 #
4 # Add next patch in series
5 #
6
7 . patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
8         echo "Impossible to find my library 'patchfns'."
9         echo "Check your install, or go to the right directory"
10         exit 1
11 }
12
13 usage()
14 {
15         echo "Usage: pushpatch [npatches]"
16         exit 1
17 }
18
19 opt_force=0
20
21 for i in $*
22 do
23         case "$i" in
24         -f)
25                 opt_force=1;;
26         *)
27                 if [ -n "$NR" -o -n "$STOP_AT" ]
28                 then
29                         usage
30                 fi
31                 if is_numeric $i
32                 then
33                         NR=$i
34                 else
35                         NR=1000
36                         STOP_AT=$(stripit $i)
37                 fi;;
38         esac
39 done
40
41 [ $opt_force = 1 ] && force="-f"
42
43 SERIES=series
44
45 if [ ! -e $SERIES ]
46 then
47         echo 'File "series" not found'
48         exit 1
49 fi
50
51 push_one()
52 {
53         top=$(toppatch)
54         if [ x"$top" == x ]
55         then
56                 todo=$(head -1 $SERIES)
57         else
58                 last_in_series=$(stripit $(tail -1 $SERIES))
59                 if [ $last_in_series == $top ]
60                 then
61                         echo "Series fully applied.  Ends at $top"
62                         exit 0
63                 fi
64                 todo=$(grep -C1 "^$top\.patch" $SERIES | tail -1)
65                 if [ x$todo = x ]
66                 then
67                         todo=$(head -1 $SERIES)
68                 fi
69         fi
70
71         apatch $force $todo
72 }
73
74 for i in $(seq 1 $NR)
75 do
76         push_one
77         if [ x$STOP_AT != "x" ]
78         then
79                 if [ $STOP_AT == $(toppatch) ]
80                 then
81                         sum-series applied-patch
82                         exit 0
83                 fi
84         fi
85 done
86 sum-series applied-patch