Skip to contentSkip to conversation

Download sources from Git (and more)

Buildroot New Luca Ceresoli 5 participants 12 messages Jul 12, 2010 – Jul 14, 2010 Arm/Microchip (AT91) SoC support

lore
Share & tools
lore
#0 lore raw

Hi,

this patchset is a tentative generalization of the DOWNLOAD macro, as recently discussed in mailing-list, in order to allow BR to obtain package sources not only as tar files from http/ftp, but also using other protocols.

I borrowed some pieces of code from Quotient Remainder's patch, but this approach is substiatially different.

The feature list is short: I deliberately wanted to be minimalistic but set up a clean infrastructure that can be extended later.

Even though these patches are quite polished, please consider them as a proposal for discussion. If there is general consensus about the way I propose, I'll be glad to add a bit of user documentation as well.

In the first two patches I prepare the ground by making the download infrastructure more general. The DOWNLOAD function is replaced by a per-package $(PKG)_DOWNLOAD, whose value is computed automatically from the site URL but can be overridden. The good old wget system is modified to fit in the new framework.

In the third and fourth commit I add DOWNLOAD_GIT, which is relatively straightforward given the whole infrastructure is already in place. The place where the repository should be cloned might not be appreciated, but I definitely think it should go in output/, as it is part of buildroot's -well- output, not of the package "recipe".

The last patch is surely *not* meant to be committed. It's just a minimalistic example of a package downloaded via Git, and would be replaced by user docs as stated above.

Luca

#1 lore raw

PATCH 1/5 packages: pass the package name to the DOWNLOAD macro

This enables DOWNLOAD to have a more complex behaviour than it currently can.

---
 package/Makefile.package.in |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
package/Makefile.package.in +2 -1
index c476de9..8243ed5 100644
@@ -76,6 +76,7 @@ TERM_RESET := $(shell tput rmso)
 #
 # Argument 1 is the source location
 # Argument 2 is the source filename
+# Argument 3 is the uppercase package name
 #
 # E.G. use like this:
 # $(call DOWNLOAD,$(FOO_SITE),$(FOO_SOURCE))
@@ -124,7 +125,7 @@ ifeq ($(SPIDER),)
 		(test -z $($(PKG)_PATCH) || test -e $(DL_DIR)$($(PKG)_PATCH))) || \
 		$(call MESSAGE,"Downloading")
 endif
-	$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_SOURCE))
+	$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_SOURCE),$(PKG))
 	$(if $($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_PATCH)))
 ifeq ($(SPIDER),)
 	$(Q)mkdir -p $(@D)
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/5 packages: allow different download protocols, with auto detection

In reply to Luca Ceresoli

Map the DOWNLOAD macro to a different specialized macro based on the URL.

---
 package/Makefile.package.in |   46 +++++++++++++++++++++++++++++++-----------
 1 files changed, 34 insertions(+), 12 deletions(-)
package/Makefile.package.in +34 -12
index 8243ed5..a212a38 100644
@@ -69,30 +69,39 @@ TERM_BOLD := $(shell tput smso)
 TERM_RESET := $(shell tput rmso)
 
 ################################################################################
-# DOWNLOAD -- Download helper. Will try to download source from:
-# 1) BR2_PRIMARY_SITE if enabled
-# 2) Download site
-# 3) BR2_BACKUP_SITE if enabled
-#
+# Download helpers.
+# Different download protocols are supported, and each has a helper function
+# named DOWNLAOD_$(PROTOCOL_NAME) taking three arguments:
 # Argument 1 is the source location
 # Argument 2 is the source filename
 # Argument 3 is the uppercase package name
 #
 # E.G. use like this:
-# $(call DOWNLOAD,$(FOO_SITE),$(FOO_SOURCE))
+# $(call DOWNLOAD_WGET,$(FOO_SITE),$(FOO_SOURCE),FOO)
 ################################################################################
 
+# $(call DOWNLOAD_WGET,$(PKG_SITE),$(PKG_SOURCE),irrelevant)
+# Will try to download source from:
+# 1) BR2_PRIMARY_SITE if enabled
+# 2) Download site specified in $(PKG)_SITE
+# 3) BR2_BACKUP_SITE if enabled
+
 # support make source-check/external-deps
 ifneq ($(SPIDER),)
-DOWNLOAD=$(WGET) -P $(DL_DIR) $(1)/$(2)
+DOWNLOAD_WGET=$(WGET) -P $(DL_DIR) $(1)/$(2)
 else
-define DOWNLOAD
+define DOWNLOAD_WGET
 	$(Q)test -e $(DL_DIR)/$(2) || \
 	for site in $(call qstrip,$(BR2_PRIMARY_SITE)) $(1) $(call qstrip,$(BR2_BACKUP_SITE)); \
 	do $(WGET) -P $(DL_DIR) $$site/$(2) && exit; done
-endef
+endef # DOWNLOAD_WGET
 endif
 
+# Use wget for ftp://, http:// and https://.
+DOWNLOAD_FTP=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
+DOWNLOAD_HTTP=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
+DOWNLOAD_HTTPS=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
+
 # Utility programs used to build packages
 TAR ?= tar
 
@@ -123,10 +132,10 @@ ifeq ($(SPIDER),)
 # Only show the download message if it isn't already downloaded
 	$(Q)(test -e $(DL_DIR)/$($(PKG)_SOURCE) && \
 		(test -z $($(PKG)_PATCH) || test -e $(DL_DIR)$($(PKG)_PATCH))) || \
-		$(call MESSAGE,"Downloading")
+		$(call MESSAGE,"Downloading via $($(PKG)_DOWNLOAD_PROTOCOL)")
 endif
-	$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_SOURCE),$(PKG))
-	$(if $($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE),$($(PKG)_PATCH)))
+	$(call $($(PKG)_DOWNLOAD),$($(PKG)_SITE),$($(PKG)_SOURCE),$(PKG))
+	$(if $($(PKG)_PATCH),$(call $($(PKG)_DOWNLOAD),$($(PKG)_SITE),$($(PKG)_PATCH)))
 ifeq ($(SPIDER),)
 	$(Q)mkdir -p $(@D)
 	$(Q)touch $@
@@ -280,6 +289,19 @@ ifndef $(2)_SITE
  endif
 endif
 
