[openwrt/openwrt] include/package-pack: remove leading whitespace from install scripts

LEDE Commits lede-commits at lists.infradead.org
Fri Jan 10 01:50:39 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b52e8972968ce25026447fea3de320fb395a2f3a

commit b52e8972968ce25026447fea3de320fb395a2f3a
Author: Eric Fahlgren <ericfahlgren at gmail.com>
AuthorDate: Mon Dec 30 15:54:55 2024 -0800

    include/package-pack: remove leading whitespace from install scripts
    
    Strip off initial leading blanks and tabs from scripts and script
    fragments that are supplied by the package's Makefile.  Specifically,
    the script included in the postrm must be left justified so that
    the shebang is in the first column.
    
    Fixes: https://github.com/openwrt/openwrt/issues/17439
    Signed-off-by: Eric Fahlgren <ericfahlgren at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/17440
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 include/package-pack.mk | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/package-pack.mk b/include/package-pack.mk
index a36d690901..411bae825a 100644
--- a/include/package-pack.mk
+++ b/include/package-pack.mk
@@ -302,7 +302,7 @@ else
 		echo 'export pkgname="$(1)"'; \
 		echo "add_group_and_user"; \
 		echo "default_postinst"; \
-		[ ! -f $$(ADIR_$(1))/postinst-pkg ] || cat "$$(ADIR_$(1))/postinst-pkg"; \
+		[ ! -f $$(ADIR_$(1))/postinst-pkg ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/postinst-pkg"; \
 	) > $$(ADIR_$(1))/post-install;
 
 	( \
@@ -312,9 +312,11 @@ else
 		echo 'export root="$$$${IPKG_INSTROOT}"'; \
 		echo 'export pkgname="$(1)"'; \
 		echo "default_prerm"; \
-		[ ! -f $$(ADIR_$(1))/prerm-pkg ] || cat "$$(ADIR_$(1))/prerm-pkg"; \
+		[ ! -f $$(ADIR_$(1))/prerm-pkg ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/prerm-pkg"; \
 	) > $$(ADIR_$(1))/pre-deinstall;
 
+	[ ! -f $$(ADIR_$(1))/postrm ] || sed -zi 's/^\s*#!/#!/' "$$(ADIR_$(1))/postrm";
+
 	if [ -n "$(USERID)" ]; then echo $(USERID) > $$(IDIR_$(1))/lib/apk/packages/$(1).rusers; fi;
 	if [ -n "$(ALTERNATIVES)" ]; then echo $(ALTERNATIVES) > $$(IDIR_$(1))/lib/apk/packages/$(1).alternatives; fi;
 	(cd $$(IDIR_$(1)) && find . -type f,l -printf "/%P\n" > $$(IDIR_$(1))/lib/apk/packages/$(1).list)




More information about the lede-commits mailing list