[openwrt/openwrt] prereq: merge common cases in SetupHostCommand
LEDE Commits
lede-commits at lists.infradead.org
Thu Oct 26 16:04:34 PDT 2023
jow pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/c4c9f6133178f7e36ec3193be97326bbd037bd44
commit c4c9f6133178f7e36ec3193be97326bbd037bd44
Author: Jonas Gorski <jonas.gorski at gmail.com>
AuthorDate: Wed Aug 23 09:47:57 2023 +0200
prereq: merge common cases in SetupHostCommand
Now that most cases do the same thing in SetupHostCommand, merge them
together into one. To allow moving the generic symlink check, invert the
check and let it check for relative links by matching on link targets
that do not start with a slash.
This then allows us to also drop the absolute link case, shortening the
case statement further.
This reorders the check to
* if it is not a symlink, do not change it
* if it is a symlink and it points to the found command, do not change it
* if it is a symlink with a relative path, do not change it
* else, update/replace it
Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
(cherry picked from commit 3210aa8e0a113cc4354628b08b608c5c8f792941)
---
include/prereq.mk | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/include/prereq.mk b/include/prereq.mk
index 5cb1102182..9f1ff70eed 100644
--- a/include/prereq.mk
+++ b/include/prereq.mk
@@ -107,15 +107,9 @@ define SetupHostCommand
bin="$$$$$$$$(command -v "$$$$$$$${cmd%% *}")"; \
if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
case "$$$$$$$$(ls -dl -- $(STAGING_DIR_HOST)/bin/$(strip $(1)))" in \
- *" -> $$$$$$$$bin"*) \
- [ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
- ;; \
- "-"*) \
- [ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
- ;; \
- *" -> /"*) \
- ;; \
- *" -> "*) \
+ "-"* | \
+ *" -> $$$$$$$$bin"* | \
+ *" -> "[!/]*) \
[ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
;; \
esac; \
More information about the lede-commits
mailing list