Add new package lua-platform-info

Provides the information given by gluon.model without the dependencies on
gluon-core and LuCi.

For now only for ar71xx-generic, additional targets should be added as needed.
This commit is contained in:
Matthias Schiffer 2014-07-09 19:44:00 +02:00
parent db7d9410b3
commit b37cde9c24
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,37 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/target.mk
PKG_NAME:=lua-platform-info
PKG_VERSION:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/lua-platform-info
SECTION:=luci
CATEGORY:=LuCi
TITLE:=Lua hardware platform information library
DEPENDS:=@TARGET_ar71xx_generic
endef
define Package/lua-platform-info/description
Lua library to obtain some generic information about the runtime platform
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/lua-platform-info/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_DATA) ./files/$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))/platform_info.lua $(1)/usr/lib/lua/
endef
$(eval $(call BuildPackage,lua-platform-info))

View File

@ -0,0 +1,32 @@
local f = io.popen('. /lib/functions.sh; . /lib/ar71xx.sh; ar71xx_board_detect; echo "$AR71XX_BOARD_NAME"; echo "$AR71XX_MODEL"')
local board_name, model = f:read("*a"):match('([^\n]+)\n([^\n]+)')
f:close()
module 'platform_info'
-- The OpenWrt target
function get_target()
return 'ar71xx'
end
-- The OpenWrt subtarget or nil
function get_subtarget()
return 'generic'
end
-- The board name
function get_board_name()
return board_name
end
-- The model name
function get_model()
return model
end
-- The image name for sysupgrades
function get_image_name()
return (model:lower():gsub('[^%w]+', '-'):gsub('%-+$', ''))
end