[source] build: fix possible issue with kmod package having multiple AutoLoad's

LEDE Commits lede-commits at lists.infradead.org
Sat May 27 01:55:59 PDT 2017


yousong pushed a commit to source.git, branch lede-17.01:
https://git.lede-project.org/a44d7bfb6352c7521bd8313ef8d2df3a16deabd7

commit a44d7bfb6352c7521bd8313ef8d2df3a16deabd7
Author: Yousong Zhou <yszhou4tech at gmail.com>
AuthorDate: Sat May 27 10:22:02 2017 +0800

    build: fix possible issue with kmod package having multiple AutoLoad's
    
    This commit contains the following changes
    
     - Use local shell var where appliable
     - The $(sort $$$$$$$$mods) call will have no expected effect
     - Avoid EEXIST when creating symlinks in /etc/modules-boot.d/
     - Avoid duplicate arguments for insert_modules() in postinst-pkg
    
    Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 include/kernel.mk | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/kernel.mk b/include/kernel.mk
index 2314ec7..5e2111c 100644
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -95,15 +95,16 @@ define ModuleAutoLoad
 	$(SH_FUNC) \
 	export modules=; \
 	probe_module() { \
-		mods="$$$$$$$$1"; \
-		boot="$$$$$$$$2"; \
+		local mods="$$$$$$$$1"; \
+		local boot="$$$$$$$$2"; \
+		local mod; \
 		shift 2; \
-		for mod in $(sort $$$$$$$$mods); do \
+		for mod in $$$$$$$$mods; do \
 			mkdir -p $(2)/etc/modules.d; \
 			echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \
 		done; \
 		if [ -e $(2)/etc/modules.d/$(1) ]; then \
-			if [ "$$$$$$$$boot" = "1" ]; then \
+			if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$(1) ]; then \
 				mkdir -p $(2)/etc/modules-boot.d; \
 				ln -s ../modules.d/$(1) $(2)/etc/modules-boot.d/; \
 			fi; \
@@ -111,16 +112,17 @@ define ModuleAutoLoad
 		fi; \
 	}; \
 	add_module() { \
-		priority="$$$$$$$$1"; \
-		mods="$$$$$$$$2"; \
-		boot="$$$$$$$$3"; \
+		local priority="$$$$$$$$1"; \
+		local mods="$$$$$$$$2"; \
+		local boot="$$$$$$$$3"; \
+		local mod; \
 		shift 3; \
-		for mod in $(sort $$$$$$$$mods); do \
+		for mod in $$$$$$$$mods; do \
 			mkdir -p $(2)/etc/modules.d; \
 			echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
 		done; \
 		if [ -e $(2)/etc/modules.d/$$$$$$$$priority-$(1) ]; then \
-			if [ "$$$$$$$$boot" = "1" ]; then \
+			if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$$$$$$$$priority-$(1) ]; then \
 				mkdir -p $(2)/etc/modules-boot.d; \
 				ln -s ../modules.d/$$$$$$$$priority-$(1) $(2)/etc/modules-boot.d/; \
 			fi; \
@@ -129,6 +131,7 @@ define ModuleAutoLoad
 	}; \
 	$(3) \
 	if [ -n "$$$$$$$$modules" ]; then \
+		modules="$$$$$$$$(echo "$$$$$$$$modules" | tr ' ' '\n' | sort | uniq | paste -s -d' ')"; \
 		mkdir -p $(2)/etc/modules.d; \
 		mkdir -p $(2)/CONTROL; \
 		echo "#!/bin/sh" > $(2)/CONTROL/postinst-pkg; \



More information about the lede-commits mailing list