From 50adb097fad7c5862914f09563042863053bc461 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 4 Jun 2020 22:53:14 +0200 Subject: [PATCH] build: make GluonSrcDiet simpler and more robust (#2033) - If luasrcdiet fails for a Lua script, this is a bug that should be noticed rather than including the unminified script - Use .tmp suffix for temporary file rather than .o - Replace chmod + stat + mv with simpler cp + rm to overwrite file while preserving file mode --- package/gluon.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package/gluon.mk b/package/gluon.mk index b69caa81..0139544e 100644 --- a/package/gluon.mk +++ b/package/gluon.mk @@ -61,14 +61,14 @@ endef define GluonSrcDiet rm -rf $(2) $(CP) $(1) $(2) -ifdef CONFIG_GLUON_MINIFY - $(FIND) $(2) -type f | while read src; do \ - if luasrcdiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \ - chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \ - mv "$$$$src.o" "$$$$src"; \ - fi; \ + ifdef CONFIG_GLUON_MINIFY + # Use cp + rm instead of mv to preserve destination permissions + set -e; $(FIND) $(2) -type f | while read src; do \ + luasrcdiet --noopt-binequiv -o "$$$$src.tmp" "$$$$src"; \ + cp "$$$$src.tmp" "$$$$src"; \ + rm "$$$$src.tmp"; \ done -endif + endif endef