Andreas Wacknitz
2024-04-05 f09dca6e20c67020d6f337fc95eec480de4d24ef
make-rules/prep-patch.mk
@@ -47,9 +47,7 @@
PATCH_DIR ?=      patches
PATCHES =   $(shell find $(PATCH_DIR) -type f \
          -name '$(PATCH_PATTERN)' 2>/dev/null | \
            LC_COLLATE=C sort)
PATCHES =   $(wildcard $(PATCH_DIR)/$(PATCH_PATTERN))
PCH_SUFFIXES = $(patsubst .patch_%,%, $(filter-out .patch,$(suffix $(PATCHES))))
@@ -109,15 +107,19 @@
   for p in $(PATCHES) ; do \
      echo $$p ; \
   done | $(TAC) | while read p ; do \
      $(GPATCH) -d $(SOURCE_DIR) --strip=$(PATCH_LEVEL) --reverse < $$p ; \
      $(GPATCH) -d $(SOURCE_DIR) --strip=$(PATCH_LEVEL) --reverse < $$p \
      && continue ; \
      exit 1 ; \
   done
   # Make sure the series file does not exist
   $(RM) $(COMPONENT_DIR)/$(PATCH_DIR)/series
   # Apply and refresh patches, then unapply them
   cd $(SOURCE_DIR) ; for p in $(PATCHES) ; do \
      QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null "../$$p" ; \
      QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q ; \
      QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 1 --no-timestamps --no-index ; \
      QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null "../$$p" \
      && QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q \
      && QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 1 --no-timestamps --no-index \
      && continue ; \
      exit 1 ; \
   done ; \
   [ ! -e $(COMPONENT_DIR)/$(PATCH_DIR)/series ] || QUILT_PATCHES=../$(PATCH_DIR) quilt pop --quiltrc /dev/null -a -q
   # cleanup
@@ -125,9 +127,11 @@
   $(RM) $(COMPONENT_DIR)/$(PATCH_DIR)/series
   # Apply and refresh patches again to get the desired patch format
   for p in $(PATCHES) ; do \
      QUILT_PATCHES=$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null -p 0 "$$p" ; \
      QUILT_PATCHES=$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q ; \
      QUILT_PATCHES=$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 0 --no-timestamps --no-index ; \
      QUILT_PATCHES=$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null -p 0 "$$p" \
      && QUILT_PATCHES=$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q \
      && QUILT_PATCHES=$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 0 --no-timestamps --no-index \
      && continue ; \
      exit 1 ; \
   done
   # final cleanup
   $(RM) -r $(COMPONENT_DIR)/.pc