include $(TOPDIR)/rules.mk
PKG_NAME:=uci
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL=$(LEDE_GIT)/project/uci.git
PKG_SOURCE_PROTO:=git
PKG_BUILD_PARALLEL:=0
+HOST_BUILD_DEPENDS:=libubox/host
+
include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk
# set to 1 to enable debugging
-DLUAPATH=/usr/lib/lua \
$(if $(DEBUG),-DUCI_DEBUG=ON)
+CMAKE_HOST_OPTIONS += \
+ -DBUILD_STATIC=ON \
+ -DBUILD_LUA=OFF \
+
define Package/libuci/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/lib/
$(CP) $(PKG_BUILD_DIR)/libucimap.a $(1)/usr/lib
endef
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOST)/sbin
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/uci $(STAGING_DIR_HOST)/sbin/uci
+endef
+
$(eval $(call BuildPackage,uci))
$(eval $(call BuildPackage,libuci))
$(eval $(call BuildPackage,libuci-lua))
+$(eval $(call HostBuild))
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
CONFIG_APPEND=
+UCI="${UCI:-/sbin/uci}"
+UCI_STATE_DIR="${IPKG_INSTROOT}/var/state}"
+
uci_load() {
local PACKAGE="$1"
local DATA
export ${NO_EXPORT:+-n} CONFIG_SECTION=
fi
- DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
+ DATA="$($UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P "$UCI_STATE_DIR"} -S -n export "$PACKAGE" 2>/dev/null)"
RET="$?"
[ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA"
unset DATA
uci_set_default() {
local PACKAGE="$1"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE"
}
uci_revert_state() {
local CONFIG="$2"
local OPTION="$3"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P "$UCI_STATE_DIR" revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
}
uci_set_state() {
local VALUE="$4"
[ "$#" = 4 ] || return 0
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P "$UCI_STATE_DIR" set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
}
uci_toggle_state() {
local OPTION="$3"
local VALUE="$4"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
}
uci_get_state() {
- uci_get "$1" "$2" "$3" "$4" "/var/state"
+ uci_get "$1" "$2" "$3" "$4" ""$UCI_STATE_DIR""
}
uci_get() {
local DEFAULT="$4"
local STATE="$5"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
RET="$?"
[ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT"
return "$RET"
local CONFIG="$3"
if [ -z "$CONFIG" ]; then
- export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$($UCI add "$PACKAGE" "$TYPE")"
else
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG"
fi
}
local CONFIG="$2"
local VALUE="$3"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
}
uci_remove() {
local CONFIG="$2"
local OPTION="$3"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
}
uci_commit() {
local PACKAGE="$1"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
+ $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
}