commit d9f6dc51cff7424dfc747bb16e1744416477697a parent 5b5b77894c26effff2bd543940babba61307e47f Author: Florian Dold <florian@dold.me> Date: Sun, 27 Jul 2025 12:49:33 +0200 debian: properly compress SPA files Also remove existing badly compressed files. Diffstat:
| M | debian/taler-exchange.postinst | | | 27 | +++++++++++++++++++-------- |
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/debian/taler-exchange.postinst b/debian/taler-exchange.postinst @@ -95,14 +95,25 @@ configure) /etc/taler-exchange/secrets/exchange-db.secret.conf fi - # Try to generate compressed versions of the SPAs - for n in forms.json index.css index.js index.html - do - TDIR="/usr/share/taler-exchange/" - gzip --best - < "${TDIR}/aml-spa/$n" > "${TDIR}/aml-spa/$n.gz" || true - gzip --best - < "${TDIR}/kyc-spa/$n" > "${TDIR}/kyc-spa/$n.gz" || true - zstd -19 - < "${TDIR}/aml-spa/$n" > "${TDIR}/aml-spa/$n.zstd" || true - zstd -19 - < "${TDIR}/kyc-spa/$n" > "${TDIR}/kyc-spa/$n.zstd" || true + # Check if we have compression commands + zstd --version >/dev/null 2>&1; have_zstd=$(( ! $? )) + gzip --version >/dev/null 2>&1; have_gzip=$(( ! $? )) + + # Generate compressed versions of the SPA files. + # Remove existing files if compression tool is not available, + # as previous package version wrongly generated empty files + # when the tool was missing. + for n in /usr/share/taler-exchange/*-spa/*.{css,js,html,json}; do + if [[ $have_gzip = 1 ]]; then + gzip -f --best "$n" > "$n.gz" + else + rm -f "$n.gz" + fi + if [[ $have_zstd = 1 ]]; then + zstd -f -19 "$n" > "$n.zstd" + else + rm -f "$n.zstd" + fi done ;;