Repaired ifphylist, added skeleton for new syntax of plugin

master
Lukas Macura 2016-12-08 16:08:08 +01:00
parent 45ae337483
commit 6db99e2d13
4 changed files with 92 additions and 3 deletions

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
include lib.mk
ifeq ($(PLUGINS),)
PLUGINS=$(shell ls -I '*mk' -I Makefile -I README.md)
endif
all: $(PLUGINS)
$(eval $(call Plugins/Rules))

View File

@ -2,9 +2,9 @@
wifi_ifphylist() {
if [ "$1" = "phy" ]; then
iw dev | grep Interface | cut -d ' ' -f 2
else
iw phy | grep Wiphy | cut -d ' ' -f 2
else
iw dev | grep Interface | cut -d ' ' -f 2
fi
}
@ -43,7 +43,7 @@ wifi_if_discovery(){
}
wifi_phy_discovery(){
wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}"
wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}"
}
wifi_channels_discovery(){

34
iwx/plugin.mk Normal file
View File

@ -0,0 +1,34 @@
NAME=iwx
VERSION=0.5
URL=https://raw.githubusercontent.com/limosek/zaf-plugins/master/iwx
WEB=https://github.com/limosek/zaf-plugins
DEPENDS_OPKG=busybox jshn
DEPENDS_DPKG=dash
DEPENDS_RPM=dash
SUDO=iw
INSTALL_BIN=functions.sh
ITEMS=if_discovery phy_discovery
define iwx/Description
Plugin for wifi mac80211 informations and discovery
endef
define iwx/Item/if_discovery/Description
Discovery of wireless interfaces
endef
define iwx/Item/if_discovery/Cmd
wifi_if_discovery
endef
define iwx/Item/phy_discovery/Description
Discovery of wireless physical interfaces
endef
define iwx/Item/phy_discovery/Cmd
wifi_phy_discovery
endef

43
lib.mk Normal file
View File

@ -0,0 +1,43 @@
define shvar
V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
endef
define shexport
export $(call shvar,$(1))="$$(call $(1))"
endef
define newline
endef
define Plugin/Rule
ifeq ($(wildcard $(1)/plugin.mk),)
$(1):
$(MAKE) PLUGINS=$(1) $(1)/control.zaf
$(1)/control.zaf:
@echo -n
else
include $(1)/plugin.mk
$(1): $(1)/control.zaf
$(MAKE) PLUGINS=$(1) $(1)/control.zaf
$(1)/plugin.mk:
$(1)/control.zaf: $(1)/plugin.mk
printf %b '$(subst $(call newline),\n,$(call Plugin/Control,$(1)))'
endif
endef
define Plugins/Rules
$(foreach p,$(PLUGINS),$(eval $(call Plugin/Rule,$(p))))
endef
define Plugin/Control
Plugin: $(1)
Version: $$(VERSION)
Description::
$$(call $(1)/Description)
::
endef