luci-app-diskman: bump to v0.2.3

This commit is contained in:
CN_SZTL 2020-02-28 18:36:25 +08:00
parent 9409676ebb
commit cc3ae1ab90
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 64 additions and 38 deletions

View File

@ -1,11 +1,18 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-diskman
PKG_VERSION:=v0.2.2
PKG_VERSION:=v0.2.3
PKG_RELEASE:=beta
PKG_MAINTAINER:=lisaac <https://github.com/lisaac/luci-app-diskman>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_LICENSE:=Apache-2.0
PKG_LICENSE:=AGPL-3.0
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/lisaac/luci-app-diskman.git
PKG_SOURCE_VERSION:=$(PKG_VERSION)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR)-$(PKG_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
include $(INCLUDE_DIR)/package.mk
@ -23,6 +30,7 @@ define Package/$(PKG_NAME)/description
endef
define Build/Prepare
tar -xzvf $(DL_DIR)/$(PKG_SOURCE) -C $(BUILD_DIR)
endef
define Build/Compile
@ -34,13 +42,17 @@ rm -fr /tmp/luci-indexcache /tmp/luci-modulecache
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
# $(INSTALL_DIR) $(1)/
# cp -pR ./root/* $(1)/
# cp -pR $(PKG_BUILD_DIR)/root/* $(1)/
# $(INSTALL_DIR) $(1)/www
# cp -pR $(PKG_BUILD_DIR)/htdoc/* $(1)/www
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)/usr/lib/lua/luci/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
po2lmo ./po/zh_Hans/diskman.po $(1)/usr/lib/lua/luci/i18n/diskman.zh-cn.lmo
po2lmo ./po/pl/diskman.po $(1)/usr/lib/lua/luci/i18n/diskman.pl.lmo
$$(foreach po,$$(shell find $(PKG_BUILD_DIR)/po/*/*.po), \
po2lmo $$(po) \
$(1)/usr/lib/lua/luci/i18n/diskman.$$(shell echo $$(po) | awk -F'/' '{print $$$$(NF-1)}').lmo;)
#po2lmo $(PKG_BUILD_DIR)/po/zh-cn/diskman.po $(1)/usr/lib/lua/luci/i18n/diskman.zh-cn.lmo
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -234,6 +234,17 @@ v_mount_point.render = function(self, section, scope)
Value.render(self, section, scope)
else
self.template = "cbi/dvalue"
local new_mp = ""
local v_mp_d
for v_mp_d in self["section"]["data"][section]["mount_point"]:gmatch('[^/]+') do
if #v_mp_d > 12 then
new_mp = new_mp .. "/" .. v_mp_d:sub(1,7) .. ".." .. v_mp_d:sub(-4)
else
new_mp = new_mp .."/".. v_mp_d
end
end
self["section"]["data"][section]["mount_point"] = '<span title="'..self["section"]["data"][section]["mount_point"] .. '" >'..new_mp..'</span>'
self.rawhtml = true
DummyValue.render(self, section, scope)
end
end

View File

@ -159,7 +159,28 @@ if not disk_info.p_table:match("Raid") then
s_partition_table:option(DummyValue, "used_formated", translate("Used"))
s_partition_table:option(DummyValue, "free_formated", translate("Free Space"))
s_partition_table:option(DummyValue, "usage", translate("Usage"))
s_partition_table:option(DummyValue, "mount_point", translate("Mount Point"))
local dv_mount_point = s_partition_table:option(DummyValue, "mount_point", translate("Mount Point"))
dv_mount_point.rawhtml = true
dv_mount_point.render = function(self, section, scope)
local new_mp = ""
local v_mp_d
for line in self["section"]["data"][section]["mount_point"]:gmatch("[^%s]+") do
if line == '-' then
new_mp = line
break
end
for v_mp_d in line:gmatch('[^/]+') do
if #v_mp_d > 12 then
new_mp = new_mp .. "/" .. v_mp_d:sub(1,7) .. ".." .. v_mp_d:sub(-4)
else
new_mp = new_mp .."/".. v_mp_d
end
end
new_mp = '<span title="'.. line .. '" >' ..new_mp ..'</span>' .. "<br/>"
end
self["section"]["data"][section]["mount_point"] = new_mp
DummyValue.render(self, section, scope)
end
local val_fs = s_partition_table:option(Value, "fs", translate("File System"))
val_fs.forcewrite = true
val_fs.write = function(self, section, value)

View File

@ -18,9 +18,9 @@ d.command.mount = nixio.fs.access("/usr/bin/mount") and "/usr/bin/mount" or "/bi
d.command.umount = nixio.fs.access("/usr/bin/umount") and "/usr/bin/umount" or "/bin/umount"
local proc_mounts = nixio.fs.readfile("/proc/mounts") or ""
local mounts = luci.util.exec(d.command.mount) or ""
local mounts = luci.util.exec(d.command.mount .. " 2>/dev/null") or ""
local swaps = nixio.fs.readfile("/proc/swaps") or ""
local df = luci.sys.exec(d.command.df) or ""
local df = luci.sys.exec(d.command.df .. " 2>/dev/null") or ""
function byte_format(byte)
local suff = {"B", "KB", "MB", "GB", "TB"}
@ -114,19 +114,9 @@ local is_raid_member = function(partition)
end
local get_mount_point = function(partition)
local mount_point, dk_root_dir
-- if use luci-in-dokcer, exclude the docker overlay mounts
-- if ver.distname == "LuCI in Docker" then
local _o, dk = pcall(require,"luci.docker")
if _o and dk then
dk_root_dir = dk.new():info().body.DockerRootDir
end
-- end
local mount_point
for m in mounts:gmatch("/dev/"..partition.." on ([^ ]*)") do
if dk_root_dir and m:match(dk_root_dir) then
else
mount_point = (mount_point and (mount_point .. " ") or "") .. m
end
mount_point = (mount_point and (mount_point .. " ") or "") .. m
end
if mount_point then return mount_point end
-- result = luci.sys.exec('cat /proc/mounts | awk \'{if($1=="/dev/'.. partition ..'") print $2}\'')
@ -278,26 +268,18 @@ end
-- return {{device="", mount_points="", fs="", mount_options="", dump="", pass=""}..}
d.get_mount_points = function()
local mount, dk_root_dir
local mount
local res = {}
local h ={"device", "mount_point", "fs", "mount_options", "dump", "pass"}
local _o, dk = pcall(require,"luci.docker")
if _o and dk then
dk_root_dir = dk.new():info().body.DockerRootDir
end
for mount in proc_mounts:gmatch("[^\n]+") do
local device = mount:match("^([^%s]+)%s+.+")
-- only show /dev/xxx device
if device and device:match("/dev/") then
-- not show docker root dir mounts
if dk_root_dir and mount and mount:match(dk_root_dir) then
else
res[#res+1] = {}
local i = 0
for v in mount:gmatch("[^%s]+") do
i = i + 1
res[#res][h[i]] = v
end
res[#res+1] = {}
local i = 0
for v in mount:gmatch("[^%s]+") do
i = i + 1
res[#res][h[i]] = v
end
end
end