Whamcloud - gitweb
9c5c5d2c7fec5420a91fd31921699c2e91675447
[fs/lustre-release.git] / build / extract_patches
1 #!/bin/bash
2
3 # extract all of the changesets since the last tagged version and put them
4 # into debian/patche{s,d} as if this was a patched tree on that tag
5
6 TARGET="$1"
7
8 ver=$(git describe --match [0-9v]\* --tags)
9 if [[ $ver = *-*-* ]]; then
10         hash=${ver##*-}
11         ffw=${ver#*-}
12         ffw=${ffw%-*}
13         ver=${ver%%-*}
14 fi
15 if [ $ffw -gt 0 ]; then
16         tag=$ver
17         if [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]; then
18                 ver=$(echo $ver |
19                   sed -e 's/^v\(.*\)/\1/'
20                       -e 's/_RC[0-9].*$//'
21                       -e 's/_/./g')
22         fi
23         pdir="$TARGET/debian/patches"
24         if [ -d $pdir ]; then
25                 rm -rf $pdir
26         fi
27         mkdir $pdir
28         git format-patch -o $pdir $tag..HEAD
29         pushd $pdir
30         if [ -d ../patched ]; then
31                 rm -rf ../patched
32         fi
33         mkdir ../patched
34         rm -f 00list *.dpatch
35         for file in [0-9][0-9][0-9][0-9]-*.patch; do
36                 if ! grep -q "^--- a/debian/" $file; then
37                         desc=$(cat $file | sed -e '1,/^$/d' \
38                                                  -e '/^---$/,$d')
39                         dpatch_file=${file/.patch/.dpatch}
40                         sed -e '1,/^---$/d' $file | \
41                           dpatch patch-template -p "${file%.patch}" \
42                           "$desc" > $dpatch_file
43                         echo "faked by make debs run from git" > \
44                           ../patched/$dpatch_file
45                         echo $dpatch_file >> 00list
46                 fi
47                 rm -f $file
48         done
49 fi