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