修改buildroot pkg-generic.mk以将修补程序应用于本地软件包吗?

问题描述

基于我的最后一个问题here

buildroot不会将补丁应用到我的软件包,因为已经回答了我先前的问题...但是我想有一种方法可以添加逻辑来始终应用补丁?

这是由构建根目录运行的代码部分

# Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
# used.
$(BUILD_DIR)/%/.stamp_rsynced:
    @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
    @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
    $(foreach hook,$($(PKG)_PRE_RSYNC_HOOKS),$(call $(hook))$(sep))
    rsync -au --chmod=u=rwX,go=rX $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D)
    $(foreach hook,$($(PKG)_POST_RSYNC_HOOKS),$(call $(hook))$(sep))
    #GV_PATCH : do not touch stamp_rsynced to force rsync

现在,在rsync部分的正下方,是我想运行的将补丁应用于本地软件包的代码,我已经在buildroot配置中定义了BR2_GLOBAL_PATCH_DIR,并在其中包含了补丁软件包的目录和补丁。这是我想在rsync之后运行的补丁代码

# Patch
#
# The RAWNAME variable is the lowercased package name,which allows to
# find the package directory (typically package/<pkgname>) and the
# prefix of the patches
#
# For BR2_GLOBAL_PATCH_DIR,only generate if it is defined
$(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_Dirs =  $(PKGDIR)
$(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_Dirs += $(addsuffix /$(RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))
$(BUILD_DIR)/%/.stamp_patched:
    @$(call step_start,patch)
    @$(call MESSAGE,"Patching")
    $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
    $(foreach p,$($(PKG)_PATCH),$(APPLY_PATCHES) $(@D) $(DL_DIR) $(notdir $(p))$(sep))
    $(Q)( \
    for D in $(PATCH_BASE_Dirs); do \
      if test -d $${D}; then \
        if test -d $${D}/$($(PKG)_VERSION); then \
          $(APPLY_PATCHES) $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
        else \
          $(APPLY_PATCHES) $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
        fi; \
      fi; \
    done; \
    )
    $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
    @$(call step_end,patch)
    $(Q)touch $@

# Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
$(foreach dir,$(BR2_GLOBAL_PATCH_DIR)),\
    $(if $(wildcard $(dir)),\
        $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory $(dir))))

这可能吗?

我尝试在@$(call step_start,patch)之后的代码的第一部分添加#GV_PATCH,但是没有用。

我不是制作文件的专家,但是我发现有一种方法可以调用补丁代码?我就是不知道。

解决方法

答案与给定的at the end of your previous question相同:

# Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
# used.
$(BUILD_DIR)/%/.stamp_rsynced:
        @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
        @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
        $(foreach hook,$($(PKG)_PRE_RSYNC_HOOKS),$(call $(hook))$(sep))
        rsync -au --chmod=u=rwX,go=rX $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D)
        $(foreach hook,$($(PKG)_POST_RSYNC_HOOKS),$(call $(hook))$(sep))
        #GV_PATCH : do not touch stamp_rsynced to force rsync
        # Apply patches in global patch dir,but no others
        $(APPLY_PATCHES) $(@D) $(addsuffix /$(RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \*.patch

顺便说一句,您不需要删除标记文件,只需使用make foo-rebuild-它也会重新同步程序包。