以下安装教程在ubuntu 10.04 和 ubuntu 16.04 上测试通过。
准备环境
安装cmake
sudo apt-get install cmake
安装依赖库libubox
克隆libubox源码
git clone http://git.nbd.name/luci2/libubox.git libubox.git
cd libubox.git
编译
cmake -DBUILD_LUA=off
安装
sudo make install
安装UCI
克隆UCI源码
git clone https://git.openwrt.org/project/uci.git uci.git
cd uci.git
编译
cmake -DBUILD_LUA=off
安装
sudo make install
添加依赖库路径
编辑/etc/ld.so.conf文件,在最后一行添加上“/usr/local/lib”
test@test-desktop:~/uci.git$ cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/usr/local/lib
执行ldconfig命令使依赖路径生效
sudo ldconfig
完成上述步骤后可以敲入uci命令获得以下结果表示uci安装成功。
test@test-desktop:/usr/local/lib$ uci
Usage: uci [<options>] <command> [<arguments>]
Commands:
batch
export [<config>]
import [<config>]
changes [<config>]
commit [<config>]
add <config> <section-type>
add_list <config>.<section>.<option>=<string>
del_list <config>.<section>.<option>=<string>
show [<config>[.<section>[.<option>]]]
get <config>.<section>[.<option>]
set <config>.<section>[.<option>]=<value>
delete <config>[.<section>[[.<option>][=<id>]]]
rename <config>.<section>[.<option>]=<name>
revert <config>[.<section>[.<option>]]
reorder <config>.<section>=<position>
Options:
-c <path> set the search path for config files (default: /etc/config)
-d <str> set the delimiter for list values in uci show
-f <file> use <file> as input instead of stdin
-m when importing, merge data into an existing package
-n name unnamed sections on export (default)
-N don't name unnamed sections
-p <path> add a search path for config change files
-P <path> add a search path for config change files and use as default
-q quiet mode (don't print error messages)
-s force strict mode (stop on parser errors, default)
-S disable strict mode
-X do not use extended syntax on 'show'
附:UCI默认加载配置文件的默认路径是在/etc/config当中,可以通过修改UCI源码的’uci.h’当中的宏UCI_CONFDIR来自定义路径
#define UCI_CONFDIR "/etc/config"
修改后需要重新编译安装才能生效。