Whamcloud - gitweb
LU-3208 tests: Fix typo in replay-single/70b
[fs/lustre-release.git] / lustre / kernel_patches / scripts / export_patch
1 #!/bin/sh
2
3 . patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
4         echo "Impossible to find my library 'patchfns'."
5         echo "Check your install, or go to the right directory"
6         exit 1
7 }
8
9 usage()
10 {
11         echo "export_patch: export the patches listed in ./series" 1>&2
12         echo "usage: export_patch destination-directory [prefix] " 1>&2
13         exit 1
14 }
15
16 DIR="$1"
17 PREFIX="$2""_"
18
19 if [ "$DIR" = "" ]
20 then
21         usage
22 fi
23
24 if [ -e "$DIR" -a ! -d "$DIR" ]
25 then
26         echo "$DIR exists already, but is not a directory." 1>&2
27         exit 1
28 fi
29
30 if [ ! -r ./series ]
31 then
32         echo "./series is not readable." 1>&2
33         exit 1
34 fi
35
36 mkdir -p "$DIR" || exit 1
37
38 count=1
39 for x in `cat ./series`
40 do
41         fname=`echo "$count" "$PREFIX" "$x" |\
42                  awk '{ if ( $2 != "_" )
43                                 printf("p%05d_%s%s\n", $1, $2, $3); 
44                         else
45                                 printf("p%05d_%s\n", $1, $3); 
46                 }'`
47         if [ ! -r $P/patches/"$x" ]
48         then
49                 echo "$P/patches/"$x" is not readable. skipping." 1>&2
50                 continue;
51         fi
52         cp -f $P/patches/"$x" "$DIR"/"$fname" || continue; 
53         count=`expr $count + 1`
54 done
55