diff options
author | Christian Schoenebeck <christian.schoenebeck@gmail.com> | 2015-01-18 19:22:54 +0100 |
---|---|---|
committer | Christian Schoenebeck <christian.schoenebeck@gmail.com> | 2015-01-18 19:22:54 +0100 |
commit | 819a733df3c9e93619dbad1159f67de70d406da7 (patch) | |
tree | f73dc2f21f5ca0a71c01f68cdbbe192380cac0d3 /applications/luci-app-ddns/luasrc/tools | |
parent | 52ecc90b3129c72a856c3d16534276ab7e192179 (diff) |
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 <christian.schoenebeck@gmail.com>
Diffstat (limited to 'applications/luci-app-ddns/luasrc/tools')
-rw-r--r-- | applications/luci-app-ddns/luasrc/tools/ddns.lua | 42 |
1 files changed, 19 insertions, 23 deletions
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 |