+# SPDX-License-Identifier: GPL-2.0-only
#
-# Copyright (C) 2007-2009 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
+# Copyright (C) 2007-2020 OpenWrt.org
ifeq ($(TARGET_BUILD),1)
PKG_BUILD_DIR:=$(LINUX_DIR)
endif
+ifneq ($(filter host-refresh refresh,$(MAKECMDGOALS)),)
+ override QUILT=1
+ override HOST_QUILT=1
+endif
+
ifneq ($(PKG_BUILD_DIR),)
QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y)
ifneq ($(QUILT),)
ifneq ($(if $(DUMP),1,$(__quilt_inc)),1)
__quilt_inc:=1
-PATCH_DIR?=./patches
-FILES_DIR?=./files
+PATCH_DIR?=$(CURDIR)/patches
+FILES_DIR?=$(CURDIR)/files
HOST_PATCH_DIR?=$(PATCH_DIR)
HOST_FILES_DIR?=$(FILES_DIR)
-ifneq ($(filter host-refresh refresh,$(MAKECMDGOALS)),)
- override QUILT=1
- override HOST_QUILT=1
-endif
-
QUILT_CMD:=quilt --quiltrc=-
define filter_series
kernel_files=$(foreach fdir,$(GENERIC_FILES_DIR) $(FILES_DIR),$(fdir)/.)
define Kernel/Patch/Default
- $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches)
+ $(if $(QUILT),rm -rf $(LINUX_DIR)/patches; mkdir -p $(LINUX_DIR)/patches)
$(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/)
find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f
- $(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
- $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
+ if [ -d $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) ]; then \
+ echo "generic patches directory is present. please move your patches to the pending directory" ; \
+ exit 1; \
+ fi
+ $(call PatchDir,$(LINUX_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
+ $(call PatchDir,$(LINUX_DIR),$(GENERIC_PATCH_DIR),generic/)
+ $(call PatchDir,$(LINUX_DIR),$(GENERIC_HACK_DIR),generic-hack/)
+ $(call PatchDir,$(LINUX_DIR),$(PATCH_DIR),platform/)
endef
define Quilt/RefreshDir
- mkdir -p $(2)
- -rm -f $(2)/* 2>/dev/null >/dev/null
- @( \
+ -rm -rf $(2) 2>/dev/null >/dev/null
+ [ -f $(1)/.quilt_no_patch ] || mkdir -p $(2)
+ @[ -f $(1)/.quilt_no_patch ] || { \
for patch in $$$$($(if $(3),grep "^$(3)",cat) $(1)/patches/series | awk '{print $$$$1}'); do \
$(CP) -v "$(1)/patches/$$$$patch" $(2); \
done; \
- )
+ }
+ @-rm -f $(1)/.quilt_no_patch 2>/dev/null >/dev/null;
endef
define Quilt/Refresh/Host
- $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR))
+ $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR))
endef
define Quilt/Refresh/Package
echo "All kernel patches must start with either generic/ or platform/"; \
false; \
}
+ $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_BACKPORT_DIR),generic-backport/)
$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
+ $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_HACK_DIR),generic-hack/)
$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
endef
}
@[ -f "$(1)/patches/series" ] || { \
echo "The source directory contains no quilt patches."; \
- false; \
+ touch $(1)/patches/series $(1)/.quilt_no_patch; \
}
@[ -n "$$$$(ls $(1)/patches/series)" -o \
- "$$$$(cat $(1)/patches/series | mkhash md5)" = "$$(sort $(1)/patches/series | mkhash md5)" ] || { \
+ "$$$$(cat $(1)/patches/series | $(MKHASH) md5)" = "$$(sort $(1)/patches/series | $(MKHASH) md5)" ] || { \
echo "The patches are not sorted in the right order. Please fix."; \
false; \
}
$(3)refresh: $(3)quilt-check
- @cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null
- @cd "$(1)"; while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
- QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
- done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null
+ @[ -f $(1)/.quilt_no_patch ] || { \
+ cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null; \
+ while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
+ QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
+ done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null; \
+ }
$(Quilt/Refresh/$(4))
$(3)update: $(3)quilt-check