include/kernel: Switch to git download method
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 9 Nov 2016 17:34:18 +0000 (09:34 -0800)
committerFelix Fietkau <nbd@nbd.name>
Sun, 4 Dec 2016 10:41:51 +0000 (11:41 +0100)
Utilize the existing git download logic from include/download.mk and migrate
the kernel download over to it. This avoids repeatedly cloning kernel sources
after a make target/linux/clean for instance.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [fix build error]
include/kernel-build.mk
include/kernel-defaults.mk

index 04878f8250a9fd608d1ab3d58efffb195866cf97..062c458ab7715bbacf904e4a9a777454c2812386 100644 (file)
@@ -46,6 +46,24 @@ define Download/kernel
   MD5SUM:=$(LINUX_KERNEL_MD5SUM)
 endef
 
+KERNEL_GIT_OPTS:=
+ifneq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
+  KERNEL_GIT_OPTS+=--reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)
+endif
+
+ifneq ($(strip $(CONFIG_KERNEL_GIT_BRANCH)),"")
+  KERNEL_GIT_OPTS+=--branch $(CONFIG_KERNEL_GIT_BRANCH)
+endif
+
+define Download/git-kernel
+  URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
+  PROTO:=git
+  VERSION:=$(CONFIG_KERNEL_GIT_BRANCH)
+  FILE:=$(LINUX_SOURCE)
+  SUBDIR:=linux-$(KERNEL_PATCHVER)
+  OPTS:=$(KERNEL_GIT_OPTS)
+endef
+
 ifdef CONFIG_COLLECT_KERNEL_DEBUG
   define Kernel/CollectDebug
        rm -rf $(KERNEL_BUILD_DIR)/debug
@@ -73,6 +91,7 @@ endif
 define BuildKernel
   $(if $(QUILT),$(Build/Quilt))
   $(if $(LINUX_SITE),$(call Download,kernel))
+  $(if $(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),$(call Download,git-kernel))
 
   .NOTPARALLEL:
 
index eff4700fcaa1efd2a078413ee8ab51ee0edb54f0..a17b489c982274defd6afbcb7f519d9a3d918354 100644 (file)
@@ -49,15 +49,6 @@ export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
 # defined in quilt.mk
 Kernel/Patch:=$(Kernel/Patch/Default)
 
-KERNEL_GIT_OPTS:=
-ifneq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"")
-  KERNEL_GIT_OPTS+=--reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)
-endif
-
-ifneq ($(strip $(CONFIG_KERNEL_GIT_BRANCH)),"")
-  KERNEL_GIT_OPTS+=--branch $(CONFIG_KERNEL_GIT_BRANCH)
-endif
-
 ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
   ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
     define Kernel/Prepare/Default
@@ -67,7 +58,7 @@ ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
     endef
   else
     define Kernel/Prepare/Default
-       git clone $(KERNEL_GIT_OPTS) $(CONFIG_KERNEL_GIT_CLONE_URI) $(LINUX_DIR)
+       xzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
     endef
   endif
 else