Merge pull request #772 from chris5560/master

luci-app-privoxy: modified to support new LuCI structure
This commit is contained in:
Steven Barth 2015-01-11 22:12:11 +01:00
commit b206a14bd8
5 changed files with 50 additions and 61 deletions

View File

@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-privoxy
PKG_VERSION:=1.0.0
PKG_VERSION:=1.0.1
#PKG_RELEASE:=0
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
@ -22,7 +22,7 @@ define Package/luci-app-privoxy
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI support for Privoxy WEB Proxy
DEPENDS:=+luci-lib-nixio +luci-mod-admin-full +privoxy
DEPENDS:=+luci-mod-admin-full +privoxy
PKGARCH:=all
endef
@ -44,8 +44,7 @@ define Build/Compile
# copy everthing we need ot PKG_INSTALL_DIR
$(CP) ./* $(PKG_INSTALL_DIR)/
# due to package dependencies LuCI is compiled first so the needed binary exists
$(LN) $(BUILD_DIR)/luci/build/po2lmo $(PKG_INSTALL_DIR)/build/po2lmo
$(LN) $(BUILD_DIR)/luci/build/i18n-po2lua.pl $(PKG_INSTALL_DIR)/build/i18n-po2lua.pl
$(LN) $(STAGING_DIR_HOST)/bin/po2lmo $(PKG_INSTALL_DIR)/build/po2lmo
# generate needed .lmo files out of given .po files
cd $(PKG_INSTALL_DIR); build/i18n-po2lua.pl po files/luasrc/i18n
endef

View File

@ -0,0 +1,27 @@
#!/usr/bin/perl
@ARGV == 2 || die "Usage: $0 <source-dir> <dest-dir>\n";
my $source_dir = shift @ARGV;
my $target_dir = shift @ARGV;
if( ! -d $target_dir )
{
system('mkdir', '-p', $target_dir);
}
if( open F, "find $source_dir -type f -name '*.po' |" )
{
while( chomp( my $file = readline F ) )
{
my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
$lang = lc $lang;
$lang =~ s/_/-/g;
printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
}
close F;
}

View File

@ -22,32 +22,19 @@ local UCI = require "luci.model.uci"
local SYS = require "luci.sys"
local UTIL = require "luci.util"
version_luci_app = "1.0.0" -- luci-application / openwrt Makefile compatible version
version_required = "3.0.22" -- minimum required service version
version_luci_app = "1.0.1" -- luci-application / openwrt Makefile compatible version
version_required = "3.0.22-1" -- minimum required service version
function index()
local _service = "privoxy"
local _vermin = "3.0.22"
local _verinst
local _util = require "luci.util"
local _ipkg = require "luci.model.ipkg"
local _info = _ipkg.info(_service)
for _, v in pairs(_info) do
if v.Package == _service and v.Status.installed then
_verinst = v.Version
break
end
end
local _sver = _util.split(_verinst, "[%.%-]", nil, true)
local _rver = _util.split(_vermin , "[%.%-]", nil, true)
local _sys = require "luci.sys"
local _vermin = "3.0.22-1"
local _verinst = _sys.exec([[opkg list-installed ]] .. "privoxy" .. [[ | awk '{print $3}']])
local _cmd = [[opkg compare-versions "]] .. _verinst .. [[" ">=" "]] .. _vermin .. [["]]
local _verok = tonumber(_sys.call(_cmd))
-- check config file and version
if not nixio.fs.access("/etc/config/" .. _service )
or (tonumber(_sver[1]) or 0) < (tonumber(_rver[1]) or 0)
or (tonumber(_sver[2]) or 0) < (tonumber(_rver[2]) or 0)
or (tonumber(_sver[3]) or 0) < (tonumber(_rver[3]) or 0)
or (tonumber(_sver[4]) or 0) < (tonumber(_rver[4]) or 0) then
entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror",
-- check config file and version
if not nixio.fs.access("/etc/config/privoxy") or (_verok == 0) then
entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror",
{hideapplybtn=true, hidesavebtn=true, hideresetbtn=true }), _("Privoxy WEB proxy"), 59)
else
entry( {"admin", "services", "privoxy"}, cbi("privoxy/detail"), _("Privoxy WEB proxy"), 59)
@ -122,35 +109,6 @@ function get_theme()
return nil
end
-- read version information for given package if installed
function ipkg_version(package)
if not package then
return nil
end
local _info = IPKG.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
end
if i > 1 then -- more then one valid record
return _data
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
end
-- replacement of build-in Flag.parse of cbi.lua
-- modified to mark section as changed if value changes
-- current parse did not do this, but it is done AbstaractValue.parse()

View File

@ -14,16 +14,19 @@ $Id$
local CTRL = require "luci.controller.privoxy" -- privoxy multiused functions
local DISP = require "luci.dispatcher"
local SYS = require "luci.sys"
-- Build javascript string to be displayed as version information
local VERSION = translate("Version Information")
.. [[\n\nluci-app-privoxy]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.version_luci_app
.. [[\n\t]] .. translate("Build") .. [[:\t]] .. CTRL.ipkg_version("luci-app-privoxy").version
.. [[\n\t]] .. translate("Build") .. [[:\t]]
.. SYS.exec([[opkg list-installed ]] .. [[luci_app_privoxy]] .. [[ | awk '{print $3}']])
.. [[\n\nprivoxy ]] .. translate("required") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.version_required .. [[ ]] .. translate("or higher")
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.version_required .. [[ ]] .. translate("or greater")
.. [[\n\nprivoxy ]] .. translate("installed") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.ipkg_version("privoxy").version
.. [[\n\t]] .. translate("Version") .. [[:\t]]
.. SYS.exec([[opkg list-installed ]] .. [[privoxy]] .. [[ | awk '{print $3}']])
.. [[\n\n]]
local HELP = [[<a href="http://www.privoxy.org/user-manual/config.html#%s" target="_blank">%s</a>]]

View File

@ -25,11 +25,13 @@ local LFLF = (CTRL.get_theme() == "Bootstrap") and [[<br /><br /><br />]] or [[]
local VERSION = translate("Version Information")
.. [[\n\nluci-app-privoxy]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.version_luci_app
.. [[\n\t]] .. translate("Build") .. [[:\t]] .. CTRL.ipkg_version("luci-app-privoxy").version
.. [[\n\t]] .. translate("Build") .. [[:\t]]
.. SYS.exec([[opkg list-installed ]] .. [[luci_app_privoxy]] .. [[ | awk '{print $3}']])
.. [[\n\nprivoxy ]] .. translate("required") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.version_required .. [[ ]] .. translate("or greater")
.. [[\n\nprivoxy ]] .. translate("installed") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.ipkg_version("privoxy").version
.. [[\n\t]] .. translate("Version") .. [[:\t]]
.. SYS.exec([[opkg list-installed ]] .. [[privoxy]] .. [[ | awk '{print $3}']])
.. [[\n\n]]
local HELP = [[<a href="http://www.privoxy.org/user-manual/config.html#%s" target="_blank">%s</a>]]