summaryrefslogtreecommitdiffstats
path: root/src/do_patch.sh
blob: 899ec9bb32432e22eec2aa8ced2b4bdc87bc4b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

recipe=$1
ceph_dir=$PWD/src/ceph

if [ -n "$1" ]; then
    echo "recipe file: $1"
else
    echo "must supply one recipe file"
    exit
fi

if [ ! -f "$recipe" ]; then
    echo "recipe file $recipe doesn't exist"
    exit
fi

source $recipe

echo $PROJECT
echo $SUMMARY
echo $BRANCH
echo $REPO
echo $OPTION

do_patch() {
    echo ""
    echo "$PROJECT do_patch"
    cd $ceph_dir
    if [ -d "$PROJECT" ]; then
        rm -rf $PROJECT
    fi
    git clone -b $BRANCH $REPO $PROJECT
    cd $PROJECT
    for patch in ${SOURCES[@]}
    do
        echo ""
        echo $patch
        if [ ! -f "$ceph_dir/$patch" ]; then
            echo "$patch doesn't exit"
        fi
        check_results=`patch -p1 < $ceph_dir/$patch | grep FAILED`
        echo "command (patch -p1 < $ceph_dir/$patch) results are:"
        echo "$check_results"
        if [[ $check_results =~ "FAILED" ]]; then
            echo "$patch could not be applied successfully"
            exit
        fi
    done
}

do_patch