【问题标题】:Applying patch kept in br2-external to a buildroot package将保存在 br2-external 中的补丁应用到 buildroot 包
【发布时间】:2021-01-21 19:31:01
【问题描述】:

我想为 buildroot 包应用补丁。我正在使用br2-external tree 将我的自定义设置排除在 buildroot 树之外。 Buildroot 可以找到我的补丁,但在尝试应用时失败。

我已设置BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_PATH}/board/myboard/patches" 并将补丁放入${BR2_EXTERNAL_PATH}/board/myboard/patches/packagename/0001-name-of-patch.patch。我通过转到buildroot repo 生成补丁,将更改应用到包,使用 git 提交它们并从上次提交创建补丁: git format-patch HEAD~1 所以补丁看起来像这样:

diff --git a/package/rpi-firmware/cmdline.txt b/package/rpi-firmware/cmdline.txt
index 155a54693b..630cfa9e00 100644
--- a/package/rpi-firmware/cmdline.txt
+++ b/package/rpi-firmware/cmdline.txt
@@ -1 +1 @@
-old code line
+new code line

但是,当我运行make 时,在修补期间找不到要修补的文件(路径错误)

Applying 0001-name-of-patch.patch using patch:
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/package/rpi-firmware/cmdline.txt b/package/rpi-firmware/cmdline.txt
|index 155a54693b..630cfa9e00 100644
|--- a/package/rpi-firmware/cmdline.txt
|+++ b/package/rpi-firmware/cmdline.txt
--------------------------
No file to patch.  Skipping patch.

我还尝试了rpi-firmware/cmdline.txtcmdline.txt 路径。

我应该在补丁文件中使用什么路径?它应该相对于包,相对于 buildroot 存储库根目录,还是指向相对于全局补丁目录的包?我关注了https://buildroot.org/downloads/manual/manual.html#customize-patches,但找不到这个问题的答案。

【问题讨论】:

  • AFAIK 您无法使用 make 修补 package/ 目录中的文件。没有特殊的 .stamp_patched 文件写入每个 package// 子目录,以确保补丁只应用一次,不应再次应用。补丁通常应用于 output/build// 中的文件。
  • 感谢您的评论 ;) 我可以在 output/build/ 中修补它。我想要的只是让补丁包登陆我的图像。我认为这里的问题是源在 buildroot/package/ 中,而补丁在 ${BR2_GLOBAL_PATCH_DIR} 中。
  • "我认为这里的问题是源码在buildroot/package/..." -- 是的,而且里面没有副本输出/构建//。或许您可以使用构建后脚本修补 已安装 版本的文件 $(BINARIES_DIR)/rpi-firmware/cmdline.txt
  • 谢谢,这是我正在考虑的替代方案,我采用了这个解决方案。

标签: git raspberry-pi diff embedded-linux buildroot


【解决方案1】:

正如@sawdust 所提到的,它不可能修补buildroot 包目录buildroot/package/<package_name> 中的文件。只能打补丁包的源,即下载到output/build/<package_name>/的源文件。

https://buildroot.org/downloads/manual/manual.html#rootfs-custom(选项BR2_ROOTFS_POST_BUILD_SCRIPT="${BR2_EXTERNAL_PATH}/board/myboard/scripts/post-build.sh")中所述,我最终使用构建后脚本在文件复制后对其进行修改

【讨论】:

猜你喜欢
  • 2021-01-01
  • 1970-01-01
  • 2011-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-01
  • 1970-01-01
相关资源
最近更新 更多