support/download: pass post-process options to post-process helper

Currently, we have no explicit, dedicated way to pass information to the
download post-process scripts, even though we do already need to pass
the path to the manifest when it is not the default, which we do with an
environment variable.

We'll soon need to be able to pass additional information to
post-process scripts, like instructing cargo to not use a lock file when
the package is not locked.

Extend the dl-wrapper with a new option with an argument, where the
argument will be passed as-is to the post-process script.

We explicitly do not document this new variable, as it is expected to
only be used in our package infrastructures (although there is currently
exactly one package that will directly need it, and we hope to drop that
in the future).

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Yann E. MORIN
2024-06-07 19:05:49 +02:00
committed by Arnout Vandecappelle
parent e0fbfe3521
commit f38e706a80
2 changed files with 6 additions and 3 deletions

View File

@@ -186,6 +186,7 @@ $(BUILD_DIR)/%/.stamp_downloaded:
$(call DOWNLOAD, \
$($(PKG)_MAIN_DOWNLOAD), \
$(patsubst %,-p '%',$($(PKG)_DOWNLOAD_POST_PROCESS)) \
$(patsubst %,-P '%',$($(PKG)_DOWNLOAD_POST_PROCESS_OPTS)) \
) \
)
$(foreach p,$($(PKG)_ADDITIONAL_DOWNLOADS),$(call DOWNLOAD,$(p))$(sep))

View File

@@ -25,10 +25,10 @@ export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:lru:qf:e"
main() {
local OPT OPTARG
local backend output large_file recurse quiet rc
local -a uris hfiles backend_opts
local -a uris hfiles backend_opts post_process_opts
# Parse our options; anything after '--' is for the backend
while getopts ":c:d:D:o:n:N:H:lrf:u:qp:" OPT; do
while getopts ":c:d:D:o:n:N:H:lrf:u:qp:P:" OPT; do
case "${OPT}" in
c) cset="${OPTARG}";;
d) dl_dir="${OPTARG}";;
@@ -42,6 +42,7 @@ main() {
f) filename="${OPTARG}";;
u) uris+=( "${OPTARG}" );;
p) post_process="${OPTARG}";;
P) post_process_opts+=( "${OPTARG}" );;
q) quiet="-q";;
:) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
\?) error "unknown option '%s'\n" "${OPTARG}";;
@@ -152,7 +153,8 @@ main() {
if [ -n "${post_process}" ] ; then
if ! "${OLDPWD}/support/download/${post_process}-post-process" \
-o "${tmpf}" \
-n "${raw_base_name}"
-n "${raw_base_name}" \
"${post_process_opts[@]}"
then
# cd back to keep path coherence
cd "${OLDPWD}"