+ifndef $(2)_DOWNLOAD_PROTOCOL
+ ifdef $(3)_DOWNLOAD_PROTOCOL
+  # use user-provided protocol
+  $(2)_DOWNLOAD_PROTOCOL := $($(3)_DOWNLOAD_PROTOCOL)
+ else
+  # Try automatic detection: use the protocol part of the URL to decide
+  # which download utility to use.
+  $(2)_DOWNLOAD_PROTOCOL	:= \
+   $(call UPPERCASE,$(firstword $(subst ://, ,$(call qstrip,$($(2)_SITE)))))
+ endif
+endif
+
+$(2)_DOWNLOAD			?= DOWNLOAD_$$($(2)_DOWNLOAD_PROTOCOL)
 $(2)_DEPENDENCIES		?=
 $(2)_INSTALL_STAGING		?= NO
 $(2)_INSTALL_TARGET		?= YES
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 2/5 packages: allow different download protocols, with auto detection

package/Makefile.package.in TERM_BOLD := $(shell tput smso) · line 73

Quoted 8 lines · Luca Ceresoli

?################################################################################

package/Makefile.package.in +2 -5
-# DOWNLOAD -- Download helper. Will try to download source from:
-# 1) BR2_PRIMARY_SITE if enabled
-# 2) Download site
-# 3) BR2_BACKUP_SITE if enabled
-#
+# Download helpers.
+# Different download protocols are supported, and each has a helper function

True name is: "Scheme" not "Protocol" if you mean everything prior to the first ":"

Quoted 1 line

+# named DOWNLAOD_$(PROTOCOL_NAME) taking three arguments:

DOWNLAOD ??

Quoted 4 lines

?# Argument 1 is the source location
?# Argument 2 is the source filename
?# Argument 3 is the uppercase package name

#4 lore raw

PATCH 3/5 Unleash all of git's power: not only clones

In reply to Luca Ceresoli
---
 Config.in                                 |    4 ++--
 configs/arm_toolchain_defconfig           |    2 +-
 configs/at91rm9200df_defconfig            |    2 +-
 configs/at91rm9200df_ext_bare_defconfig   |    2 +-
 configs/at91rm9200df_ext_defconfig        |    2 +-
 configs/at91sam9260dfc_defconfig          |    2 +-
 configs/at91sam9260dfc_ext_bare_defconfig |    2 +-
 configs/at91sam9260dfc_ext_defconfig      |    2 +-
 configs/at91sam9261ek_defconfig           |    2 +-
 configs/at91sam9261ek_ext_bare_defconfig  |    2 +-
 configs/at91sam9261ek_ext_defconfig       |    2 +-
 configs/at91sam9263ek_defconfig           |    2 +-
 configs/at91sam9263ek_ext_bare_defconfig  |    2 +-
 configs/at91sam9263ek_ext_defconfig       |    2 +-
 configs/at91sam9g20dfc_defconfig          |    2 +-
 configs/at91sam9g20dfc_ext_bare_defconfig |    2 +-
 configs/at91sam9g20dfc_ext_defconfig      |    2 +-
 configs/atngw100-base_defconfig           |    2 +-
 configs/atngw100_defconfig                |    2 +-
 configs/atstk1005_defconfig               |    2 +-
 configs/atstk100x_defconfig               |    2 +-
 configs/i386_defconfig                    |    2 +-
 configs/i686_defconfig                    |    2 +-
 configs/integrator926_defconfig           |    2 +-
 configs/integrator926_huge_defconfig      |    2 +-
 configs/kb9202_defconfig                  |    2 +-
 configs/v100sc2_defconfig                 |    2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
Config.in +2 -2
index 6adfe49..8b22c23 100644
@@ -38,8 +38,8 @@ config BR2_BZR_UP
 	default "bzr up"
 
 config BR2_GIT
-	string "Git command to download source tree"
-	default "git clone"
+	string "Git command"
+	default "git"
 
 config BR2_ZCAT
 	string "zcat command"
configs/arm_toolchain_defconfig +1 -1
index 4c1e2c2..602e271 100644
@@ -133,7 +133,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91rm9200df_defconfig +1 -1
index 0d453b6..4fd633b 100644
@@ -138,7 +138,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91rm9200df_ext_bare_defconfig +1 -1
index 1622cc7..a333acf 100644
@@ -133,7 +133,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91rm9200df_ext_defconfig +1 -1
index 7245b8a..3667205 100644
@@ -144,7 +144,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9260dfc_defconfig +1 -1
index 3de2aea..fbb72b4 100644
@@ -151,7 +151,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9260dfc_ext_bare_defconfig +1 -1
index f1939cc..cd4020b 100644
@@ -133,7 +133,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9260dfc_ext_defconfig +1 -1
index e66a541..d1c4e57 100644
@@ -152,7 +152,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9261ek_defconfig +1 -1
index b8b5d60..a17ec0b 100644
@@ -154,7 +154,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9261ek_ext_bare_defconfig +1 -1
index e116f44..30b4c69 100644
@@ -136,7 +136,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9261ek_ext_defconfig +1 -1
index 7e0e84f..7e80c0f 100644
@@ -155,7 +155,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9263ek_defconfig +1 -1
index de2a12d..05f0366 100644
@@ -152,7 +152,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9263ek_ext_bare_defconfig +1 -1
index 4efc758..4b1c716 100644
@@ -135,7 +135,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9263ek_ext_defconfig +1 -1
index d757aaa..e3cecf4 100644
@@ -154,7 +154,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9g20dfc_defconfig +1 -1
index ffe4636..3108550 100644
@@ -152,7 +152,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9g20dfc_ext_bare_defconfig +1 -1
index 22676b7..ac6273e 100644
@@ -133,7 +133,7 @@ BR2_AT91_LINUXPATCH_SITE="http://maxim.org.za/AT91RM9200/2.6"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/at91sam9g20dfc_ext_defconfig +1 -1
index 2cf2839..a9c6d92 100644
@@ -152,7 +152,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-arm/kernel-patches-$(BR2_KER
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/atngw100-base_defconfig +1 -1
index 8c3d80b..c90dbee 100644
@@ -86,7 +86,7 @@ BR2_TARGET_AVR32_ATNGW100_BASE=y
 BR2_WGET="wget --passive-ftp --retry-connrefused --waitretry=10"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="zcat"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/atngw100_defconfig +1 -1
index 763cad7..9f39fe8 100644
@@ -73,7 +73,7 @@ BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
 BR2_BZR_CO="bzr co"
 BR2_BZR_UP="bzr up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="zcat"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/atstk1005_defconfig +1 -1
index ab8b369..8188a77 100644
@@ -84,7 +84,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-avr32/kernel-patches-$(BR2_K
 BR2_WGET="wget --passive-ftp --retry-connrefused --waitretry=10"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="zcat"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/atstk100x_defconfig +1 -1
index 0a718de..96e6e9d 100644
@@ -85,7 +85,7 @@ BR2_KERNEL_ARCH_PATCH_DIR="target/device/Atmel/arch-avr32/kernel-patches-$(BR2_K
 BR2_WGET="wget --passive-ftp --retry-connrefused --waitretry=10"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="zcat"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/i386_defconfig +1 -1
index 69e6412..74606ac 100644
@@ -87,7 +87,7 @@ BR2_TARGET_I686=y
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/i686_defconfig +1 -1
index e4d4f98..4a4f2b3 100644
@@ -87,7 +87,7 @@ BR2_TARGET_I686=y
 BR2_WGET="wget --passive-ftp"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/integrator926_defconfig +1 -1
index 815d259..cb5a4e4 100644
@@ -83,7 +83,7 @@ BR2_BOARD_PATH="target/device/ARMLTD/$(BR2_BOARD_NAME)"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/integrator926_huge_defconfig +1 -1
index 9b68258..c58a7cb 100644
@@ -83,7 +83,7 @@ BR2_BOARD_PATH="target/device/ARMLTD/$(BR2_BOARD_NAME)"
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/kb9202_defconfig +1 -1
index 9300f28..1c22876 100644
@@ -94,7 +94,7 @@ BR2_PRIMARY_SITE=""
 BR2_WGET="wget --passive-ftp -nd"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="gzip -d -c"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
configs/v100sc2_defconfig +1 -1
index c85a4d8..65ddcf6 100644
@@ -65,7 +65,7 @@ BR2_PRIMARY_SITE=""
 BR2_WGET="wget --passive-ftp --retry-connrefused --waitretry=10"
 BR2_SVN_CO="svn co"
 BR2_SVN_UP="svn up"
-BR2_GIT="git clone"
+BR2_GIT="git"
 BR2_ZCAT="zcat"
 BR2_BZCAT="bzcat"
 BR2_TAR_OPTIONS=""
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 4/5 packages: add DOWNLOAD_GIT

In reply to Luca Ceresoli

Allows to download packages directly from git repositories.

The repository is cloned in output/build/$(PKG)_NAME.git/ the first time, and fetched whenever a download action is required (e.g. because $(PKG)_VERSION changed in the package .mk file.

Sources are extracted directly from the local clone to output/build/$(PKG)_NAME-$(PKG)_VERSION/, skipping the usual extract step.

---
 package/Makefile.package.in |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
package/Makefile.package.in +18 -0
index a212a38..0cb3ccc 100644
@@ -102,6 +102,24 @@ DOWNLOAD_FTP=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
 DOWNLOAD_HTTP=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
 DOWNLOAD_HTTPS=$(call DOWNLOAD_WGET,$(1),$(2),$(3))
 
+# $(call DOWNLOAD_GIT,irrelevant,irrelevant,$(PKG_NAME))
+# Download sources from a Git repository.
+# - Step 1: clone the first time, fetch thereafter, according to the logic:
+#           ( [ local clone exists ] && fetch ) || clone
+# - Step 2: Go to the cloned repo and extract specific version straight
+#           to the build dir
+# - Finally: touch .stamp_extracted in order to skip that step (kind of hack)
+define DOWNLOAD_GIT
+	( [ -d $(BUILD_DIR)/$($(3)_NAME).git/.git ] \
+	    && ( cd $(BUILD_DIR)/$($(3)_NAME).git/.git && $(GIT) fetch) \
+	    || $(GIT) clone --no-checkout $($(3)_SITE) $(BUILD_DIR)/$($(3)_NAME).git )
+	mkdir -p $($(3)_DIR)
+	cd $(BUILD_DIR)/$($(3)_NAME).git && \
+	  git archive --format=tar --prefix=$($(3)_NAME)-$($(3)_VERSION)/ $($(3)_VERSION) | \
+	    $(TAR) -x -C $(BUILD_DIR)
+	touch $($(3)_DIR)/.stamp_extracted
+endef # DOWNLOAD_GIT
+
 # Utility programs used to build packages
 TAR ?= tar
 
Signature · 1 line
1.7.0.4
#6 lore raw

PATCH 5/5 FOR TESTING ONLY: Add a GIT-downloaded test package

In reply to Luca Ceresoli
---
 package/Config.in          |    2 ++
 package/testpkg/Config.in  |    2 ++
 package/testpkg/testpkg.mk |    7 +++++++
 3 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 package/testpkg/Config.in
 create mode 100644 package/testpkg/testpkg.mk
package/Config.in +2 -0
index eba21da..8b7eda2 100644
@@ -486,4 +486,6 @@ source "package/vim/Config.in"
 endif
 endmenu
 
+source "package/testpkg/Config.in"
+
 endmenu
package/testpkg/Config.in new file +2 -0
new file mode 100644
index 0000000..0802012
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_TESTPKG
+	bool "testpkg"
package/testpkg/testpkg.mk new file +7 -0
new file mode 100644
index 0000000..cc1e0f3
@@ -0,0 +1,7 @@
+# This is a fake package: it only downloads sources.
+
+TESTPKG_SITE=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/tracker.git
+TESTPKG_VERSION=7f220f1ea
+# TESTPKG_VERSION can also be a tag name.
+
+$(eval $(call GENTARGETS,package,testpkg))
Signature · 1 line
1.7.0.4
#7 lore raw
In reply to Luca Ceresoli

Ar Luan, 2010-07-12 ag 23:30 +0200, scr?obh Luca Ceresoli:

Quoted 29 lines

Hi,

this patchset is a tentative generalization of the DOWNLOAD macro, as recently discussed in mailing-list, in order to allow BR to obtain package sources not only as tar files from http/ftp, but also using other protocols.

I borrowed some pieces of code from Quotient Remainder's patch, but this approach is substiatially different.

The feature list is short: I deliberately wanted to be minimalistic but set up a clean infrastructure that can be extended later.

Even though these patches are quite polished, please consider them as a proposal for discussion. If there is general consensus about the way I propose, I'll be glad to add a bit of user documentation as well.

In the first two patches I prepare the ground by making the download infrastructure more general. The DOWNLOAD function is replaced by a per-package $(PKG)_DOWNLOAD, whose value is computed automatically from the site URL but can be overridden. The good old wget system is modified to fit in the new framework.

In the third and fourth commit I add DOWNLOAD_GIT, which is relatively straightforward given the whole infrastructure is already in place. The place where the repository should be cloned might not be appreciated, but I definitely think it should go in output/, as it is part of buildroot's -well- output, not of the package "recipe".

Quoted 5 lines

The last patch is surely *not* meant to be committed. It's just a minimalistic example of a package downloaded via Git, and would be replaced by user docs as stated above.

Luca

I personally quite like the approach here and think it's more flexible than the patch set from Maxime, but have two questions.

- Why not make the usual tarball in $(DL_DIR) with "git archive
--format=tar ... | gzip > $(DL_DIR)/..." instead of the self-described "hack" of skipping the extraction step? I suppose it's slightly faster since you avoid the compression and decompression time but that mightn't be too significant. I just wonder if the skipping of this stage may have some side effects especially if packages have custom extraction steps.

- Do you see any way of making it possible to use the clone as the
actual working copy used by buildroot? That is, if I clone a repository (as opposed to archive) and then want to make changes, I can edit the source and build/test the change in-place (in output/build/package/) . As it stands with this patch set, I think it would be necessary to make a change in the source in $(PKG_NAME).git/, commit the change, note the new version, change the package version in package/Makefile to the same and make will then copy an entire snapshot to a new build-dir/pkg-newversion/.

#8 lore raw

Hello,

Quoted 9 lines · On Tue, 13 Jul 2010 15:43:39 +0100 Quotient Remainder…

- Do you see any way of making it possible to use the clone as the
actual working copy used by buildroot? That is, if I clone a repository (as opposed to archive) and then want to make changes, I can edit the source and build/test the change in-place (in output/build/package/) . As it stands with this patch set, I think it would be necessary to make a change in the source in $(PKG_NAME).git/, commit the change, note the new version, change the package version in package/Makefile to the same and make will then copy an entire snapshot to a new build-dir/pkg-newversion/.

I understand this need: use Buildroot not only as an integration system to produce the final system, but also during the development of the application. For the moment, our recommended practice for this is to work on the application outside of Buildroot, as Buildroot is not well-suited for doing this.

Adding such a capability to Buildroot requires a fairly wide brainstorming and discussion to propose a global design that solves this question. What do we want to achieve ? What is the exact use case ? How all development steps are going to work ?

For that reason, I think Maxime's patch is saner: it adds the simple capability of downloading a package from GIT/SVN, without changing the existing Buildroot workflow.

I'm really open to changing the Buildroot workflow, but:

1. I think it requires a much more detailed discussion about *what* we need and then *how* we implement it.

2. I'd prefer to do such major changes once the Buildroot cleanup phase (started in January 2009) is more or less completed, so that we start with a Buildroot from which we are satisfied in terms of quality before starting adding major features such as turning Buildroot into a development system and not only an integration system. I think it's more important to make Buildroot work properly with the feature-set we have today than having dozens of half-thought features.

As such a change wouldn't probably occur before 2010.08, I'd prefer to have a solution similar to Maxime's merged into the tree for the moment, and having someone seriously starting the discussion on the Buildroot future as a development system.

Best regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#9 lore raw
Quoted 23 lines · Thomas Petazzoni

Hello,

Quoted 10 lines · On Tue, 13 Jul 2010 15:43:39 +0100 Quotient Remainder…

- Do you see any way of making it possible to use the clone as the
actual working copy used by buildroot? That is, if I clone a repository (as opposed to archive) and then want to make changes, I can edit the source and build/test the change in-place (in output/build/package/) . As it stands with this patch set, I think it would be necessary to make a change in the source in $(PKG_NAME).git/, commit the change, note the new version, change the package version in package/Makefile to the same and make will then copy an entire snapshot to a new build-dir/pkg-newversion/.

I understand this need: use Buildroot not only as an integration system to produce the final system, but also during the development of the application. For the moment, our recommended practice for this is to work on the application outside of Buildroot, as Buildroot is not well-suited for doing this.

Quoted 5 lines

Adding such a capability to Buildroot requires a fairly wide brainstorming and discussion to propose a global design that solves this question. What do we want to achieve ? What is the exact use case ? How all development steps are going to work ?

I understand your point, and I think the threads seen so far are a good starting point for this discussion.

Quoted 4 lines

For that reason, I think Maxime's patch is saner: it adds the simple capability of downloading a package from GIT/SVN, without changing the existing Buildroot workflow.

After reviewing once again the two patches, I've come to the conclusion that they are quite similar apart from a matter of code style. Practically I don't think they have big pros/cons over each other.

Creating a tarball would be trivial to add to my patches.

Enabling git pull in Maxime's code would probably be easy if the clone were put in a suitable directory.

Supporting more complex workflows (such as working copies within the buildroot tree, or integrating git submodules) would require a deeper analysis and substantial work in both cases.

The choice of which download helper to use is more readable in Maxime's code (case-based) but I suspect is more efficient in my macro-based system which is also more uniform with the rest of Makefile.package.in.

That said, I think both approaches are sane enough (after the few discussed improvements) to be applied. I'd like to hear the maintainer's opinion about this choice. The only one that I wouldn't agree with is to reject both.

Luca

#10 lore raw
In reply to Thomas Petazzoni
Quoted 6 lines · Thomas Petazzoni

I understand this need: use Buildroot not only as an integration system to produce the final system, but also during the development of the application. For the moment, our recommended practice for this is to work on the application outside of Buildroot, as Buildroot is not well-suited for doing this.

Quoted 8 lines

Adding such a capability to Buildroot requires a fairly wide brainstorming and discussion to propose a global design that solves this question. What do we want to achieve ? What is the exact use case ? How all development steps are going to work ?

For that reason, I think Maxime's patch is saner: it adds the simple capability of downloading a package from GIT/SVN, without changing the existing Buildroot workflow.

A combination of the best of the two may be the way to go.

Quoted 14 lines

I'm really open to changing the Buildroot workflow, but:

1. I think it requires a much more detailed discussion about *what* we need and then *how* we implement it.

2. I'd prefer to do such major changes once the Buildroot cleanup phase (started in January 2009) is more or less completed, so that we start with a Buildroot from which we are satisfied in terms of quality before starting adding major features such as turning Buildroot into a development system and not only an integration system. I think it's more important to make Buildroot work properly with the feature-set we have today than having dozens of half-thought features.

Quoted 5 lines

As such a change wouldn't probably occur before 2010.08, I'd prefer to have a solution similar to Maxime's merged into the tree for the moment, and having someone seriously starting the discussion on the Buildroot future as a development system.

Understood; that's perfectly reasonable. The amount of work going into this project these days in phenomenal. It is already a great tool but the cleanup should make it all the more accessible.

I don't mind doing some throwaway work in the meantime in order to spark some discussion on the points you raised above.

Quoted 3 lines

Best regards,

Thomas

BTW, I hope I'm not stepping on toes by commenting here on this topic. I'm eager to get something working but I realise there are many here that have much greater oversight on what's needed.

#11 lore raw
In reply to Quotient Remainder
Quoted 41 lines · Quotient Remainder

Ar Luan, 2010-07-12 ag 23:30 +0200, scr?obh Luca Ceresoli:

Quoted 29 lines

Hi,

this patchset is a tentative generalization of the DOWNLOAD macro, as recently discussed in mailing-list, in order to allow BR to obtain package sources not only as tar files from http/ftp, but also using other protocols.

I borrowed some pieces of code from Quotient Remainder's patch, but this approach is substiatially different.

The feature list is short: I deliberately wanted to be minimalistic but set up a clean infrastructure that can be extended later.

Even though these patches are quite polished, please consider them as a proposal for discussion. If there is general consensus about the way I propose, I'll be glad to add a bit of user documentation as well.

In the first two patches I prepare the ground by making the download infrastructure more general. The DOWNLOAD function is replaced by a per-package $(PKG)_DOWNLOAD, whose value is computed automatically from the site URL but can be overridden. The good old wget system is modified to fit in the new framework.

In the third and fourth commit I add DOWNLOAD_GIT, which is relatively straightforward given the whole infrastructure is already in place. The place where the repository should be cloned might not be appreciated, but I definitely think it should go in output/, as it is part of buildroot's -well- output, not of the package "recipe".

Quoted 6 lines

The last patch is surely *not* meant to be committed. It's just a minimalistic example of a package downloaded via Git, and would be replaced by user docs as stated above.

Luca

I personally quite like the approach here and think it's more flexible than the patch set from Maxime, but have two questions.

Quoted 8 lines

- Why not make the usual tarball in $(DL_DIR) with "git archive
--format=tar ... | gzip > $(DL_DIR)/..." instead of the self-described "hack" of skipping the extraction step? I suppose it's slightly faster since you avoid the compression and decompression time but that mightn't be too significant. I just wonder if the skipping of this stage may have some side effects especially if packages have custom extraction steps.

That would be very simple, and probably cleaner as you noted. I think it's worth doing after all, since it would save download time for example after make clean.
I'll code it as time permits.

Quoted 10 lines

- Do you see any way of making it possible to use the clone as the
actual working copy used by buildroot? That is, if I clone a repository (as opposed to archive) and then want to make changes, I can edit the source and build/test the change in-place (in output/build/package/) . As it stands with this patch set, I think it would be necessary to make a change in the source in $(PKG_NAME).git/, commit the change, note the new version, change the package version in package/Makefile to the same and make will then copy an entire snapshot to a new build-dir/pkg-newversion/.

This would certainly be useful, but hard to couple with the current buildroot structure, as Thomas pointed out in this thread. A discussion would be needed before such a thing.

Luca

Quoted 5 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot