openwrt 添加 應用(luci-application)


openwrt 添加應用的幾個步驟如下:

(1)在目錄 ./feeds/luci/applications 下添加要增加的應用,譬如 "luci-test"

(2)里面應該包含以下幾個目錄

hbg@root:~/trunk/feeds/luci/applications/luci-test$ tree
.
├── ipkg                      //  1、包相關
│   ├── conffiles
│   ├── postinst
│   └── postrm
├── luasrc                  //   2、web界面相關
│   ├── controller
│   │   └── test.lua
│   ├── model
│   └── view
├── Makefile              //  3、編譯相關
├── po
│   ├── en
│   │   └── test.po
│   └── zh_CN
│       └── test.po
├── root                   //  4、/etc/目錄下相關文件
│   ├── config
│   │   └── test               
│   ├── init.d
│   │   └── test
│   └── uci-defaults
│       └── luci-dtest
└── src                    //  5、實現功能的主程序
    ├── test.c
    └── test.h

 

(3)除此之外,還需要修改  ./feeds/luci/contrib/package/luci 目錄下的makefile,使其能夠在 make menuconfig  中顯示。

$(eval $(call application,dtest, test 1.0,\
       +PACKAGE_luci-app-test:libuci +libpthread +libubox +librt)) 

 

然后就可以在 make menuconfig中查找到test的選項了。

注意: 在執行命令"make menuconfig"之前,需要先清空 /tmp目錄。

 

 

 

 

補充知識:

Categories(luci目錄)

The LuCI modules are divided into several category directories, namely:

  • applications (Single applications or plugins for other modules or applications, 應用)
  • i18n (Translation files, 翻譯文件)
  • libs (Independent libraries, 獨立的庫)
  • modules (Collections of applications, 應用集合)
  • themes (Frontend themes, 前端主題)

Each module goes into a subdirectory of any of this category-directories.

Module directory

The contents of a module directory are as follows:

Makefile

This is the module's makefile. If the module just contains Lua source code or resources then the following Makefile should suffice.

如果module中只有 lua 代碼文件和資源文件,那么Makefile包含如下內容足以:

include ../../build/config.mk

include ../../build/module.mk

 

If you have C(++) code in your module your Makefile should at least contain the following things.

如果module中包含了 C 或 C++ 代碼文件,則需要包含如下內容:

include ../../build/config.mk

include ../../build/gccconfig.mk

include ../../build/module.mk

 

compile:

    # Commands to compile and link your C-code

    # and to install them under the dist/ hierarchy

 

clean: luaclean

    # Commands to clean your compiled objects

src

The src directory is reserved for C source code.

src 目錄用來保存 C源碼。

luasrc

luasrc contains all Lua source code files. These will automatically be stripped or compiled depending on the Make target and are installed in the LuCI installation directory.

Luasrc 目錄用來保存所有的 lua 源代碼。 

lua

lua is equivalent to luasrc but containing Lua files will be installed in the Lua document root.

htdocs

All files under htdocs will be copied to the document root of the target webserver.

htdocs 目錄將被拷貝到目標webserver下的文檔根目錄。

root

All directories and files under root will be copied to the installation target as they are.

拷貝到設備的根目錄下。

dist

dist is reserved for the builder to create a working installation tree that will represent the file system on the target machine. DO NOT put any files there as they will get deleted.

 

ipkg

ipkg contains IPKG package control files, like preinst, posinst, prerm, postrm. conffiles. See IPKG documentation for details.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM