Browse Source

luci-app-privoxy: modified to support new LuCI structure

* Makefile
    - modified to support new LuCI build structure when building i18n support
    - increase "patch" version
* privoxy.lua detail.lua apperror.lua
    - modified version detection
    - removed function ipgk_version()
* new file build/i18n-po2lua.pl
    - copied from luci build system to create lmo language files

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Christian Schoenebeck 10 years ago
parent
commit
83e8a0e36c

+ 3
- 4
net/privoxy-luci/Makefile View File

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

+ 27
- 0
net/privoxy-luci/build/i18n-po2lua.pl View File

@@ -0,0 +1,27 @@
1
+#!/usr/bin/perl
2
+
3
+@ARGV == 2 || die "Usage: $0 <source-dir> <dest-dir>\n";
4
+
5
+my $source_dir  = shift @ARGV;
6
+my $target_dir  = shift @ARGV;
7
+
8
+if( ! -d $target_dir )
9
+{
10
+	system('mkdir', '-p', $target_dir);
11
+}
12
+
13
+if( open F, "find $source_dir -type f -name '*.po' |" )
14
+{
15
+	while( chomp( my $file = readline F ) )
16
+	{
17
+		my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
18
+		$lang = lc $lang;
19
+		$lang =~ s/_/-/g;
20
+
21
+		printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
22
+		system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
23
+		print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
24
+	}
25
+
26
+	close F;
27
+}

+ 11
- 52
net/privoxy-luci/files/luasrc/controller/privoxy.lua View File

@@ -22,32 +22,19 @@ local UCI  = require "luci.model.uci"
22 22
 local SYS  = require "luci.sys"
23 23
 local UTIL = require "luci.util"
24 24
 
25
-version_luci_app = "1.0.0"	-- luci-application / openwrt Makefile compatible version
26
-version_required = "3.0.22"	-- minimum required service version
25
+version_luci_app = "1.0.1"	-- luci-application / openwrt Makefile compatible version
26
+version_required = "3.0.22-1"	-- minimum required service version
27 27
 
28 28
 function index()
29
-	local _service	= "privoxy"
30
-	local _vermin	= "3.0.22"
31
-	local _verinst
32
-	local _util	= require "luci.util"
33
-	local _ipkg	= require "luci.model.ipkg"
34
-	local _info	= _ipkg.info(_service)
35
-	for _, v in pairs(_info) do
36
-		if v.Package == _service and v.Status.installed then
37
-			_verinst = v.Version
38
-			break
39
-		end
40
-	end
41
-	local _sver = _util.split(_verinst, "[%.%-]", nil, true)
42
-	local _rver = _util.split(_vermin , "[%.%-]", nil, true)
43
-
44
-	-- check config file and version 
45
-	if not nixio.fs.access("/etc/config/" .. _service )
46
-	    or (tonumber(_sver[1]) or 0) < (tonumber(_rver[1]) or 0)
47
-	    or (tonumber(_sver[2]) or 0) < (tonumber(_rver[2]) or 0)
48
-	    or (tonumber(_sver[3]) or 0) < (tonumber(_rver[3]) or 0)
49
-	    or (tonumber(_sver[4]) or 0) < (tonumber(_rver[4]) or 0) then
50
-		entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror", 
29
+	local _sys	= require "luci.sys"
30
+	local _vermin	= "3.0.22-1"
31
+	local _verinst	= _sys.exec([[opkg list-installed ]] .. "privoxy" .. [[ | awk '{print $3}']])
32
+	local _cmd 	= [[opkg compare-versions "]] .. _verinst .. [[" ">=" "]] .. _vermin .. [["]]
33
+	local _verok	= tonumber(_sys.call(_cmd))
34
+
35
+	-- check config file and version
36
+	if not nixio.fs.access("/etc/config/privoxy") or (_verok == 0) then
37
+		entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror",
51 38
 			{hideapplybtn=true, hidesavebtn=true, hideresetbtn=true }), _("Privoxy WEB proxy"), 59)
52 39
 	else
53 40
 		entry( {"admin", "services", "privoxy"}, cbi("privoxy/detail"), _("Privoxy WEB proxy"), 59)
@@ -122,35 +109,6 @@ function get_theme()
122 109
 	return nil
123 110
 end
124 111
 
125
-function ipkg_version(package)
126
-	if not package then
127
-		return nil
128
-	end
129
-	local _info = IPKG.info(package)
130
-	local _data = {}
131
-	local _version = ""
132
-	local i = 0
133
-	for k, v in pairs(_info) do
134
-		if v.Package == package and v.Status.installed then
135
-			_version = v.Version
136
-			i = i + 1
137
-		end
138
-	end
139
-	if i > 1 then	-- more then one valid record
140
-		return _data
141
-	end
142
-	local _sver = UTIL.split(_version, "[%.%-]", nil, true)
143
-	_data = {
144
-		version = _version,
145
-		major   = tonumber(_sver[1]) or 0,
146
-		minor   = tonumber(_sver[2]) or 0,
147
-		patch   = tonumber(_sver[3]) or 0,
148
-		build   = tonumber(_sver[4]) or 0
149
-	}
150
-	return _data
151
-end
152
-
153 112
 -- replacement of build-in Flag.parse of cbi.lua
154 113
 -- modified to mark section as changed if value changes
155 114
 -- current parse did not do this, but it is done AbstaractValue.parse()

+ 6
- 3
net/privoxy-luci/files/luasrc/model/cbi/privoxy/apperror.lua View File

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

+ 4
- 2
net/privoxy-luci/files/luasrc/model/cbi/privoxy/detail.lua View File

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