All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR
@ 2018-04-02 14:57 Maxime Hadjinlian
  2018-04-02 14:57 ` [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR Maxime Hadjinlian
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:57 UTC (permalink / raw)
  To: buildroot

With all the previous changes, we are now ready to add a subdirectory to
the DL_DIR.
The structure will now be DL_DIR/PKG_NAME/{FILE1,FILE2}

This is needed for multiple reasons:
    - Avoid patches with name like SHA1.patch laying flat in DL_DIR,
    which makes it hard to know to which packages they apply
    - Avoid possible collisions if two releases have the same name
    (e.g: v01.tar)
    - Allow the possibility to handle a git cache per package in the
    newly created subdirectory.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/pkg-generic.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 01d61ac0ad..20ee73d438 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -432,7 +432,7 @@ endif
 
 $(2)_BASENAME	= $$(if $$($(2)_VERSION),$(1)-$$($(2)_VERSION),$(1))
 $(2)_BASENAME_RAW = $$(if $$($(2)_VERSION),$$($(2)_RAWNAME)-$$($(2)_VERSION),$$($(2)_RAWNAME))
-$(2)_DL_DIR	=  $$(DL_DIR)
+$(2)_DL_DIR 	=  $$(DL_DIR)/$$($(2)_RAWNAME)
 $(2)_DIR	=  $$(BUILD_DIR)/$$($(2)_BASENAME)
 
 ifndef $(2)_SUBDIR
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
@ 2018-04-02 14:57 ` Maxime Hadjinlian
  2018-04-02 15:45   ` Peter Korsgaard
  2018-04-02 14:57 ` [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors Maxime Hadjinlian
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:57 UTC (permalink / raw)
  To: buildroot

This per package variable can be used to specify the download
subdirectory used by that package.

The use case here is for example linux-headers and linux, which share
the same sources (because they are the same upstream project), so we
don't want to download twice the kernel, nor store it multiple times
either.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
v4 -> v5:
    - Change SAME_SOURCE_AS into DL_SUBDIR (Thomas Petazzonni)
---
 package/pkg-generic.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 20ee73d438..3c6a1839ff 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -432,7 +432,8 @@ endif
 
 $(2)_BASENAME	= $$(if $$($(2)_VERSION),$(1)-$$($(2)_VERSION),$(1))
 $(2)_BASENAME_RAW = $$(if $$($(2)_VERSION),$$($(2)_RAWNAME)-$$($(2)_VERSION),$$($(2)_RAWNAME))
-$(2)_DL_DIR 	=  $$(DL_DIR)/$$($(2)_RAWNAME)
+$(2)_DL_SUBDIR ?= $$($(2)_RAWNAME)
+$(2)_DL_DIR = $$(DL_DIR)/$$($(2)_DL_SUBDIR)
 $(2)_DIR	=  $$(BUILD_DIR)/$$($(2)_BASENAME)
 
 ifndef $(2)_SUBDIR
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
  2018-04-02 14:57 ` [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR Maxime Hadjinlian
@ 2018-04-02 14:57 ` Maxime Hadjinlian
  2018-04-02 15:45   ` Peter Korsgaard
  2018-04-02 14:57 ` [Buildroot] [PATCH 4/8] package: share downloaded files for big packages Maxime Hadjinlian
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:57 UTC (permalink / raw)
  To: buildroot

Since we introduced subdirectory to the DL_DIR, we need to support them
in the PRIMARY and BACKUP mirror as they evolve to the new tree
structure.

We check first the new URI (with the subdir), and in case of failure, we
go check without.
By checking both URIs, we ensure that old mirror are usable.

Also, add a missing qstrip call for BR2_BACKUP_SITE.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
v4 -> v5:
   - Use new DL_SUBDIR
   - Add missing qstrip
---
 package/pkg-download.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 3f35661a16..7ca6fcc757 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -75,6 +75,7 @@ export BR_NO_CHECK_HASH_FOR =
 
 ifneq ($(call qstrip,$(BR2_PRIMARY_SITE)),)
 DOWNLOAD_URIS += \
+	-u $(call getschemeplusuri,$(call qstrip,$(BR2_PRIMARY_SITE)/$($(PKG)_DL_SUBDIR)),urlencode) \
 	-u $(call getschemeplusuri,$(call qstrip,$(BR2_PRIMARY_SITE)),urlencode)
 endif
 
@@ -83,7 +84,8 @@ DOWNLOAD_URIS += \
 	-u $($(PKG)_SITE_METHOD)+$(dir $(call qstrip,$(1)))
 ifneq ($(call qstrip,$(BR2_BACKUP_SITE)),)
 DOWNLOAD_URIS += \
-	-u $(call getschemeplusuri,$(BR2_BACKUP_SITE),urlencode)
+	-u $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)/$($(PKG)_DL_SUBDIR)),urlencode) \
+	-u $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)),urlencode)
 endif
 endif
 
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 4/8] package: share downloaded files for big packages
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
  2018-04-02 14:57 ` [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR Maxime Hadjinlian
  2018-04-02 14:57 ` [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors Maxime Hadjinlian
@ 2018-04-02 14:57 ` Maxime Hadjinlian
  2018-04-02 15:45   ` Peter Korsgaard
  2018-04-02 14:57 ` [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR) Maxime Hadjinlian
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:57 UTC (permalink / raw)
  To: buildroot

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Theses packages are given as an example of the use of the *_DL_SUBDIR feature.
There maybe other packages that would benefit from that feature, they
would need to be added on a case by case basis.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
v4 -> v5:
    - Change SAME_SOURCE_AS into DL_SUBDIR
---
 package/gcc/gcc-final/gcc-final.mk       | 2 ++
 package/gcc/gcc-initial/gcc-initial.mk   | 5 +++++
 package/linux-headers/linux-headers.mk   | 3 +++
 package/mesa3d-headers/mesa3d-headers.mk | 1 +
 4 files changed, 11 insertions(+)

diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
index 213f3d7b66..b7b27aec13 100644
--- a/package/gcc/gcc-final/gcc-final.mk
+++ b/package/gcc/gcc-final/gcc-final.mk
@@ -8,6 +8,8 @@ GCC_FINAL_VERSION = $(GCC_VERSION)
 GCC_FINAL_SITE = $(GCC_SITE)
 GCC_FINAL_SOURCE = $(GCC_SOURCE)
 
+HOST_GCC_FINAL_DL_SUBDIR = gcc
+
 HOST_GCC_FINAL_DEPENDENCIES = \
 	$(HOST_GCC_COMMON_DEPENDENCIES) \
 	$(BR_LIBC)
diff --git a/package/gcc/gcc-initial/gcc-initial.mk b/package/gcc/gcc-initial/gcc-initial.mk
index c476b2faeb..9b20eb18f9 100644
--- a/package/gcc/gcc-initial/gcc-initial.mk
+++ b/package/gcc/gcc-initial/gcc-initial.mk
@@ -8,6 +8,11 @@ GCC_INITIAL_VERSION = $(GCC_VERSION)
 GCC_INITIAL_SITE = $(GCC_SITE)
 GCC_INITIAL_SOURCE = $(GCC_SOURCE)
 
+# We do not have a 'gcc' package per-se; we only have two incarnations,
+# gcc-initial and gcc-final. gcc-initial is just am internal step that
+# users should not care about, while gcc-final is the one they shall see.
+HOST_GCC_INITIAL_DL_SUBDIR = gcc
+
 HOST_GCC_INITIAL_DEPENDENCIES = $(HOST_GCC_COMMON_DEPENDENCIES)
 
 HOST_GCC_INITIAL_EXCLUDES = $(HOST_GCC_EXCLUDES)
diff --git a/package/linux-headers/linux-headers.mk b/package/linux-headers/linux-headers.mk
index f1e3790608..954c6b7978 100644
--- a/package/linux-headers/linux-headers.mk
+++ b/package/linux-headers/linux-headers.mk
@@ -82,6 +82,9 @@ endif
 
 endif # ! BR2_KERNEL_HEADERS_AS_KERNEL
 
+# linux-headers really is the same as the linux package
+LINUX_HEADERS_DL_SUBDIR = linux
+
 LINUX_HEADERS_LICENSE = GPL-2.0
 LINUX_HEADERS_LICENSE_FILES = COPYING
 
diff --git a/package/mesa3d-headers/mesa3d-headers.mk b/package/mesa3d-headers/mesa3d-headers.mk
index b48d965d8a..19d1c6fdf1 100644
--- a/package/mesa3d-headers/mesa3d-headers.mk
+++ b/package/mesa3d-headers/mesa3d-headers.mk
@@ -15,6 +15,7 @@ endif
 MESA3D_HEADERS_VERSION = 18.0.0
 MESA3D_HEADERS_SOURCE = mesa-$(MESA3D_HEADERS_VERSION).tar.xz
 MESA3D_HEADERS_SITE = https://mesa.freedesktop.org/archive
+MESA3D_HEADERS_DL_SUBDIR = mesa3d
 MESA3D_HEADERS_LICENSE = MIT, SGI, Khronos
 MESA3D_HEADERS_LICENSE_FILES = docs/license.html
 
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR)
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
                   ` (2 preceding siblings ...)
  2018-04-02 14:57 ` [Buildroot] [PATCH 4/8] package: share downloaded files for big packages Maxime Hadjinlian
@ 2018-04-02 14:57 ` Maxime Hadjinlian
  2018-04-02 15:46   ` Peter Korsgaard
  2018-04-02 14:58 ` [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper Maxime Hadjinlian
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:57 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 Config.in                               | 3 +++
 docs/manual/adding-packages-generic.txt | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Config.in b/Config.in
index 71b9f60e5b..c2a1925088 100644
--- a/Config.in
+++ b/Config.in
@@ -200,6 +200,9 @@ config BR2_DL_DIR
 	  If the Linux shell environment has defined the BR2_DL_DIR
 	  environment variable, then this overrides this configuration
 	  item.
+	  The directory is organized with a subdirectory for each package.
+	  Each package has its own $(LIBFOO_DL_DIR) variable that can be used
+	  to find the correct path.
 
 	  The default is $(TOPDIR)/dl
 
diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt
index 9d1428ad40..62906d92bb 100644
--- a/docs/manual/adding-packages-generic.txt
+++ b/docs/manual/adding-packages-generic.txt
@@ -263,7 +263,7 @@ information is (assuming the package name is +libfoo+) :
   the file using this URL. Otherwise, Buildroot will assume the file
   to be downloaded is located at +LIBFOO_SITE+. Buildroot will not do
   anything with those additional files, except download them: it will
-  be up to the package recipe to use them from +$(DL_DIR)+.
+  be up to the package recipe to use them from +$(LIBFOO_DL_DIR)+.
 
 * +LIBFOO_SITE_METHOD+ determines the method used to fetch or copy the
   package source code. In many cases, Buildroot guesses the method
@@ -554,8 +554,8 @@ In the action definitions, you can use the following variables:
 * +$(@D)+, which contains the directory in which the package source
   code has been uncompressed.
 
-* +$(DL_DIR)+ contains the path to the directory where all the downloads made
-  by Buildroot are stored.
+* +$(LIBFOO_DL_DIR)+ contains the path to the directory where all the downloads
+  made by Buildroot for +libfoo+ are stored in.
 
 * +$(TARGET_CC)+, +$(TARGET_LD)+, etc. to get the target
   cross-compilation utilities
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
                   ` (3 preceding siblings ...)
  2018-04-02 14:57 ` [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR) Maxime Hadjinlian
@ 2018-04-02 14:58 ` Maxime Hadjinlian
  2018-04-02 15:46   ` Peter Korsgaard
  2018-04-02 14:58 ` [Buildroot] [PATCH 7/8] download: add missing '-d' option Maxime Hadjinlian
  2018-04-02 14:58 ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Maxime Hadjinlian
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:58 UTC (permalink / raw)
  To: buildroot

In order to introduce the cache mechanisms, we need to have a lock on
the $(LIBFOO_DL_DIR), otherwise it would be impossible to do parallel
download (a shared DL_DIR for two buildroot instances).

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/pkg-download.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 7ca6fcc757..4fdb283acc 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -19,6 +19,7 @@ SSH := $(call qstrip,$(BR2_SSH))
 export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
 
 DL_WRAPPER = support/download/dl-wrapper
+FLOCK = flock $($(PKG)_DL_DIR)/
 
 # DL_DIR may have been set already from the environment
 ifeq ($(origin DL_DIR),undefined)
@@ -93,7 +94,7 @@ define DOWNLOAD
 	$(Q)mkdir -p $($(PKG)_DL_DIR)
 	$(Q)$(if $(filter bzr cvs hg svn,$($(PKG)_SITE_METHOD)),
 		BR_NO_CHECK_HASH_FOR=$(notdir $(call qstrip,$(1)))) \
-	$(EXTRA_ENV) $(DL_WRAPPER) \
+	$(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
 		-c '$($(PKG)_DL_VERSION)' \
 		-f '$(notdir $(1))' \
 		-H '$(PKGDIR)/$($(PKG)_RAWNAME).hash' \
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 7/8] download: add missing '-d' option
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
                   ` (4 preceding siblings ...)
  2018-04-02 14:58 ` [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper Maxime Hadjinlian
@ 2018-04-02 14:58 ` Maxime Hadjinlian
  2018-04-02 15:47   ` Peter Korsgaard
  2018-04-02 14:58 ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Maxime Hadjinlian
  6 siblings, 1 reply; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:58 UTC (permalink / raw)
  To: buildroot

The infrastructure needs to give the 'dl_dir' to the dl-wrappe which in
its turn needs to give it to the helper.
It will only be used by the 'git' helper as of now.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
---
 package/pkg-download.mk     | 1 +
 support/download/dl-wrapper | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 4fdb283acc..b7f1d43920 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -96,6 +96,7 @@ define DOWNLOAD
 		BR_NO_CHECK_HASH_FOR=$(notdir $(call qstrip,$(1)))) \
 	$(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
 		-c '$($(PKG)_DL_VERSION)' \
+		-d '$($(PKG)_DL_DIR)' \
 		-f '$(notdir $(1))' \
 		-H '$(PKGDIR)/$($(PKG)_RAWNAME).hash' \
 		-n '$($(PKG)_BASENAME_RAW)' \
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index cd903f92d9..af2950ac3b 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -19,7 +19,7 @@
 # We want to catch any unexpected failure, and exit immediately.
 set -e
 
-export BR_BACKEND_DL_GETOPTS=":hc:o:n:N:H:ru:qf:e"
+export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:ru:qf:e"
 
 main() {
     local OPT OPTARG
@@ -27,10 +27,11 @@ main() {
     local -a uris
 
     # Parse our options; anything after '--' is for the backend
-    while getopts ":hc:o:n:N:H:rf:u:q" OPT; do
+    while getopts ":hc:d:o:n:N:H:rf:u:q" OPT; do
         case "${OPT}" in
         h)  help; exit 0;;
         c)  cset="${OPTARG}";;
+        d)  dl_dir="${OPTARG}";;
         o)  output="${OPTARG}";;
         n)  raw_base_name="${OPTARG}";;
         N)  base_name="${OPTARG}";;
@@ -109,6 +110,7 @@ main() {
         if ! "${OLDPWD}/support/download/${backend}" \
                 $([ -n "${urlencode}" ] && printf %s '-e') \
                 -c "${cset}" \
+                -d "${dl_dir}" \
                 -n "${raw_base_name}" \
                 -N "${raw_name}" \
                 -f "${filename}" \
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 8/8] download: git: introduce cache feature
  2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
                   ` (5 preceding siblings ...)
  2018-04-02 14:58 ` [Buildroot] [PATCH 7/8] download: add missing '-d' option Maxime Hadjinlian
@ 2018-04-02 14:58 ` Maxime Hadjinlian
  2018-04-02 15:13   ` [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first Yann E. MORIN
  2018-04-02 21:47   ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Peter Korsgaard
  6 siblings, 2 replies; 17+ messages in thread
From: Maxime Hadjinlian @ 2018-04-02 14:58 UTC (permalink / raw)
  To: buildroot

Now we keep the git clone that we download and generates our tarball
from there.
The main goal here is that if you change the version of a package (say
Linux), instead of cloning all over again, you will simply 'git fetch'
from the repo the missing objects, then generates the tarball again.

This should speed the 'source' part of the build significantly.

The drawback is that the DL_DIR will grow much larger; but time is more
important than disk space nowadays.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
---
v4 -> v5:
    - Fix comments's content
---
 support/download/git | 65 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/support/download/git b/support/download/git
index 58a2c6ad9d..58dbcd211c 100755
--- a/support/download/git
+++ b/support/download/git
@@ -25,6 +25,7 @@ while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     o)  output="${OPTARG}";;
     u)  uri="${OPTARG}";;
     c)  cset="${OPTARG}";;
+    d)  dl_dir="${OPTARG}";;
     n)  basename="${OPTARG}";;
     :)  printf "option '%s' expects a mandatory argument\n" "${OPTARG}"; exit 1;;
     \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
@@ -39,29 +40,41 @@ _git() {
     eval ${GIT} "${@}"
 }
 
-# Try a shallow clone, since it is faster than a full clone - but that only
-# works if the version is a ref (tag or branch). Before trying to do a shallow
-# clone we check if ${cset} is in the list provided by git ls-remote. If not
-# we fall back on a full clone.
+# We want to check if a cache of the git clone of this repo already exists.
+git_cache="${dl_dir}/git"
+
+# If the cache directory doesn't exists, init a new repo, which will be
+# fetch'ed later.
+if [ ! -d "${git_cache}" ]; then
+    _git init "'${git_cache}'"
+    _git -C "'${git_cache}'" remote add origin "'${uri}'"
+fi
+
+pushd "${git_cache}" >/dev/null
+
+_git remote set-url origin "'${uri}'"
+
+# Try to fetch with limited depth, since it is faster than a full clone - but
+# that only works if the version is a ref (tag or branch). Before trying to do
+# a shallow clone we check if ${cset} is in the list provided by git ls-remote.
+# If not we fallback to a full fetch.
 #
-# Messages for the type of clone used are provided to ease debugging in case of
-# problems
+# Messages for the type of clone used are provided to ease debugging in
+# case of problems
 git_done=0
-if [ -n "$(_git ls-remote "'${uri}'" "'${cset}'" 2>&1)" ]; then
-    printf "Doing shallow clone\n"
-    if _git clone ${verbose} "${@}" --depth 1 -b "'${cset}'" "'${uri}'" "'${basename}'"; then
+if [ -n "$(_git ls-remote origin "'${cset}'" 2>&1)" ]; then
+    printf "Doing a shallow fetch\n"
+    if _git fetch "${@}" --depth 1 origin "'${cset}'"; then
         git_done=1
     else
-        printf "Shallow clone failed, falling back to doing a full clone\n"
+        printf "Shallow fetch failed, falling back to fetching all refs\n"
     fi
 fi
 if [ ${git_done} -eq 0 ]; then
-    printf "Doing full clone\n"
-    _git clone ${verbose} "${@}" "'${uri}'" "'${basename}'"
+    printf "Fetching all references\n"
+    _git fetch origin -t
 fi
 
-pushd "${basename}" >/dev/null
-
 # Try to get the special refs exposed by some forges (pull-requests for
 # github, changes for gerrit...). There is no easy way to know whether
 # the cset the user passed us is such a special ref or a tag or a sha1
@@ -86,20 +99,24 @@ if [ ${recurse} -eq 1 ]; then
     _git submodule update --init --recursive
 fi
 
-# We do not want the .git dir; we keep other .git files, in case they
-# are the only files in their directory.
+# Generate the archive, sort with the C locale so that it is reproducible.
+# We do not want the .git dir; we keep other .git files, in case they are the
+# only files in their directory.
 # The .git dir would generate non reproducible tarballs as it depends on
 # the state of the remote server. It also would generate large tarballs
 # (gigabytes for some linux trees) when a full clone took place.
-rm -rf .git
+find . -not -type d \
+	-and -not -path "./.git/*" >"${output}.list"
+LC_ALL=C sort <"${output}.list" >"${output}.list.sorted"
 
-popd >/dev/null
-
-# Generate the archive, sort with the C locale so that it is reproducible
-find "${basename}" -not -type d >"${basename}.list"
-LC_ALL=C sort <"${basename}.list" >"${basename}.list.sorted"
 # Create GNU-format tarballs, since that's the format of the tarballs on
 # sources.buildroot.org and used in the *.hash files
-tar cf - --numeric-owner --owner=0 --group=0 --mtime="${date}" --format=gnu \
-         -T "${basename}.list.sorted" >"${output}.tar"
+tar cf - --transform="s/^\.$/${basename}/" \
+	--numeric-owner --owner=0 --group=0 --mtime="${date}" --format=gnu \
+         -T "${output}.list.sorted" >"${output}.tar"
 gzip -6 -n <"${output}.tar" >"${output}"
+
+rm -f "${output}.list"
+rm -f "${output}.list.sorted"
+
+popd >/dev/null
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first
  2018-04-02 14:58 ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Maxime Hadjinlian
@ 2018-04-02 15:13   ` Yann E. MORIN
  2018-04-02 15:48     ` Peter Korsgaard
  2018-04-02 21:47   ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Peter Korsgaard
  1 sibling, 1 reply; 17+ messages in thread
From: Yann E. MORIN @ 2018-04-02 15:13 UTC (permalink / raw)
  To: buildroot

For existing setups, the global donload directory may have a lot of the
required archives, so lok into there before attempting a adownload.

We siply hard-link them if found there and not in the new per-package
loaction. Then we resume the existing procedure (which means the new
hardlink will get removed if it happened to be incorrect).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 package/pkg-download.mk     |  1 +
 support/download/dl-wrapper | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index b7f1d43920..7ed95f2b2c 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -97,6 +97,7 @@ define DOWNLOAD
 	$(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
 		-c '$($(PKG)_DL_VERSION)' \
 		-d '$($(PKG)_DL_DIR)' \
+		-D '$(DL_DIR)' \
 		-f '$(notdir $(1))' \
 		-H '$(PKGDIR)/$($(PKG)_RAWNAME).hash' \
 		-n '$($(PKG)_BASENAME_RAW)' \
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index af2950ac3b..ce44752df0 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -27,11 +27,12 @@ main() {
     local -a uris
 
     # Parse our options; anything after '--' is for the backend
-    while getopts ":hc:d:o:n:N:H:rf:u:q" OPT; do
+    while getopts ":hc:d:D:o:n:N:H:rf:u:q" OPT; do
         case "${OPT}" in
         h)  help; exit 0;;
         c)  cset="${OPTARG}";;
         d)  dl_dir="${OPTARG}";;
+        D)  old_dl_dir="${OPTARG}";;
         o)  output="${OPTARG}";;
         n)  raw_base_name="${OPTARG}";;
         N)  base_name="${OPTARG}";;
@@ -52,6 +53,13 @@ main() {
         error "no output specified, use -o\n"
     fi
 
+    # Legacy handling: check if the file already exists in the global
+    # download directory. If it does, hard-link it. If it turns out it
+    # was an incorrect download, we'd still check it below anyway.
+    if [ ! -e "${output}" -a -e "${old_dl_dir}/${filename}" ]; then
+        ln "${old_dl_dir}/${filename}" "${output}"
+    fi
+
     # If the output file already exists and:
     # - there's no .hash file: do not download it again and exit promptly
     # - matches all its hashes: do not download it again and exit promptly
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR
  2018-04-02 14:57 ` [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR Maxime Hadjinlian
@ 2018-04-02 15:45   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:45 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > This per package variable can be used to specify the download
 > subdirectory used by that package.

 > The use case here is for example linux-headers and linux, which share
 > the same sources (because they are the same upstream project), so we
 > don't want to download twice the kernel, nor store it multiple times
 > either.

 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > ---
 > v4 -> v5:
 >     - Change SAME_SOURCE_AS into DL_SUBDIR (Thomas Petazzonni)

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors
  2018-04-02 14:57 ` [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors Maxime Hadjinlian
@ 2018-04-02 15:45   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:45 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > Since we introduced subdirectory to the DL_DIR, we need to support them
 > in the PRIMARY and BACKUP mirror as they evolve to the new tree
 > structure.

 > We check first the new URI (with the subdir), and in case of failure, we
 > go check without.
 > By checking both URIs, we ensure that old mirror are usable.

 > Also, add a missing qstrip call for BR2_BACKUP_SITE.

 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > ---
 > v4 -> v5:
 >    - Use new DL_SUBDIR
 >    - Add missing qstrip

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 4/8] package: share downloaded files for big packages
  2018-04-02 14:57 ` [Buildroot] [PATCH 4/8] package: share downloaded files for big packages Maxime Hadjinlian
@ 2018-04-02 15:45   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:45 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > From: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > Theses packages are given as an example of the use of the *_DL_SUBDIR feature.
 > There maybe other packages that would benefit from that feature, they
 > would need to be added on a case by case basis.

 > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 > ---
 > v4 -> v5:
 >     - Change SAME_SOURCE_AS into DL_SUBDIR

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR)
  2018-04-02 14:57 ` [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR) Maxime Hadjinlian
@ 2018-04-02 15:46   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:46 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Committed, thanks.

It would also be good to document LIBFOO_DL_SUBDIR and how to share it
between packages.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper
  2018-04-02 14:58 ` [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper Maxime Hadjinlian
@ 2018-04-02 15:46   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:46 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > In order to introduce the cache mechanisms, we need to have a lock on
 > the $(LIBFOO_DL_DIR), otherwise it would be impossible to do parallel
 > download (a shared DL_DIR for two buildroot instances).

I've extended the commit message a bit and committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 7/8] download: add missing '-d' option
  2018-04-02 14:58 ` [Buildroot] [PATCH 7/8] download: add missing '-d' option Maxime Hadjinlian
@ 2018-04-02 15:47   ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:47 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > The infrastructure needs to give the 'dl_dir' to the dl-wrappe which in
 > its turn needs to give it to the helper.
 > It will only be used by the 'git' helper as of now.

 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>

You could argue that the dl-wrapper could itself figure this out
(E.G. the directory part of output) and pass it to the helper, but OK -
We already pass a lot of arguments.

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first
  2018-04-02 15:13   ` [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first Yann E. MORIN
@ 2018-04-02 15:48     ` Peter Korsgaard
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 15:48 UTC (permalink / raw)
  To: buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > For existing setups, the global donload directory may have a lot of the
 > required archives, so lok into there before attempting a adownload.

 > We siply hard-link them if found there and not in the new per-package
 > loaction. Then we resume the existing procedure (which means the new
 > hardlink will get removed if it happened to be incorrect).

 > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > Cc: Peter Korsgaard <peter@korsgaard.com>
 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Committed after fixing a few typos, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Buildroot] [PATCH 8/8] download: git: introduce cache feature
  2018-04-02 14:58 ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Maxime Hadjinlian
  2018-04-02 15:13   ` [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first Yann E. MORIN
@ 2018-04-02 21:47   ` Peter Korsgaard
  1 sibling, 0 replies; 17+ messages in thread
From: Peter Korsgaard @ 2018-04-02 21:47 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxime" == Maxime Hadjinlian <maxime.hadjinlian@gmail.com> writes:

 > Now we keep the git clone that we download and generates our tarball
 > from there.
 > The main goal here is that if you change the version of a package (say
 > Linux), instead of cloning all over again, you will simply 'git fetch'
 > from the repo the missing objects, then generates the tarball again.

 > This should speed the 'source' part of the build significantly.

 > The drawback is that the DL_DIR will grow much larger; but time is more
 > important than disk space nowadays.

 > Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
 > ---
 > v4 -> v5:
 >     - Fix comments's content

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-04-02 21:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-02 14:57 [Buildroot] [PATCH 1/8] pkg-generic: add a subdirectory to the DL_DIR Maxime Hadjinlian
2018-04-02 14:57 ` [Buildroot] [PATCH 2/8] pkg-generic: introduce _DL_SUBDIR Maxime Hadjinlian
2018-04-02 15:45   ` Peter Korsgaard
2018-04-02 14:57 ` [Buildroot] [PATCH 3/8] pkg-download: support new subdir for mirrors Maxime Hadjinlian
2018-04-02 15:45   ` Peter Korsgaard
2018-04-02 14:57 ` [Buildroot] [PATCH 4/8] package: share downloaded files for big packages Maxime Hadjinlian
2018-04-02 15:45   ` Peter Korsgaard
2018-04-02 14:57 ` [Buildroot] [PATCH 5/8] help/manual: update help about the new $(LIBFOO_DL_DIR) Maxime Hadjinlian
2018-04-02 15:46   ` Peter Korsgaard
2018-04-02 14:58 ` [Buildroot] [PATCH 6/8] download: add flock call before dl-wrapper Maxime Hadjinlian
2018-04-02 15:46   ` Peter Korsgaard
2018-04-02 14:58 ` [Buildroot] [PATCH 7/8] download: add missing '-d' option Maxime Hadjinlian
2018-04-02 15:47   ` Peter Korsgaard
2018-04-02 14:58 ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Maxime Hadjinlian
2018-04-02 15:13   ` [Buildroot] [PATCH 9/8] core/download: look for archives in the global downlaod dir first Yann E. MORIN
2018-04-02 15:48     ` Peter Korsgaard
2018-04-02 21:47   ` [Buildroot] [PATCH 8/8] download: git: introduce cache feature Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.