donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

gana-generate.sh (1478B)


      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 ]; then
     11   echo "Please run this script from the root of the source tree!"
     12   exit 1
     13 fi
     14 
     15 COMMIT_HASH=""
     16 if [ ! -z "${1:-}" ]; then
     17   COMMIT_HASH=$1
     18 fi
     19 
     20 # This is more portable than `which' but comes with
     21 # the caveat of not(?) properly working on busybox's ash:
     22 existence()
     23 {
     24     type "$1" >/dev/null 2>&1
     25 }
     26 
     27 
     28 domake ()
     29 {
     30     # $1 -- dir under contrib/
     31     dir="contrib/$1"
     32 
     33     make -C $dir
     34 }
     35 
     36 ensure ()
     37 {
     38     # $1 -- filename
     39     # $2 -- src dir under contrib/
     40     # $3 -- dst dir under ./
     41     fn="$1"
     42     src="contrib/$2/$fn"
     43     tmp_dst="./$3/$fn.tmp"
     44     dst="./$3/$fn"
     45 
     46     cat $src | uncrustify -l c -c uncrustify.cfg > $tmp_dst
     47     if ! diff $tmp_dst $dst > /dev/null
     48     then
     49         test ! -f $dst || chmod +w $dst
     50         cp $tmp_dst $dst
     51         chmod -w $dst
     52     fi
     53     rm $tmp_dst
     54 }
     55 
     56 gana_update()
     57 {
     58     echo "Updating GANA..."
     59     if ! existence git; then
     60       echo "Script requires git"
     61       exit 1
     62     fi
     63     if ! existence recfmt; then
     64       echo "Script requires recutils"
     65       exit 1
     66     fi
     67     cd contrib/gana || exit 1
     68     if [ ! -z "${COMMIT_HASH}" ]; then
     69       git checkout "${COMMIT_HASH}" || exit 1
     70       git pull
     71     fi
     72     cd $SRC_ROOT
     73     domake                    sigp
     74     ensure donau_signatures.h sigp src/include
     75 }
     76 
     77 gana_update