diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-03-10 18:49:10 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-03-10 18:49:10 +0100 |
commit | d539eb4d13cd6a65dc90a0e2e65cc11352a51248 (patch) | |
tree | 54c9b1d2ac204c4162c23ef6404bcd6c033fdbba | |
parent | 965c6315bfd87ebcf5888b5329f116952feefdd7 (diff) | |
parent | df0590972345e6862817e53a38c73925596aaf63 (diff) |
Merge pull request #337 from chris5560/master-app-ddns
luci-app-ddns: patches for #298 #334 #335
4 files changed, 67 insertions, 43 deletions
diff --git a/applications/luci-app-ddns/Makefile b/applications/luci-app-ddns/Makefile index db1da2c7c..f20b49e90 100644 --- a/applications/luci-app-ddns/Makefile +++ b/applications/luci-app-ddns/Makefile @@ -6,16 +6,11 @@ include $(TOPDIR)/rules.mk -# LuCI specific settings -LUCI_TITLE:=LuCI Support for Dynamic DNS Client (ddns-scripts) -LUCI_DEPENDS:=+luci-mod-admin-full +ddns-scripts -LUCI_PKGARCH:=all - PKG_NAME:=luci-app-ddns # Version == major.minor.patch # increase on new functionality (minor) or patches (patch) -PKG_VERSION:=2.2.0 +PKG_VERSION:=2.2.1 # Release == build # increase on changes of translation files @@ -24,15 +19,20 @@ PKG_RELEASE:=1 PKG_LICENSE:=Apache-2.0 PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com> +# LuCI specific settings +LUCI_TITLE:=LuCI Support for Dynamic DNS Client (ddns-scripts) +LUCI_DEPENDS:=+luci-mod-admin-full +ddns-scripts +LUCI_PKGARCH:=all + define Package/$(PKG_NAME)/config # shown in make menuconfig <Help> help $(LUCI_TITLE) - - Version : $(PKG_VERSION)-$(PKG_RELEASE) - Maintainer: $(PKG_MAINTAINER) + . + Version: $(PKG_VERSION)-$(PKG_RELEASE) + $(PKG_MAINTAINER) endef -include ../../luci.mk +include $(TOPDIR)/feeds/luci/luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua index 602bc159a..40a66ef15 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua @@ -1,7 +1,7 @@ -- Copyright 2008 Steven Barth <steven@midlink.org> -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> -- Copyright 2013 Manuel Munz <freifunk at somakoma dot de> --- Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> +-- Copyright 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> -- Licensed to the public under the Apache License 2.0. local NX = require "nixio" @@ -25,7 +25,6 @@ local has_dnstcp = DDNS.check_bind_host() -- DNS TCP support local has_force = has_ssl and has_dnstcp -- Force IP Protocoll -- html constants -- ########################################################### -local LFLF = (DDNS.get_theme() == "Bootstrap") and [[<br /><br />]] or [[]] local font_red = "<font color='red'>" local font_off = "</font>" local bold_on = "<strong>" diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua index 32ca5418e..e1718739f 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/global.lua @@ -7,9 +7,6 @@ local DISP = require "luci.dispatcher" local SYS = require "luci.sys" local DDNS = require "luci.tools.ddns" -- ddns multiused functions --- Bootstrap theme needs 2 or 3 additional linefeeds for tab description for better optic -local LFLF = (DDNS.get_theme() == "Bootstrap") and [[<br /><br />]] or [[]] - -- cbi-map definition -- ####################################################### local m = Map("ddns") @@ -38,7 +35,7 @@ local ns = m:section( NamedSection, "global", "ddns", .. [[<a href="http://wiki.openwrt.org/doc/uci/ddns#version_2x1" target="_blank">]] .. translate("For detailed information about parameter settings look here.") .. [[</a>]] - .. LFLF ) + -- section might not exist function ns.cfgvalue(self, section) if not self.map:get(section) then diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua index e9c3fa936..6d5393146 100644 --- a/applications/luci-app-ddns/luasrc/tools/ddns.lua +++ b/applications/luci-app-ddns/luasrc/tools/ddns.lua @@ -100,39 +100,67 @@ end function ipkg_ver_compare(ver1, comp, ver2) if not ver1 or not (#ver1 > 0) or not ver2 or not (#ver2 > 0) - or not comp or not (#comp > 0) then - return nil + or not comp or not (#comp > 0) then return nil end + -- correct compare string + if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~=" + elseif comp == "<=" or comp == "<" or comp == "=<" then comp = "<=" + elseif comp == ">=" or comp == ">" or comp == "=>" then comp = ">=" + elseif comp == "=" or comp == "==" then comp = "==" + elseif comp == "<<" then comp = "<" + elseif comp == ">>" then comp = ">" + else return nil end + + local av1 = UTIL.split(ver1, "[%.%-]", nil, true) + local av2 = UTIL.split(ver2, "[%.%-]", nil, true) + + for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do + local s1 = av1[i] or "" + local s2 = av2[i] or "" + local n1 = tonumber(s1) + local n2 = tonumber(s2) + + -- one numeric and other empty string then set other to 0 + if n1 and not n2 and (not s2 or #s2 == 0) then n2 = 0 end + if n2 and not n1 and (not s1 or #s1 == 0) then n1 = 0 end + + local nc = (n1 and n2) -- numeric compare + + if nc then + -- first "not equal" found return true + if comp == "~=" and (n1 ~= n2) then return true end + -- first "lower" found return true + if (comp == "<" or comp == "<=") and (n1 < n2) then return true end + -- first "greater" found return true + if (comp == ">" or comp == ">=") and (n1 > n2) then return true end + -- not equal then return false + if (n1 ~= n2) then return false end + else + if comp == "~=" and (s1 ~= s2) then return true end + if (comp == "<" or comp == "<=") and (s1 < s2) then return true end + if (comp == ">" or comp == ">=") and (s1 > s2) then return true end + if (s1 ~= s2) then return false end + end end - return (tonumber(SYS.call( - [[opkg compare-versions "]] .. ver1 .. [[" "]] .. comp .. [[" "]] .. ver2 .. [["]] - )) == 1) + -- all equal then true + return true end -- read version information for given package if installed function ipkg_ver_installed(pkg) - if not pkg then - return nil - end - -- opkg list-installed [pkg] | cut -d " " -f 3 - return version as sting - local ver = SYS.exec([[opkg list-installed ]] .. pkg .. [[ | cut -d " " -f 3 ]]) - if (#ver > 0) then - return ver - end - return nil -end - --- get the "name" of the current active theme -function get_theme() - local _uci = UCI.cursor() - local _base = _uci:get("luci", "main", "mediaurlbase") -- only pathname - _uci:unload("luci") - - for k, v in pairs(luci.config.themes) do - if k:sub(1, 1) ~= "." and v == _base then - return k - end + local version = nil + local control = io.open("/usr/lib/opkg/info/%s.control" % pkg, "r") + if control then + local ln + repeat + ln = control:read("*l") + if ln and ln:match("^Version: ") then + version = ln:gsub("^Version: ", "") + break + end + until not ln + control:close() end - return nil + return version end -- replacement of build-in read of UCI option |