procd: update to latest git head

this includes the first wip version of the uci validation backend

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38786
This commit is contained in:
John Crispin 2013-11-13 10:49:25 +00:00
parent 5fa0e4fac0
commit 130d7de07f
2 changed files with 81 additions and 14 deletions

View file

@ -1,14 +1,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=procd PKG_NAME:=procd
PKG_VERSION:=2013-11-08 PKG_VERSION:=2013-11-13
PKG_RELEASE=$(PKG_SOURCE_VERSION)-1 PKG_RELEASE=$(PKG_SOURCE_VERSION)-1
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=315f04d8b823adda96041c17f6672b7790376ccb PKG_SOURCE_VERSION:=f9d31edb8938341b9217ee4c14eb58111414eb97
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
CMAKE_INSTALL:=1 CMAKE_INSTALL:=1
@ -30,13 +30,14 @@ define Package/procd
endef endef
define Package/procd/install define Package/procd/install
$(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc/init.d $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc/init.d $(1)/lib
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/{procd,askfirst,udevtrigger,logread} $(1)/sbin/ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/{procd,askfirst,udevtrigger,logread,validate_data} $(1)/sbin/
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib/
$(INSTALL_BIN) ./files/reload_config $(1)/sbin/ $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
$(INSTALL_BIN) ./files/log.init $(1)/etc/init.d/log $(INSTALL_BIN) ./files/log.init $(1)/etc/init.d/log
$(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/ $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
$(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/ $(INSTALL_DATA) ./files/procd.sh ./files/procd-validate.sh $(1)/lib/functions/
ln -s /sbin/procd $(1)/sbin/init ln -s /sbin/procd $(1)/sbin/init
endef endef

View file

@ -68,9 +68,7 @@ _procd_open_service() {
_procd_close_service() { _procd_close_service() {
json_close_object json_close_object
_procd_open_trigger
service_triggers service_triggers
_procd_close_trigger
_procd_ubus_call set _procd_ubus_call set
} }
@ -117,6 +115,10 @@ _procd_open_trigger() {
json_add_array "triggers" json_add_array "triggers"
} }
_procd_open_validate() {
json_add_array "validate"
}
_procd_set_param() { _procd_set_param() {
local type="$1"; shift local type="$1"; shift
@ -135,7 +137,8 @@ _procd_set_param() {
_procd_add_config_trigger() { _procd_add_config_trigger() {
json_add_array json_add_array
_procd_add_array_data "config.change" _procd_add_array_data "$1"
shift
json_add_array json_add_array
_procd_add_array_data "if" _procd_add_array_data "if"
@ -158,14 +161,15 @@ _procd_add_reload_trigger() {
local script=$(readlink "$initscript") local script=$(readlink "$initscript")
local name=$(basename ${script:-$initscript}) local name=$(basename ${script:-$initscript})
_procd_add_config_trigger $1 /etc/init.d/$name reload _procd_open_trigger
_procd_add_config_trigger "config.change" $1 /etc/init.d/$name reload
_procd_close_trigger
} }
_procd_add_reload_trigger() { _procd_add_validation() {
local script=$(readlink "$initscript") _procd_open_validate
local name=$(basename ${script:-$initscript}) $@
_procd_close_validate
_procd_add_config_trigger $1 /etc/init.d/$name reload
} }
_procd_append_param() { _procd_append_param() {
@ -191,6 +195,10 @@ _procd_close_trigger() {
json_close_array json_close_array
} }
_procd_close_validate() {
json_close_array
}
_procd_add_instance() { _procd_add_instance() {
_procd_open_instance _procd_open_instance
_procd_set_param command "$@" _procd_set_param command "$@"
@ -207,6 +215,63 @@ _procd_kill() {
_procd_ubus_call delete _procd_ubus_call delete
} }
uci_validate_section()
{
local error=0
[ "$4" = "" ] && return 1
[ "$3" = "" ] && {
json_add_object
json_add_string "package" "$1"
json_add_string "type" "$2"
json_add_object "data"
shift; shift; shift
while [ -n "$1" ]; do
json_add_string "${1%:*}" "${1#*:}"
shift
done
json_close_object
json_close_object
return 0
}
local section="${3}"
config_load "${1}"
shift; shift; shift
while [ -n "$1" ]; do
local name=${1%%:*}
local tmp=${1#*:}
local type=${tmp%%:*}
local default=""
[ "$tmp" = "$type" ] || default=${tmp#*:}
shift
config_get "${name}" "${section}" "${name}"
eval val=\$$name
[ "$type" = "bool" ] && {
case "$val" in
1|on|true|enabled) val=1;;
0|off|false|disabled) val=0;;
*) val="";;
esac
}
[ -z "$val" ] && val=${default}
eval $name=\"$val\"
[ -z "$val" ] || {
/sbin/validate_data "${type}" "${val}"
[ $? -eq 0 ] || error="$((error + 1))"
}
done
return $error
}
_procd_wrapper \ _procd_wrapper \
procd_open_service \ procd_open_service \
procd_close_service \ procd_close_service \
@ -219,4 +284,5 @@ _procd_wrapper \
procd_close_instance \ procd_close_instance \
procd_set_param \ procd_set_param \
procd_append_param \ procd_append_param \
procd_add_validation \
procd_kill procd_kill