Merge pull request #484 from LuttyYang/master
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_system / ipkg.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local ipkgfile = "/etc/opkg.conf"
6 local distfeeds = "/etc/opkg/distfeeds.conf"
7 local customfeeds = "/etc/opkg/customfeeds.conf"
8
9 f = SimpleForm("ipkgconf", translate("OPKG-Configuration"), translate("General options for opkg"))
10
11 f:append(Template("admin_system/ipkg"))
12
13 t = f:field(TextValue, "lines")
14 t.wrap = "off"
15 t.rows = 10
16 function t.cfgvalue()
17         return nixio.fs.readfile(ipkgfile) or ""
18 end
19
20 function t.write(self, section, data)
21         return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n"))
22 end
23
24 function f.handle(self, state, data)
25         return true
26 end
27
28 g = SimpleForm("distfeedconf", translate("Distribution feeds"),
29         translate("Build/distribution specific feed definitions. This file will NOT be preserved in any sysupgrade."))
30
31 d = g:field(TextValue, "lines2")
32 d.wrap = "off"
33 d.rows = 10
34 function d.cfgvalue()
35         return nixio.fs.readfile(distfeeds) or ""
36 end
37
38 function d.write(self, section, data)
39         return nixio.fs.writefile(distfeeds, data:gsub("\r\n", "\n"))
40 end
41
42 function g.handle(self, state, data)
43         return true
44 end
45
46 h = SimpleForm("customfeedconf", translate("Custom feeds"),
47         translate("Custom feed definitions, e.g. private feeds. This file can be preserved in a sysupgrade."))
48
49 c = h:field(TextValue, "lines3")
50 c.wrap = "off"
51 c.rows = 10
52 function c.cfgvalue()
53         return nixio.fs.readfile(customfeeds) or ""
54 end
55
56 function c.write(self, section, data)
57         return nixio.fs.writefile(customfeeds, data:gsub("\r\n", "\n"))
58 end
59
60 function h.handle(self, state, data)
61         return true
62 end
63
64 return f, g, h