fix warnings
[pluto.git] / apply_patches.sh
blob3b35292bd56919d2c2b7c58a95a514987e394f71
1 #!/bin/bash
3 export BASE=`pwd`
5 # ------------------------------------------------
6 # Utility functions
7 # ------------------------------------------------
9 # Tries to apply a patch from the given directory. Exits the program if it
10 # fails
11 check_and_apply_patch() {
12 local path="$1"
13 local patch="$2"
15 if [ \( -d ${BASE}/$path \) -a \( ! -f ${BASE}/$path/.`basename $patch` \) ] ; then
16 echo Hello
17 echo -e "\nTrying to apply patch from directory: `pwd`"
18 `git apply --check --directory=$path $patch`
19 exit_status=$?
21 if [ $exit_status -ne 0 ]; then
22 echo -e "Failed to apply patch $patch in directory ${BASE}/$path"
23 exit 1
24 else
25 cd ${BASE}/$path; git am $patch
26 # it could have still failed (note that this is git-am, not git apply)
27 exit_status=$?
28 cd -
30 if [ $exit_status -ne 0 ]; then
31 echo -e "git-am failed on patch $patch in directory ${BASE}/$path"
32 exit 1
33 else
34 touch ${BASE}/$path/.`basename $patch`
35 echo -e "Successfully applied patch $patch in directory ${BASE}/$path"
41 check_and_apply_patch "isl" "${BASE}/patches/0001-isl-dim-wise-single_valued-and-isl_pw_aff_map-functi.patch"