gen-procedures.sh (1724B)
1 #!/bin/sh 2 3 # This file is part of TALER 4 # Copyright (C) 2026 Taler Systems SA 5 # 6 # TALER is free software; you can redistribute it and/or modify it under the 7 # terms of the GNU General Public License as published by the Free Software 8 # Foundation; either version 3, or (at your option) any later version. 9 # 10 # TALER is distributed in the hope that it will be useful, but WITHOUT ANY 11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License along with 15 # TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 16 17 set -eu 18 19 if [ $# -lt 2 ]; then 20 echo "Usage: $0 SCHEMANAME SQLFILES..." >&2 21 exit 1 22 fi 23 24 25 # Output preamble 26 27 cat <<'EOF' 28 -- 29 -- This file is part of TALER 30 -- Copyright (C) 2024-2026 Taler Systems SA 31 -- 32 -- TALER is free software; you can redistribute it and/or modify it under the 33 -- terms of the GNU General Public License as published by the Free Software 34 -- Foundation; either version 3, or (at your option) any later version. 35 -- 36 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 37 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 38 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 39 -- 40 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 41 -- 42 43 BEGIN; 44 EOF 45 46 echo "CREATE SCHEMA IF NOT EXISTS $1;" 47 echo "SET search_path TO $1;" 48 shift 1 49 50 51 # Output procedures, stripping comments 52 53 for x in $@; do 54 echo -- generated from $x 55 # Remove SQL comments and empty lines 56 cat $x | sed -e "s/--.*//" | awk 'NF' 57 done 58 59 echo "COMMIT;"