[LEDE-DEV] include/kernel: Allow to use git clone kernel into external tree

Message ID 20170228180640.2129-1-hauke.mehrtens@intel.com
State Deferred
Delegated to: Hauke Mehrtens
Headers show

Commit Message

Hauke Mehrtens Feb. 28, 2017, 6:06 p.m.
From: Hauke Mehrtens <hauke.mehrtens@intel.com>

This combines the usage of external kernel tree with the cloning of the
kernel tree form git. The new kernel will be cloned into an external
directory and then used from there.

Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
---
 include/kernel-defaults.mk | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Florian Fainelli Feb. 28, 2017, 6:15 p.m. | #1
On 02/28/2017 10:06 AM, hauke.mehrtens@intel.com wrote:
> From: Hauke Mehrtens <hauke.mehrtens@intel.com>
> 
> This combines the usage of external kernel tree with the cloning of the
> kernel tree form git. The new kernel will be cloned into an external
> directory and then used from there.
> 
> Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
> ---
>  include/kernel-defaults.mk | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
> index 10bd67a..6969c9f 100644
> --- a/include/kernel-defaults.mk
> +++ b/include/kernel-defaults.mk
> @@ -62,13 +62,26 @@ ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
>      endef
>    endif
>  else
> -  define Kernel/Prepare/Default
> +  ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
> +    define Kernel/Prepare/Default
>  	mkdir -p $(KERNEL_BUILD_DIR)
>  	if [ -d $(LINUX_DIR) ]; then \
>  		rmdir $(LINUX_DIR); \
>  	fi
>  	ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
> -  endef
> +    endef
> +  else
> +    define Kernel/Prepare/Default
> +	mkdir -p $(KERNEL_BUILD_DIR)
> +	if [ -d $(LINUX_DIR) ]; then \
> +		rmdir $(LINUX_DIR); \
> +	fi
> +	ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
> +	if [ ! -d $(CONFIG_EXTERNAL_KERNEL_TREE) ]; then \
> +		git clone $(KERNEL_GIT_OPTS) $(CONFIG_KERNEL_GIT_CLONE_URI) $(CONFIG_EXTERNAL_KERNEL_TREE); \
> +	fi

This does not allow us to create a tarball of the git clone, and that's
a helpful thing to reduce constants clones (which typically take time
for such a large project as Linux).

Can you look into using the git download method (Download/git-kernel)?

Patch

diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index 10bd67a..6969c9f 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -62,13 +62,26 @@  ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"")
     endef
   endif
 else
-  define Kernel/Prepare/Default
+  ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
+    define Kernel/Prepare/Default
 	mkdir -p $(KERNEL_BUILD_DIR)
 	if [ -d $(LINUX_DIR) ]; then \
 		rmdir $(LINUX_DIR); \
 	fi
 	ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
-  endef
+    endef
+  else
+    define Kernel/Prepare/Default
+	mkdir -p $(KERNEL_BUILD_DIR)
+	if [ -d $(LINUX_DIR) ]; then \
+		rmdir $(LINUX_DIR); \
+	fi
+	ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR)
+	if [ ! -d $(CONFIG_EXTERNAL_KERNEL_TREE) ]; then \
+		git clone $(KERNEL_GIT_OPTS) $(CONFIG_KERNEL_GIT_CLONE_URI) $(CONFIG_EXTERNAL_KERNEL_TREE); \
+	fi
+    endef
+  endif
 endif
 
 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)