[ 编译篇 ] Buildroot Add Package的一些坑

主要说明添加package 遇到的问题以及解决方法

步骤如下:
1. buildroot/configs/xxx_defconfig 添加配置选项 BR2_PACKAGE_DEMO_NAME=y 

2. 目录中buildroot/package/demo_name

3. demo_name 添加demo_name.mk 和 Config.in 

4. package/COnfig.in添加source "package/demo_name/Config.in"

5. buildroot 根目录编译 make demo_name-rebuild

Config.in 内容如下

config BR2_PACKAGE_DEMO_NAME
    bool "demo name"
    help
		demo name 

demo_name.mk 内容如下

DEMO_NAME_VERSION = 20181126
DEMO_NAME_SITE = $(TOPDIR)/../xxx_path
DEMO_NAME_SITE_METHOD = local

define DEMO_NAME_BUILD_CMDS
    $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) all armhf=1
endef

define DEMAO_NAME_INSTALL_TARGET_CMDS
      $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) install
endef

$(eval $(generic-package))

编译过程中报错如下:
umask 0022 && make -C xxxx demo_name
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
>>> demo_name 20181126 Downloading
xxxx/demo_name-20181126.tar.gz: Scheme missing.
--2018-11-26 21:22:13--  http://openlinux.xxx.com:xxx/download/GPL_code_release/ThirdParty/demo-name-20181126.tar.gz
Resolving openlinux.amlogic.com (openlinux.amlogic.com)... 120.25.202.108
Connecting to openlinux.amlogic.com (openlinux.amlogic.com)|120.25.202.108|:8000... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-11-26 21:22:13 ERROR 404: Not Found.

奇怪的是配置文件中(DEMO_NAME_SITE_METHOD = local)已经说明这个包存在本地,编译的时候怎么还去网上下载,而且官方文档已经说明

local for a local source code directory. One should use this when
LIBFOO_SITE specifies a local directory path containing the package
source code. Buildroot copies the contents of the source directory
into the package’s build directory. Note that for local packages, no
patches are applied. If you need to still patch the source code, use
LIBFOO_POST_RSYNC_HOOKS, see Section 17.21.1, “Using the POST_RSYNC
hook”.

本地的包只需要调用rsync实现拷贝的过程,起初判断肯定是demo_name.mk配置文件写错了,和系统自带的demo对来对去,也没有发现问题,多亏同事提醒:是不是demo_name.mk格式有问题

仔细核对,果然发现DEMO_NAME_SITE_METHOD = local后有空格,去掉空格后,问题解决

应该是local 后有空格,buildroot没有识别DEMO_NAME_SITE_METHOD字段,导致本地的包去网上下载,就算网上下载下来,也会报错,因为没有实现rsync拷贝的过程,output/build/demo_name 目录就是空的,编译肯定会报错


参考
  • Buildroot构建指南–快速上手与实用技巧
  • Chapter 17. Adding new packages to Buildroot

你可能感兴趣的:([,工作积累,])