[OpenWrt-Devel] [PATCH 3/3] base-files: move find_mtd_chardev() to /lib/functions.sh

Adrian Schmutzler freifunk at adrianschmutzler.de
Fri Mar 13 12:11:22 EDT 2020


While find_mtd_index() and find_mtd_part() are located in
/lib/functions.sh, find_mtd_chardev() has been located in
/lib/functions/system.sh.

Move the latter to the former file to keep similar functions
together.

While at it, fix some corresponding includes.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 package/base-files/Makefile                               | 2 +-
 package/base-files/files/lib/functions.sh                 | 8 ++++++++
 package/base-files/files/lib/functions/system.sh          | 8 --------
 .../ath79/base-files/lib/functions/mikrotik-caldata.sh    | 2 ++
 .../linux/lantiq/xrx200/base-files/etc/board.d/02_network | 1 +
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 8e252153fe..87c43fdc0c 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=215
+PKG_RELEASE:=216
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index a77b669709..0438e9e25a 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -302,6 +302,14 @@ find_mtd_part() {
 	echo "${INDEX:+$PREFIX$INDEX}"
 }
 
+find_mtd_chardev() {
+	local INDEX=$(find_mtd_index "$1")
+	local PREFIX=/dev/mtd
+
+	[ -d /dev/mtd ] && PREFIX=/dev/mtd/
+	echo "${INDEX:+$PREFIX$INDEX}"
+}
+
 group_add() {
 	local name="$1"
 	local gid="$2"
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index c7aa7bf75c..b5c68acb15 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -53,14 +53,6 @@ get_mac_label() {
 	echo $macaddr
 }
 
-find_mtd_chardev() {
-	local INDEX=$(find_mtd_index "$1")
-	local PREFIX=/dev/mtd
-
-	[ -d /dev/mtd ] && PREFIX=/dev/mtd/
-	echo "${INDEX:+$PREFIX$INDEX}"
-}
-
 mtd_get_mac_ascii() {
 	local mtdname="$1"
 	local key="$2"
diff --git a/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
index 9c4016ee5d..81e262d874 100644
--- a/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
+++ b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
@@ -4,6 +4,8 @@
 # Helper function to extract MAC addresses and calibration data for MikroTik
 #
 
+. /lib/functions/caldata.sh
+
 mikrotik_caldata_extract() {
 	local part=$1
 	local offset=$(($2))
diff --git a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
index f39898263d..6bb52ccf0c 100755
--- a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
+++ b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
@@ -3,6 +3,7 @@
 # Copyright (C) 2011-2015 OpenWrt.org
 #
 
+. /lib/functions.sh
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list