mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 08:30:47 -09:00
package/pkg-generic.mk: factor out patch directories
The .stamp_patched rule currently uses shell loops and conditions to iterate over the patches in the package directory and BR2_GLOBAL_PATCH_DIRS and to select between the versioned and unversioned directory. We want to add the patch list to show-info as well, so we need a way to do this entirely in Make functions. Introduce the function pkg-patches-dirs in pkg-utils which copies this functionality in make syntax, and use it in the .stamp_patched rule. As an extra simplification, only consider the version directory if PKG_VERSION actually exists. Otherwise, we would use the directory with a slash appended for packages without version. Why this does work, it just looks weird for no reason. Furthermore, introduce the function pkg-patch-hash-dirs which simply enumerates the package directory and the package subdirectories of BR2_GLOBAL_PATCH_DIRS. This function is used for _HASH_FILES as well. Ideally, we should be able to factor our the handling of the version subdirectory between the patches and hashes as well. Unfortunately, they are treated subtly different: patches don't use the base directory if the version directory exists, while hashes do use the base directory. We don't want to change this behaviour. Signed-off-by: Thomas Perale <thomas.perale@mind.be> Co-authored-by: Matthias Swiggers <matthias.swiggers@mind.be> [Arnout: - split into a separate patch; - don't fully factor with _HASH_FILES because version is treaded differently; - introduce pkg-patch-hash-dirs; - retain the RAWNAME comment, but move it to pkg-patch-hash-dirs; - use foreach instead of shell loop, and $(seq) instead of exit 1; - rewrite to retain original behaviour of only using versioned dir. ] Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
committed by
Arnout Vandecappelle
parent
98aec6280a
commit
99d4180eda
@@ -231,29 +231,13 @@ $(BUILD_DIR)/%/.stamp_rsynced:
|
||||
$(Q)touch $@
|
||||
|
||||
# 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: 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) $($(PKG)_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 || exit 1; \
|
||||
else \
|
||||
$(APPLY_PATCHES) $(@D) $${D} \*.patch || exit 1; \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
$(foreach dir,$(call pkg-patches-dirs,$(PKG)),\
|
||||
$(Q)$(APPLY_PATCHES) $(@D) $(dir) \*.patch$(sep)\
|
||||
)
|
||||
$(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
|
||||
@$(call step_end,patch)
|
||||
@@ -517,7 +501,7 @@ $(2)_VERSION := $$(call sanitize,$$($(2)_DL_VERSION))
|
||||
|
||||
$(2)_HASH_FILES = \
|
||||
$$(strip \
|
||||
$$(foreach d, $$($(2)_PKGDIR) $$(addsuffix /$$($(2)_RAWNAME), $$(call qstrip,$$(BR2_GLOBAL_PATCH_DIR))),\
|
||||
$$(foreach d, $$(call pkg-patch-hash-dirs,$(2)),\
|
||||
$$(if $$(wildcard $$(d)/$$($(2)_VERSION)/$$($(2)_RAWNAME).hash),\
|
||||
$$(d)/$$($(2)_VERSION)/$$($(2)_RAWNAME).hash,\
|
||||
$$(d)/$$($(2)_RAWNAME).hash\
|
||||
|
||||
@@ -156,6 +156,18 @@ define _json-info-pkg
|
||||
)
|
||||
endef
|
||||
|
||||
# The RAWNAME variable is the lowercased package name, which allows to
|
||||
# find the package directory (typically package/<pkgname>) and the
|
||||
# prefix of the patches
|
||||
pkg-patch-hash-dirs = \
|
||||
$($(1)_PKGDIR) $(addsuffix /$($(1)_RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))
|
||||
|
||||
pkg-patches-dirs = \
|
||||
$(foreach dir, $(call pkg-patch-hash-dirs,$(1)),\
|
||||
$(wildcard $(if $($(1)_VERSION),\
|
||||
$(or $(wildcard $(dir)/$($(1)_VERSION)),$(dir)),\
|
||||
$(dir))))
|
||||
|
||||
define _json-info-pkg-details
|
||||
"version": $(call mk-json-str,$($(1)_DL_VERSION)),
|
||||
"licenses": $(call mk-json-str,$($(1)_LICENSE)),
|
||||
|
||||
Reference in New Issue
Block a user