commit 0406ec509a27b1bd22e088f329537b5f4df34cf0
parent c2db1c8442bbd30a8b595e5f1dda3a2d5901a094
Author: Florian Dold <florian@dold.me>
Date: Wed, 6 May 2026 13:40:55 +0200
properly (re-)generate procedures.sql via meson
Previously the SQL procedures amalgamation file was incorrectly
generated in the sources tree via abuse of the C preprocessor. A "make
install" would also not update the file properly, as its dependencies
were tracked outside the build system.
All input files are now tracked via meson and the algamation file is
generated via a simple custom meson target.
Diffstat:
6 files changed, 122 insertions(+), 160 deletions(-)
diff --git a/Makefile.am b/Makefile.am
@@ -1,29 +0,0 @@
-# This Makefile is in the public domain
-
-if DOC_ONLY
-if ENABLE_DOC
- SUBDIRS = . doc
-else
- SUBDIRS = .
-endif
-else
-if ENABLE_DOC
- SUBDIRS = . src contrib doc
-else
- SUBDIRS = . src contrib
-endif
-endif
-
-@DX_RULES@
-
-TESTS = contrib/check-prebuilt
-
-ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = \
- AUTHORS \
- COPYING.GPL \
- COPYING.AGPL \
- COPYING.LGPL \
- contrib/gnunet.tag \
- contrib/microhttpd.tag \
- contrib/taler-exchange.tag
diff --git a/contrib/Makefile.am.in b/contrib/Makefile.am.in
@@ -1,45 +0,0 @@
-# This file is in the public domain.
-
-SUBDIRS = typst .
-
-tmplpkgdatadir = $(prefix)/share/taler-merchant/templates/
-staticpkgdatadir = $(prefix)/share/taler-merchant/static/
-spapkgdatadir = $(prefix)/share/taler-merchant/spa/
-
-bin_SCRIPTS = \
- taler-merchant-dbconfig
-
-termsdir=$(datadir)/taler-merchant/terms/
-terms_DATA = \
- merchant-tos-tops-v0.en.rst \
- merchant-tos-demo-v0.en.rst
-
-EXTRA_DIST = \
- $(terms_DATA) \
- $(bin_SCRIPTS)
-
-dist_tmplpkgdata_DATA = \
- kyc_text.en.must \
- offer_refund.en.must \
- request_payment.en.must \
- show_order_details.en.must
-
-%.must: wallet-core/backend/%.html
- cp $< $@
-
-# Note: only works when building from Git, if you
-# run maintainer clean against the TGZ, you will
-# not be able to recover...
-MAINTAINERCLEANFILES = \
- $(dist_tmplpkgdata_DATA)
-
-# Note: historic mechanism for static resource files, currently not used.
-#dist_staticpkgdata_DATA = \
-# foo.css
-
-
-# This is for the single-page-app imported from the wallet-core.git
-# prebuilt branch. This MUST be the last line in the
-# Makefile.am.in, as it will be combined with the
-# actual SPA data by 'bootstrap'!
-dist_spapkgdata_DATA = \
diff --git a/src/backenddb/sql-schema/Makefile.sql b/src/backenddb/sql-schema/Makefile.sql
@@ -1,13 +0,0 @@
-procedures.sql: procedures.sql.in ../pg_*.sql
- chmod +w $@ || true
- gcc -E -P -undef - < procedures.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
- chmod ugo-w $@
-
-
-CLEANFILES = \
- procedures.sql
-
-all: ${CLEANFILES}
-
-clean:
- rm ${CLEANFILES}
diff --git a/src/backenddb/sql-schema/gen-procedures.sh b/src/backenddb/sql-schema/gen-procedures.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+# This file is part of TALER
+# Copyright (C) 2026 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+
+set -eu
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 SQLFILES..." >&2
+ exit 1
+fi
+
+
+# Output preamble
+
+cat <<'EOF'
+--
+-- This file is part of TALER
+-- Copyright (C) 2024-2026 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+BEGIN;
+
+SET search_path TO merchant;
+
+EOF
+
+# Output procedures, stripping comments
+
+for x in $@; do
+ echo -- generated from $x
+ # Remove SQL comments and empty lines
+ cat $x | sed -e "s/--.*//" | awk 'NF'
+done
+
+# Output epilogue
+
+cat <<'EOF'
+-- Epilogue
+DROP PROCEDURE IF EXISTS merchant_do_gc;
+CREATE PROCEDURE merchant_do_gc(in_now INT8)
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ DELETE FROM merchant_instances
+ WHERE validation_needed
+ AND validation_expiration < in_now;
+ CALL merchant_statistic_amount_gc ();
+ CALL merchant_statistic_bucket_gc ();
+ CALL merchant_statistic_counter_gc ();
+
+ DELETE FROM tan_challenges
+ WHERE expiration_date < in_now;
+ DELETE FROM merchant_unclaim_signatures
+ WHERE expiration_time < in_now;
+END $$;
+COMMENT ON PROCEDURE merchant_do_gc
+ IS 'calls all other garbage collection subroutines';
+
+COMMIT;
+EOF
diff --git a/src/backenddb/sql-schema/meson.build b/src/backenddb/sql-schema/meson.build
@@ -1,7 +1,33 @@
sqldir = get_option('datadir') / 'taler-merchant' / 'sql'
-# FIXME possibly provide this output in the tgz through dist script
-run_command('make', '-f', 'Makefile.sql', 'all', check: true)
+# Input files for the amalgamated procedures.sql.
+# The order matters.
+sql_procedures = [
+ '../pg_insert_deposit_to_transfer.sql',
+ '../pg_insert_product.sql',
+ '../pg_insert_issued_token.sql',
+ '../pg_insert_spent_token.sql',
+ '../pg_insert_transfer_details.sql',
+ '../pg_update_product.sql',
+ '../pg_solve_mfa_challenge.sql',
+ '../pg_account_kyc_set_status.sql',
+ '../pg_account_kyc_set_failed.sql',
+ '../pg_statistics_helpers.sql',
+ '../pg_do_handle_inventory_changes.sql',
+ '../pg_do_handle_category_changes.sql',
+ '../pg_update_product_group.sql',
+ '../pg_update_money_pot.sql',
+ '../pg_increment_money_pots.sql',
+ '../pg_account_kyc_get_status.sql',
+ '../pg_insert_transfer.sql',
+ '../pg_insert_deposit_confirmation.sql',
+ '../pg_base32_crockford.sql',
+ '../pg_uri_escape.sql',
+ '../pg_merchant_kyc_trigger.sql',
+ '../pg_merchant_send_kyc_notification.sql',
+ '../pg_activate_account.sql',
+ '../pg_inactivate_account.sql',
+]
sqlfiles = [
'drop.sql',
@@ -40,13 +66,21 @@ sqlfiles = [
'merchant-0033.sql',
'merchant-0034.sql',
'merchant-0035.sql',
- 'procedures.sql',
'versioning.sql',
]
+
+sql_procs = custom_target('sql_procedures',
+ input: sql_procedures,
+ output: 'procedures.sql',
+ capture: true,
+ command: ['./gen-procedures.sh', '@INPUT@'],
+ install: true,
+ install_dir: sqldir)
+
install_data(sources: sqlfiles, install_dir: sqldir)
# This makes meson copy the files into the build directory for testing
-foreach f : sqlfiles
- configure_file(input: f, output: f, copy: true)
-endforeach
+#foreach f : sqlfiles
+# configure_file(input: f, output: f, copy: true, install_mode: 'rw-r--r--')
+#endforeach
diff --git a/src/backenddb/sql-schema/procedures.sql.in b/src/backenddb/sql-schema/procedures.sql.in
@@ -1,67 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2024-2025 Taler Systems SA
---
--- TALER is free software; you can redistribute it and/or modify it under the
--- terms of the GNU General Public License as published by the Free Software
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-BEGIN;
-
-SET search_path TO merchant;
-
-#include "../pg_insert_deposit_to_transfer.sql"
-#include "../pg_insert_product.sql"
-#include "../pg_insert_issued_token.sql"
-#include "../pg_insert_spent_token.sql"
-#include "../pg_insert_transfer_details.sql"
-#include "../pg_update_product.sql"
-#include "../pg_solve_mfa_challenge.sql"
-#include "../pg_account_kyc_set_status.sql"
-#include "../pg_account_kyc_set_failed.sql"
-#include "../pg_statistics_helpers.sql"
-#include "../pg_do_handle_inventory_changes.sql"
-#include "../pg_do_handle_category_changes.sql"
-#include "../pg_update_product_group.sql"
-#include "../pg_update_money_pot.sql"
-#include "../pg_increment_money_pots.sql"
-#include "../pg_account_kyc_get_status.sql"
-#include "../pg_insert_transfer.sql"
-#include "../pg_insert_deposit_confirmation.sql"
-#include "../pg_base32_crockford.sql"
-#include "../pg_uri_escape.sql"
-#include "../pg_merchant_kyc_trigger.sql"
-#include "../pg_merchant_send_kyc_notification.sql"
-#include "../pg_activate_account.sql"
-#include "../pg_inactivate_account.sql"
-
-DROP PROCEDURE IF EXISTS merchant_do_gc;
-CREATE PROCEDURE merchant_do_gc(in_now INT8)
-LANGUAGE plpgsql
-AS $$
-BEGIN
- DELETE FROM merchant_instances
- WHERE validation_needed
- AND validation_expiration < in_now;
- CALL merchant_statistic_amount_gc ();
- CALL merchant_statistic_bucket_gc ();
- CALL merchant_statistic_counter_gc ();
-
- DELETE FROM tan_challenges
- WHERE expiration_date < in_now;
- DELETE FROM merchant_unclaim_signatures
- WHERE expiration_time < in_now;
-END $$;
-COMMENT ON PROCEDURE merchant_do_gc
- IS 'calls all other garbage collection subroutines';
-
-
-COMMIT;