All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Havelange <patrick.havelange@essensium.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v3 04/10] support/download/dl-wrapper: rework backend parsing
Date: Thu, 20 Feb 2020 17:01:13 +0100	[thread overview]
Message-ID: <20200220160119.3407-4-patrick.havelange@essensium.com> (raw)
In-Reply-To: <20200220160119.3407-1-patrick.havelange@essensium.com>

The point of this modification is to be more generic in the way
the backends/options are parsed from the urls.
The '+' char serves as delimiter between the backends and the
actual url.
The '|' char serves as separator between the different
options or backends.
This will be useful later when more options or backends would be
needed.

pkg-generic.mk now passes the optional FOO_PKGMGR value in case a
package needs to use a second backend.

Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
---
 package/pkg-generic.mk      |  2 +-
 support/download/dl-wrapper | 34 ++++++++++++++++++++++------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 268d999efb..a5038ebff4 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -541,7 +541,7 @@ ifndef $(2)_PATCH
 endif
 
 $(2)_ALL_DOWNLOADS = \
-	$$(if $$($(2)_SOURCE),$$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$($(2)_SOURCE)) \
+	$$(if $$($(2)_SOURCE),$$($(2)_PKGMGR)$$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$($(2)_SOURCE)) \
 	$$(foreach p,$$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS),\
 		$$(if $$(findstring ://,$$(p)),$$(p),\
 			$$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$(p)))
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index 3315bd410e..3f613bb622 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -21,8 +21,8 @@ export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:ru:qf:e"
 
 main() {
     local OPT OPTARG
-    local backend output hfile recurse quiet rc
-    local -a uris
+    local backend backends_str output hfile recurse quiet rc backend2
+    local -a uris backends
 
     # Parse our options; anything after '--' is for the backend
     while getopts ":c:d:D:o:n:N:H:rf:u:q" OPT; do
@@ -85,18 +85,24 @@ main() {
     download_and_check=0
     rc=1
     for uri in "${uris[@]}"; do
-        backend_urlencode="${uri%%+*}"
-        backend="${backend_urlencode%|*}"
-        case "${backend}" in
-            git|svn|cvs|bzr|file|scp|hg) ;;
-            *) backend="wget" ;;
-        esac
+        urlencode=""
+        backend="wget"
+        backend2=""
+
+        # Extract the backends list, separated by '+' from the actual url
+        backends_str="${uri%%+*}"
+        # make an array out of it, backends are '|' separated
+        IFS='|' read -r -a backends <<< "${backends_str}"
+        # parse each of them, set flags and set the real backend
+        for b in "${backends[@]}" ; do
+            case "${b}" in
+                urlencode) urlencode="${b}" ;;
+                git|svn|cvs|bzr|file|scp|hg) backend="${b}" ;;
+                # insert here supported second backends) backend2="${b}" ;;
+            esac
+        done
         uri=${uri#*+}
 
-        urlencode=${backend_urlencode#*|}
-        # urlencode must be "urlencode"
-        [ "${urlencode}" != "urlencode" ] && urlencode=""
-
         # tmpd is a temporary directory in which backends may store
         # intermediate by-products of the download.
         # tmpf is the file in which the backends should put the downloaded
@@ -138,6 +144,10 @@ main() {
         # cd back to free the temp-dir, so we can remove it later
         cd "${OLDPWD}"
 
+        if [ -n "${backend2}" ] ; then
+	    support/download/${backend2} "${tmpf}" "${tmpd}" "${old_dl_dir}"
+        fi
+
         # Check if the downloaded file is sane, and matches the stored hashes
         # for that file
         if support/download/check-hash ${quiet} "${hfile}" "${tmpf}" "${output##*/}"; then
-- 
2.17.1

  parent reply	other threads:[~2020-02-20 16:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 16:01 [Buildroot] [PATCH v3 01/10] package/pkg-cargo.mk: Introduce the cargo package infrastructure Patrick Havelange
2020-02-20 16:01 ` [Buildroot] [PATCH v3 02/10] docs/manual/cargo: Update manual for cargo packages Patrick Havelange
2020-02-20 16:01 ` [Buildroot] [PATCH v3 03/10] package/ripgrep: convert to cargo infrastructure Patrick Havelange
2020-02-20 16:01 ` Patrick Havelange [this message]
2020-02-20 16:01 ` [Buildroot] [PATCH v3 05/10] docs/manual/adding-packages-generic: update for new FOO_PKGMGR value Patrick Havelange
2020-02-20 16:01 ` [Buildroot] [PATCH v3 06/10] package/pkg-cargo.mk: Introduce the cargo dl backend Patrick Havelange
2020-08-26 19:22   ` Thomas Petazzoni
2020-02-20 16:01 ` [Buildroot] [PATCH v3 07/10] docs/manual/adding-packages-cargo: update doc for new infra Patrick Havelange
2020-02-20 16:01 ` [Buildroot] [PATCH v3 08/10] package/ripgrep: bump to version 11.0.1 Patrick Havelange
2020-02-20 16:01 ` [Buildroot] [PATCH v3 09/10] package/ripgrep: add legal-info for dependencies Patrick Havelange
2020-08-26 19:26   ` Thomas Petazzoni
2020-02-20 16:01 ` [Buildroot] [PATCH v3 10/10] docs/manual/adding-packages-cargo: Update for legal-info Patrick Havelange
2020-04-29 13:53 ` [Buildroot] [PATCH v3 01/10] package/pkg-cargo.mk: Introduce the cargo package infrastructure Romain Naour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200220160119.3407-4-patrick.havelange@essensium.com \
    --to=patrick.havelange@essensium.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.