[Buildroot] [git commit] support/download/dl-wrapper: add concept of download post-processing

Yann E. MORIN yann.morin.1998 at free.fr
Fri Jan 7 10:19:10 UTC 2022


commit: https://git.buildroot.net/buildroot/commit/?id=1db15e2853ff5a234e8ed1a70a75b5d426dceec5
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

In order to support package managers such as Cargo (Rust) or Go, we
want to run some custom logic after the main download, but before
packing the tarball and checking the hash.

To implement this, this commit introduces a concept of download
post-processing: if -p <something> is passed to the dl-wrapper, then
support/download/<something>-post-process will be called.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
[yann.morin.1998 at free.fr:
  - double-quote variable expansion when calling post-process script
]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
---
 support/download/dl-wrapper | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index 3185887541..09a6ac1f1a 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -25,7 +25,7 @@ main() {
     local -a uris
 
     # Parse our options; anything after '--' is for the backend
-    while getopts ":c:d:D:o:n:N:H:lrf:u:q" OPT; do
+    while getopts ":c:d:D:o:n:N:H:lrf:u:qp:" OPT; do
         case "${OPT}" in
         c)  cset="${OPTARG}";;
         d)  dl_dir="${OPTARG}";;
@@ -38,6 +38,7 @@ main() {
         r)  recurse="-r";;
         f)  filename="${OPTARG}";;
         u)  uris+=( "${OPTARG}" );;
+        p)  post_process="${OPTARG}";;
         q)  quiet="-q";;
         :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
         \?) error "unknown option '%s'\n" "${OPTARG}";;
@@ -136,6 +137,12 @@ main() {
             continue
         fi
 
+        if [ -n "${post_process}" ] ; then
+            "${OLDPWD}/support/download/${post_process}-post-process" \
+                -o "${tmpf}" \
+                -n "${raw_base_name}"
+        fi
+
         # cd back to free the temp-dir, so we can remove it later
         cd "${OLDPWD}"
 



More information about the buildroot mailing list