quinnwencn / blog

Apache License 2.0
0 stars 0 forks source link

07 在openwrt中增加aktualizr组件 #16

Open quinnwencn opened 7 months ago

quinnwencn commented 7 months ago

[aktualizr] 是基于CMake构建的包,在此前的定制包示例中,都是基于Makefile编译的,因此这篇博客主要记录如何增加CMAKE编译的组件。 编写的CMAKE如下:

include $(TOPDIR)/rules.mk

# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=aktualizr
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/advancedtelematic/aktualizr.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
PKG_SOURCE_VERSION:=2020.10

PKG_BUILD_DIR:=$(BUILD_DIR)/${PKG_NAME}
PKG_INSTALL_DIR:=$(STAGING_DIR)/root-layerscape
CMAKE_BINARY_SUBDIR:=build

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/${PKG_NAME}
        SECTION:=libs
        CATEGORY:=Libraries
        TITLE:=aktualizr
        DEPENDS:=+asn1c +boost +libboost_log +libboost_program_options +libpsl +libcurl +libsodium +ostree
endef

define Package/${PKG_NAME}/description
        This is a FOTA client for embedded systems. It can be used to update the software on a device over-the-air.
endef

CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=Debug

define Package/${PKG_NAME}/install
        $(INSTALL_DIR) $(1)/usr/bin
endef

$(eval $(call BuildPackage,${PKG_NAME}))

由于aktualizr无法在源码目录编译,否则会出现以下错误: image 在解决这个问题的时候花费了较长时间,最后是通过openwrt论坛提问得到的解决方法,具体帖子参考:openwrt提问求助。 其中,include $(INCLUDE_DIR)/cmake.mk只有在编译cmake的包是2才需要引入,CMAKE_BINARY_SUBDIR定义了编译的路径,正是这个变量解决了上述问题。除了这个问题外,如果依赖只添加boost或者添加的方式为+libboost_atomic或者是boost_atomic,都会出现以下这个错误:

Package aktualizr is missing dependencies for the following libraries:
libboost_atomic.so.1.78.0
libboost_chrono.so.1.78.0
libboost_filesystem.so.1.78.0
libboost_log.so.1.78.0
libboost_log_setup.so.1.78.0
libboost_program_options.so.1.78.0
libboost_regex.so.1.78.0
libboost_system.so.1.78.0
libboost_thread.so.1.78.0

正确的添加方式是:

define Package/${PKG_NAME}
        SECTION:=TCU
        CATEGORY:=TCU
        SUBMENU:=Utils
        TITLE:=aktualizr
        DEPENDS:=+libc +libopenssl +boost +boost-atomic +boost-chrono +boost-filesystem +boost-log +boost-program_options +boost-regex +boost-thread +boost-system +libpsl +libcurl +libsodium +libostree +libarchive +libsqlite3 
endef