BuildSystem: Provide Overlay Feeds base infrastructure implementation
Problem: OpenWRT Build system provide no way to extend package from 3rd party feed.
As a result in order to manage CVE patches or small modification to a single package
we should make copy of package in feeds that we own and monitor any changes in the
package original feed to not miss upstream updates.
Solution: Include all $(PKG_DIR_NAME)/Makefile.append files as part of first
$(eval $(call BuildPackage,packagename)) call in original $(PKG_DIR_NAME)/Makefile.
Add append directories to PKG_FILE_DEPENDS in order to invalidate build when
append files changed.
Together with this change provide several useful functions and variables:
Variable $(THISDIR) -- defined in context of Makefile.append files to and points to
the directory where Makefile.append recipe. Can be used to find additional patches,
config fragments, etc.
Variable $(OVERLAY_PATCHES) -- can be used to provide additional patch files for package
sources in the following manner:
OVERLAY_PATCHES := $(OVERLAY_PATCHES) $(THISDIR)/patches/filename.patch
OVERLAY_PATCHES := $(OVERLAY_PATCHES) $(wildcard $(THISDIR)/patches/*.patch)
Variable $(newline) -- contains single "\n" symbol. Required to append/prepend
OpenWRT multiline variables with additional line.
Functions (append,VARNAME,value[,override]) -- used to append "value" string to variable VARNAME.
Behave like "+=" with two exceptions:
1. Append "value" without extra space before the value
2. The "value" expanded immediately before the assignment, while VARNAME is treated
as recursive expand variable. Such behavior allow you to use $(THISDIR) variable
together with "append" function. For example the following call will expand
$(THISDIR) immediately:
$(call append,Package/helloworld/config,$(newline)source "$(THISDIR)/Config.in")
Function (prepend,VARNAME,value[,override]) -- used to prepend "value" string to variable VARNAME.
Shares "append" function behavior regards expansion time. In order to append string
with delayed expansion time you can replace $(...) with $$(...). For exaple the
following call will delay $(Build/IncludeOverlay) expansion:
$(call prepend,BuildPackage,$$(Build/IncludeOverlay)$(newline))
Function (remove,VARNAME,value[,override]) -- behave like "filter-out" function, but allow to
control expansion time of the passed "value".
Function (rewrite,VARNAME,value[,override]) -- generalized function that allow arbitrary change
of VARNAME variable value controlling "value" expansion time.
All this functions support optional last argument that allow to modify "override VARNAME" instead
of non-override version of VARNAME.
References: PCF-1615
Signed-off-by: Ivan Efimov <i.efimov@inango-systems.com>
Signed-off-by: Nicolai Scurtu <n.scurtu@inango-systems.com>
Signed-off-by: Vadym Omelchuk <v.omelchuk@inango-systems.com>
Signed-off-by: Vladimir Shulika <v.shulika@inango-systems.com>
Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com>
This commit is contained in:
parent
1cdcba5207
commit
469e1eb8a8
22
include/overlay-feed/helpers.mk
Normal file
22
include/overlay-feed/helpers.mk
Normal file
@ -0,0 +1,22 @@
|
||||
define rewrite
|
||||
$(eval $(3) define $(1)
|
||||
$(2)
|
||||
endef)
|
||||
endef
|
||||
|
||||
define prepend
|
||||
$(call rewrite,$(1),$(2)$(value $(1)),$(3))
|
||||
endef
|
||||
|
||||
define append
|
||||
$(call rewrite,$(1),$(value $(1))$(2),$(3))
|
||||
endef
|
||||
|
||||
define remove
|
||||
$(call rewrite,$(1),$(filter-out $(2),$(value $(1))),$(3))
|
||||
endef
|
||||
|
||||
define newline
|
||||
|
||||
|
||||
endef
|
||||
27
include/overlay-feed/package.mk
Normal file
27
include/overlay-feed/package.mk
Normal file
@ -0,0 +1,27 @@
|
||||
include $(INCLUDE_DIR)/overlay-feed/helpers.mk
|
||||
|
||||
# All patches which paths added into OVERLAY_PATCHES
|
||||
# will be applied on package build dir after Prepare step
|
||||
# of main package
|
||||
OVERLAY_PATCHES ?=
|
||||
|
||||
define Overlay/Prepare/Patch
|
||||
$(foreach pf,$(filter %.patch,$(OVERLAY_PATCHES)), \
|
||||
patch -d "$(PKG_BUILD_DIR)" -p1 < $(pf) $$(newline) \
|
||||
)
|
||||
endef
|
||||
Hooks/Prepare/Post += Overlay/Prepare/Patch
|
||||
|
||||
OVERLAY_MAKEFILE_APPENDS := $(foreach feed,$(shell $(TOPDIR)/scripts/feeds list -n 2>/dev/null),$(shell find -L $(TOPDIR)/feeds/$(feed)/ -path '*/$(PKG_DIR_NAME)/Makefile.append' | sort))
|
||||
PKG_FILE_DEPENDS += $(foreach mk,$(OVERLAY_MAKEFILE_APPENDS), $(dir $(mk)))
|
||||
|
||||
define Build/IncludeOverlay
|
||||
# Clean out Build/IncludeOverlay to prevent recursive expansion
|
||||
$(eval Build/IncludeOverlay=)
|
||||
$(foreach mk,$(OVERLAY_MAKEFILE_APPENDS), \
|
||||
$(eval THISDIR := $(dir $(mk))) \
|
||||
$(eval -include $(mk)) \
|
||||
)
|
||||
endef
|
||||
|
||||
$(call prepend,BuildPackage,$$(Build/IncludeOverlay)$(newline))
|
||||
@ -379,3 +379,5 @@ dist:
|
||||
|
||||
distcheck:
|
||||
$(Build/DistCheck)
|
||||
|
||||
include $(INCLUDE_DIR)/overlay-feed/package.mk
|
||||
|
||||
Loading…
Reference in New Issue
Block a user