Search code examples
embedded-linuxyoctobitbake

Add specific header to bitbake wget fetcher


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!


Solution

  • 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.