2

I need to set a specific header to fetch an archive from a resource using the wget fetcher, analogous to:

wget --header "PRIVATE-ACCESS-TOKEN:blablablablabla https://some-resource...." 

How can I set specific headers using that fetcher?

Thanks in advance!

grmmgrmm
  • 994
  • 10
  • 29

1 Answers1

4

You can do it in various ways, here are some:

  1. Download the file manually and place it in downloads folder, as mentioned here

  2. Override the do_fetch task:

do_fetch() {
    bbnote "Fetching some file ..."
    wget ...
}

But you need to take note that do_unpack uses SRC_URI, so you still gonna need to specify SRC_URI to the file URL for the unpack, example that I test with wget package itself:

LICENSE="CLOSED"

SRC_URI = "http://ftp.gnu.org/gnu/wget/wget2-2.0.0.tar.gz"

do_fetch(){
    bbwarn "Fetching wget"
    wget http://ftp.gnu.org/gnu/wget/wget2-2.0.0.tar.gz
}

After running do_fetch the file gets downloaded in downloads and then do_unpack unpacked it under WORKDIR of the recipe.

  1. Specify your own wget command line for the wget fetcher:
FETCHCMD_wget = "/usr/bin/env wget --header "PRIVATE-ACCESS-TOKEN:blablablablabla""

the default wget command is present in: poky/bitbake/lib/bb/fetch2/wget.py:

self.basecmd = d.getVar("FETCHCMD_wget") or "/usr/bin/env wget -t 2 -T 30 --passive-ftp --no-check-certificate"

For more information check: this link.

Talel BELHADJSALEM
  • 3,199
  • 1
  • 10
  • 30
  • Thanks a lot! I have to define `--download-document=${SOMEPATH}/${PN}.zip` because otherwise wget stores it under some name deduced from a part of the url. I don't manage to automatically unpack that package. I tried setting `${SOMEPATH}` to `${WORLKDIR}` and to `${DL_DIR}`. The target is stored as expected but the zip file doesn't get unpacked. A hint here would be very much appreciated. – grmmgrmm Apr 07 '22 at 14:02