use UCI on ubuntu

The following HOWTO introduces the building of UCI (Unified Configuration Interface) on Ubuntu.

  1. Some extra package are required:

    sudo apt-get install cmake lua5.2

  2. The libubox library is required. It should to compiled from source. To do this, first you have to get the source from git:  

    git clone git://nbd.name/luci2/libubox.git libubox
    cd libubox


  3. Please follow the next steps to build libubox:

    mkdir build
    cd build
    cmake ..
    make ubox


  4. Install libubox:

    sudo mkdir -p /usr/local/include/libubox
    sudo cp ../*.h /usr/local/include/libubox
    sudo cp libubox.so /usr/local/lib
    sudo ldconfig


  5. Get UCI source from git:

    git clone git://nbd.name/uci.git uci
    cd uci


  6. Please follow the next steps to build uci:

    mkdir build
    cd build
    cmake ..
    make uci cli


  7. Install uci:

    sudo mkdir -p /usr/local/include/uci
    sudo cp ../uci.h ../uci_config.h /usr/local/include/uci
    sudo cp ../uci_blob.h ../ucimap.h /usr/local/include/uci
    sudo cp libuci.so /usr/local/lib
    sudo cp uci /usr/local/bin
    sudo ldconfig


  8. Testing:

    mkdir test
    cat > test/test << EOF
    > config 'test' 'abc'
    > option 'test_var' 'value'
    > EOF


    uci -c `pwd`/test show test
    Output:
    test.abc=test
    test.abc.test_var=value


    uci -c `pwd`/test set test.abc.test_var=foobar
    uci -c `pwd`/test commit test


    uci -c `pwd`/test show test
    Output:
    test.abc=test
    test.abc.test_var=foobar


    在centos 6.4 上试验过,uci 命令 找不到动态库,将动态库拷贝到 /lib 下面!!!!

猜你喜欢

转载自blog.csdn.net/twd_1991/article/details/80392911