You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Buildroot 2024.02中BR2_GLOBAL_PATCH_DIR引发非补丁包hash文件缺失错误的修复咨询

Fixing Buildroot Hash File Lookup Errors Caused by Global Patch Directories

Short Answer: You don't need to modify package/pkg-generic.mk—there are cleaner workarounds available.


What's Causing This?

The issue stems from how Buildroot's pkg-generic.mk constructs the $(2)_HASH_FILES variable: it unconditionally checks both the package's native directory and the global patch directory (from BR2_GLOBAL_PATCH_DIR) for hash files. Even if you don't have patches for a package (like aria2), it still tries to look for [global-patch-dir]/[package-name]/[package-name].hash—and throws an error when that file doesn't exist.


Solutions

Option 1: Create Empty Hash Files for Unpatched Packages (Quick Fix)

For packages where you don't need patches (like aria2), just create an empty hash file in the corresponding patch directory. Buildroot will recognize it as a valid (but empty) hash source, and fall back to the package's native hash file:

# Create the directory for aria2 in your patch tree
mkdir -p /home/admin/buildroot-external-my/patches/aria2
# Touch an empty hash file
touch /home/admin/buildroot-external-my/patches/aria2/aria2.hash

This works because Buildroot prioritizes the package's native hash file first—this empty file just satisfies the lookup check without affecting the actual download validation.

Option 2: Avoid Global Patch Directory for Unpatched Packages (Cleaner Long-Term Fix)

Instead of using BR2_GLOBAL_PATCH_DIR for all packages, specify patch directories only for packages that actually need patches:

  1. Remove the global BR2_GLOBAL_PATCH_DIR setting from your configuration
  2. For packages that do need patches (like dhcpcd), explicitly set their patch directory in your external package's makefile or config:
    DHCPCD_PATCH_DIRS = $(BR2_EXTERNAL_MY_PATH)/patches/dhcpcd
    

This way, Buildroot won't scan the patch directory for hash files for every package—only the ones you've explicitly configured to use patches.


Tinkering with Buildroot's core makefiles has downsides:

  • Your changes will be overwritten when you upgrade Buildroot to a newer version, forcing you to re-apply the patch every time
  • It breaks the intended design of Buildroot's hash lookup logic, which could lead to unexpected behavior elsewhere
  • The solutions above are non-intrusive and maintainable without modifying core code

内容的提问来源于stack exchange,提问作者Papillon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 12:37:46