From 819a733df3c9e93619dbad1159f67de70d406da7 Mon Sep 17 00:00:00 2001 From: Christian Schoenebeck Date: Sun, 18 Jan 2015 19:22:54 +0100 Subject: [PATCH] luci-app-ddns: Update to version 2.1.1-0 - adaption Makefile to changed luci.mk - description in Makefile for correct version handling - modified handling to detect and display installed version - new functions ipkg_ver_installed() and ipkg_ver_compare - correct wrong spellings - modified language template and German translation Signed-off-by: Christian Schoenebeck --- applications/luci-app-ddns/Makefile | 27 +++- .../luci-app-ddns/luasrc/controller/ddns.lua | 45 +++---- .../luasrc/model/cbi/ddns/detail.lua | 2 +- .../luasrc/model/cbi/ddns/hints.lua | 3 +- .../luasrc/model/cbi/ddns/overview.lua | 16 ++- .../luci-app-ddns/luasrc/tools/ddns.lua | 42 +++---- .../luasrc/view/ddns/detail_lvalue.htm | 2 +- .../luasrc/view/ddns/detail_value.htm | 2 +- .../luasrc/view/ddns/overview_startstop.htm | 2 +- .../luasrc/view/ddns/overview_status.htm | 36 +----- .../luasrc/view/ddns/system_status.htm | 7 +- applications/luci-app-ddns/po/de/ddns.po | 118 ++++++++++++------ .../luci-app-ddns/po/templates/ddns.pot | 102 ++++++++++----- 13 files changed, 229 insertions(+), 175 deletions(-) diff --git a/applications/luci-app-ddns/Makefile b/applications/luci-app-ddns/Makefile index d116f06a46..18906cd1c2 100644 --- a/applications/luci-app-ddns/Makefile +++ b/applications/luci-app-ddns/Makefile @@ -6,17 +6,32 @@ include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI Support for Dynamic DNS (ddns-scripts) -LUCI_DEPENDS:=+ddns-scripts +luci-mod-admin-full +# LuCI specific settings +LUCI_TITLE:=LuCI Support for Dynamic DNS Client (ddns-scripts) +LUCI_DEPENDS:=+luci-mod-admin-full +ddns-scripts PKG_NAME:=luci-app-ddns -PKG_VERSION:=2.1.0 -PKG_RELEASE:=4 -PKG_LICENSE:=Apache-2.0 -PKGARCH:=all +# Version == major.minor.patch +# increase on new functionality (minor) or patches (patch) +PKG_VERSION:=2.1.1 + +# Release == build +# increase on changes of translation files +PKG_RELEASE:=0 + +PKG_LICENSE:=Apache-2.0 PKG_MAINTAINER:=Christian Schoenebeck +define Package/$(PKG_NAME)/config +# shown in make menuconfig +help + $(LUCI_TITLE) + + Version : $(PKG_VERSION)-$(PKG_RELEASE) + Maintainer: $(PKG_MAINTAINER) +endef + include ../../luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-ddns/luasrc/controller/ddns.lua b/applications/luci-app-ddns/luasrc/controller/ddns.lua index 3cd52e5e3c..56d2b66e21 100644 --- a/applications/luci-app-ddns/luasrc/controller/ddns.lua +++ b/applications/luci-app-ddns/luasrc/controller/ddns.lua @@ -15,19 +15,21 @@ local SYS = require "luci.sys" local DDNS = require "luci.tools.ddns" -- ddns multiused functions local UTIL = require "luci.util" -local luci_ddns_version = "2.1.0-4" -- luci-app-ddns / openwrt Makefile compatible version -local ddns_scripts_min = "2.1.0-3" -- minimum version of ddns-scripts required +DDNS_MIN = "2.1.0-2" -- minimum version of service required function index() - -- no services_ipv6 file or no dynamic_dns_lucihelper.sh - -- do NOT start - if not nixio.fs.access("/usr/lib/ddns/services_ipv6") - or not nixio.fs.access("/usr/lib/ddns/dynamic_dns_lucihelper.sh") then + local nxfs = require "nixio.fs" -- global definitions not available + local sys = require "luci.sys" -- in function index() + local ddns = require "luci.tools.ddns" -- ddns multiused functions + local verinst = ddns.ipkg_ver_installed("ddns-scripts") + local verok = ddns.ipkg_ver_compare(verinst, ">=", "2.0.0-0") + -- do NOT start it not ddns-scripts version 2.x + if not verok then return end -- no config create an empty one - if not nixio.fs.access("/etc/config/ddns") then - nixio.fs.writefile("/etc/config/ddns", "") + if not nxfs.access("/etc/config/ddns") then + nxfs.writefile("/etc/config/ddns", "") end entry( {"admin", "services", "ddns"}, cbi("ddns/overview"), _("Dynamic DNS"), 59) @@ -44,17 +46,11 @@ local function _get_status() local uci = UCI.cursor() local service = SYS.init.enabled("ddns") and 1 or 0 local url_start = DISP.build_url("admin", "system", "startup") - local luci_build = DDNS.ipkg_version("luci-app-ddns").version - local ddns_act = DDNS.ipkg_version("ddns-scripts").version local data = {} -- Array to transfer data to javascript data[#data+1] = { enabled = service, -- service enabled url_up = url_start, -- link to enable DDS (System-Startup) - luci_ver = luci_ddns_version, -- luci-app-ddns / openwrt Makefile compatible version - luci_build = luci_build, -- installed luci build - script_min = ddns_scripts_min, -- minimum version of ddns-scripts needed - script_ver = ddns_act -- installed ddns-scripts } uci:foreach("ddns", "service", function (s) @@ -63,8 +59,8 @@ local function _get_status() -- and enabled state local section = s[".name"] local enabled = tonumber(s["enabled"]) or 0 - local datelast = "_empty_" -- formated date of last update - local datenext = "_empty_" -- formated date of next update + local datelast = "_empty_" -- formatted date of last update + local datenext = "_empty_" -- formatted date of next update -- get force seconds local force_seconds = DDNS.calc_seconds( @@ -182,7 +178,7 @@ function startstop(section, enabled) return end - -- read uncommited changes + -- read uncommitted changes -- we don't save and commit data from other section or other options -- only enabled will be done local exec = true @@ -210,9 +206,9 @@ function startstop(section, enabled) end -- we can not execute because other - -- uncommited changes pending, so exit here + -- uncommitted changes pending, so exit here if not exec then - HTTP.write("_uncommited_") + HTTP.write("_uncommitted_") return end @@ -238,14 +234,3 @@ function status() HTTP.prepare_content("application/json") HTTP.write_json(data) end - --- check if installed ddns-scripts version < required version -function update_needed() - local sver = DDNS.ipkg_version("ddns-scripts") - local rver = UTIL.split(ddns_scripts_min, "[%.%-]", nil, true) - return (sver.major < (tonumber(rver[1]) or 0)) - or (sver.minor < (tonumber(rver[2]) or 0)) - or (sver.patch < (tonumber(rver[3]) or 0)) - or (sver.build < (tonumber(rver[4]) or 0)) -end - 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 057b8c8aa2..77753c03a7 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/detail.lua @@ -22,7 +22,7 @@ has_ipv6 = DDNS.check_ipv6() -- IPv6 support has_ssl = DDNS.check_ssl() -- HTTPS support has_proxy = DDNS.check_proxy() -- Proxy support has_dnstcp = DDNS.check_bind_host() -- DNS TCP support -has_force = has_ssl and has_dnstcp -- Force IP Protocoll +has_force = has_ssl and has_dnstcp -- Force IP Protocoll -- html constants -- ########################################################### font_red = "" diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua index 15da0289f1..009ba99eb8 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/hints.lua @@ -11,7 +11,8 @@ local DDNS = require "luci.tools.ddns" -- ddns multiused functions has_ssl = DDNS.check_ssl() -- HTTPS support has_proxy = DDNS.check_proxy() -- Proxy support has_dnstcp = DDNS.check_bind_host() -- DNS TCP support -need_update = CTRL.update_needed() -- correct ddns-scripts version +-- correct ddns-scripts version +need_update = DDNS.ipkg_ver_compare(DDNS.ipkg_ver_installed("ddns-scripts"), "<<", CTRL.DDNS_MIN) -- html constants font_red = [[]] diff --git a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua index 2944ec52f9..83b10e9366 100644 --- a/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua +++ b/applications/luci-app-ddns/luasrc/model/cbi/ddns/overview.lua @@ -14,7 +14,8 @@ show_hints = not (DDNS.check_ipv6() -- IPv6 support and DDNS.check_proxy() -- Proxy support and DDNS.check_bind_host() -- DNS TCP support ) -need_update = CTRL.update_needed() -- correct ddns-scripts version +-- correct ddns-scripts version +need_update = DDNS.ipkg_ver_compare(DDNS.ipkg_ver_installed("ddns-scripts"), "<<", CTRL.DDNS_MIN) -- html constants font_red = [[]] @@ -28,8 +29,17 @@ m = Map("ddns") -- first need to close from cbi map template our closed by template --m.title = [[]] .. -- translate("Dynamic DNS") -m.title = [[]] .. - translate("Dynamic DNS") +m.title = [[]] + .. translate("Dynamic DNS") m.description = translate("Dynamic DNS allows that your router can be reached with " .. "a fixed hostname while having a dynamically changing " .. diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua index 5c8ced50b3..2fbcff8bad 100644 --- a/applications/luci-app-ddns/luasrc/tools/ddns.lua +++ b/applications/luci-app-ddns/luasrc/tools/ddns.lua @@ -96,33 +96,29 @@ function get_pid(section) return pid end --- read version information for given package if installed -function ipkg_version(package) - if not package then +-- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>" +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 end - local info = OPKG.info(package) - local data = {} - local version = "" - local i = 0 - for k, v in pairs(info) do - if v.Package == package and v.Status.installed then - version = v.Version - i = i + 1 - end + return (tonumber(SYS.call( + [[opkg compare-versions "]] .. ver1 .. [[" "]] .. comp .. [[" "]] .. ver2 .. [["]] + )) == 1) +end + +-- read version information for given package if installed +function ipkg_ver_installed(pkg) + if not pkg then + return nil end - if i > 1 then -- more then one valid record - return data + -- 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 - local sver = UTIL.split(version, "[%.%-]", nil, true) - data = { - version = version, - major = tonumber(sver[1]) or 0, - minor = tonumber(sver[2]) or 0, - patch = tonumber(sver[3]) or 0, - build = tonumber(sver[4]) or 0 - } - return data + return nil end -- replacement of build-in read of UCI option diff --git a/applications/luci-app-ddns/luasrc/view/ddns/detail_lvalue.htm b/applications/luci-app-ddns/luasrc/view/ddns/detail_lvalue.htm index d516837b2b..0bcfd44283 100644 --- a/applications/luci-app-ddns/luasrc/view/ddns/detail_lvalue.htm +++ b/applications/luci-app-ddns/luasrc/view/ddns/detail_lvalue.htm @@ -1,6 +1,6 @@ - +   <% if self.widget == "select" then %> " style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)" <%= attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled") diff --git a/applications/luci-app-ddns/luasrc/view/ddns/overview_status.htm b/applications/luci-app-ddns/luasrc/view/ddns/overview_status.htm index 37c54be25f..6cca0e75d9 100644 --- a/applications/luci-app-ddns/luasrc/view/ddns/overview_status.htm +++ b/applications/luci-app-ddns/luasrc/view/ddns/overview_status.htm @@ -2,12 +2,6 @@