gana-update.sh (2045B)
1 #!/bin/sh 2 # Helper script to recompute error codes based on submodule 3 # Run from exchange/ main directory. 4 set -eu 5 6 # Generate taler-error-codes.h in gana and copy it to 7 # src/include/taler_error_codes.h 8 cd contrib/gana/gnu-taler-error-codes 9 make 10 cd ../../.. 11 cat contrib/gana/gnu-taler-error-codes/taler_error_codes.h | sed -e "s/GNU_TALER_ERROR_CODES_H/GNU_ANASTASIS_ERROR_CODES_H/" -e "s/taler_error_codes.h/anastasis_error_codes.h/" > src/include/anastasis_error_codes.h 12 13 SRC_ROOT=$PWD 14 15 if [ ! -f $SRC_ROOT/contrib/gana-update.sh ]; then 16 echo "Please run this script from the root of the source tree!" 17 exit 1 18 fi 19 20 COMMIT_HASH="" 21 if [ ! -z $1 ]; then 22 COMMIT_HASH=$1 23 fi 24 25 # This is more portable than `which' but comes with 26 # the caveat of not(?) properly working on busybox's ash: 27 existence() 28 { 29 type "$1" >/dev/null 2>&1 30 } 31 32 33 domake () 34 { 35 # $1 -- dir under contrib/ 36 dir="./contrib/$1" 37 38 make -C $dir 39 } 40 41 ensure () 42 { 43 # $1 -- filename 44 # $2 -- src dir under contrib/ 45 # $3 -- dst dir under ./ 46 fn="$1" 47 src="./contrib/$2/$fn" 48 tmp_dst="./$3/$fn.tmp" 49 dst="./$3/$fn" 50 51 cat $src | uncrustify -l c -c uncrustify.cfg > $tmp_dst 52 if ! diff $tmp_dst $dst > /dev/null 53 then 54 test ! -f $dst || chmod +w $dst 55 cp $tmp_dst $dst 56 chmod -w $dst 57 fi 58 rm $tmp_dst 59 } 60 61 gana_update() 62 { 63 echo "Updating GANA..." 64 if ! existence git; then 65 echo "Script requires git" 66 exit 1 67 fi 68 if ! existence recfmt; then 69 echo "Script requires recutils" 70 exit 1 71 fi 72 cd contrib/gana || exit 1 73 if [ ! -z "${COMMIT_HASH}" ]; then 74 git checkout "${COMMIT_HASH}" || exit 1 75 git pull 76 fi 77 cd $SRC_ROOT 78 domake gana/gnu-taler-error-codes 79 cat contrib/gana/gnu-taler-error-codes/taler_error_codes.h | \ 80 uncrustify -l c -c uncrustify.cfg | \ 81 sed -e "s/GNU_TALER_ERROR_CODES_H/GNU_ANASTASIS_ERROR_CODES_H/" -e "s/taler_error_codes.h/anastasis_error_codes.h/" > src/include/anastasis_error_codes.h 82 } 83 84 gana_update