Add quilt integration for packages
authorFelix Fietkau <nbd@openwrt.org>
Sun, 3 Jun 2007 06:16:08 +0000 (06:16 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 3 Jun 2007 06:16:08 +0000 (06:16 +0000)
make package/<package>-prepare QUILT=1 will apply all patches using quilt
Autorebuild will be disabled, so that you can edit all patches in the build dir.
When you're done editing patches and everything works, you can call:
make package/<package>-refresh
That will copy the updated patches from quilt into package/<package>/patches,
and remove all old patches.
Before the patches are overwritten, the correct order of the patches is verified
('cat series' is compared against 'sort series').

SVN-Revision: 7471

include/package-defaults.mk
include/package.mk
include/quilt.mk [new file with mode: 0644]
package/Makefile

index 57f5ed7..16d9ae0 100644 (file)
@@ -33,12 +33,11 @@ define Package/Default
   DESCRIPTION:=
 endef
 
+Build/Patch:=$(Build/Patch/Default)
 ifneq ($(strip $(PKG_UNPACK)),)
   define Build/Prepare/Default
        $(PKG_UNPACK)
-       @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
-               $(PATCH) $(PKG_BUILD_DIR) ./patches; \
-       fi
+       $(Build/Patch)
   endef
 endif
 
index 3e2944f..daff3ed 100644 (file)
@@ -14,13 +14,16 @@ include $(INCLUDE_DIR)/prereq.mk
 include $(INCLUDE_DIR)/host.mk
 include $(INCLUDE_DIR)/unpack.mk
 include $(INCLUDE_DIR)/depends.mk
-include $(INCLUDE_DIR)/package-defaults.mk
-include $(INCLUDE_DIR)/package-dumpinfo.mk
-include $(INCLUDE_DIR)/package-ipkg.mk
 
 STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared$(if $(DUMP),,_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s))
 STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
 STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
+
+include $(INCLUDE_DIR)/quilt.mk
+include $(INCLUDE_DIR)/package-defaults.mk
+include $(INCLUDE_DIR)/package-dumpinfo.mk
+include $(INCLUDE_DIR)/package-ipkg.mk
+
 export CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
 
 ifneq ($(CONFIG_AUTOREBUILD),)
diff --git a/include/quilt.mk b/include/quilt.mk
new file mode 100644 (file)
index 0000000..ec5acc5
--- /dev/null
@@ -0,0 +1,48 @@
+# 
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_patched && echo y))
+ifneq ($(QUILT),)
+  STAMP_PREPARED:=$(strip $(STAMP_PREPARED))_q
+  CONFIG_AUTOREBUILD=
+  PATCHES:=$(shell cd ./patches; ls)
+  define Build/Patch/Default
+       rm -rf $(PKG_BUILD_DIR)/patches
+       mkdir -p $(PKG_BUILD_DIR)/patches
+       for patch in $(PATCHES); do ( \
+               cp "./patches/$$$$patch" $(PKG_BUILD_DIR); \
+               cd $(PKG_BUILD_DIR); \
+               quilt import -p 1 "$$$$patch"; \
+               quilt push; \
+               quilt refresh; \
+               rm -f "$$$$patch"; \
+       ); done
+       touch $(PKG_BUILD_DIR)/.quilt_patched
+  endef
+else
+  define Build/Patch/Default
+       @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
+               $(PATCH) $(PKG_BUILD_DIR) ./patches; \
+       fi
+  endef
+endif
+
+refresh: $(STAMP_PREPARED)
+       @[ -f "$(PKG_BUILD_DIR)/patches/series" ] || { \
+               echo "The source directory was not unpacked using quilt. Please rebuild."; \
+               false; \
+       }
+       @[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] || { \
+               echo "The patches are not sorted in the right order. Please fix."; \
+               false; \
+       }
+       rm -f ./patches/* 2>/dev/null >/dev/null
+       @( \
+               for patch in $$(cat $(PKG_BUILD_DIR)/patches/series); do \
+                       $(CP) -v "$(PKG_BUILD_DIR)/patches/$$patch" ./patches; \
+               done; \
+       )
index 64c78de..0713e8d 100644 (file)
@@ -26,9 +26,9 @@ ifeq ($(QUIET),1)
 %-compile %-install: FORCE
        $(MAKE) -C $* $(patsubst $*-%,%,$@) || { $(call MESSAGE, "*** $* $(patsubst $*-%,%,$@) failed"); false; }
 
-%-prepare %-prereq %-download %-clean: FORCE
+%-prepare %-prereq %-download %-clean %-refresh: FORCE
 else
-%-prepare %-prereq %-download %-clean %-compile %-install: FORCE
+%-prepare %-prereq %-download %-clean %-compile %-install %-refresh: FORCE
 endif
        $(MAKE) -C $* $(patsubst $*-%,%,$@)