Matt K
Matt K

Reputation: 618

Setting environment variables for a single package

My current Buildroot configuration includes a package whose source is hosted on a GitLab server. Unfortunately this server has errors with its SSL certificate; when Buildroot reaches this package it tries to clone the repository, but Git throws an error regarding the SSL certificate and aborts.

This is reasonable behaviour, and the reasonable response would be to either:

Unfortunately, I'm also constrained by the following:

I think the GIT_NO_SSL_VERIFY environment variable is the simplest solution. If I add this to Buildroot's EXTRA_ENV variable, everything works as expected.

Unfortunately this disables SSL for all Git repositories cloned by Buildroot. Since there is only one Git repository with this issue, it feels wrong to disabled SSL for all Git repositories cloned through Buildroot.

It would be great if I could set EXTRA_ENV to add GIT_NO_SSL_VERIFY, but only for the package I'm having issues with. I can't find any suggestion that Buildroot supports this, but the documentation is sparse so I figured I'd ask here.

Thanks!

Upvotes: 1

Views: 4218

Answers (2)

Arnout
Arnout

Reputation: 3464

In addition to setting $(PKG)_DL_OPTS, there are a few other hacks that can be used.

  1. Add a rule that overrides EXTRA_ENV, but only for your package (but note that this will not work for legal-info):

    $(MYPKG_TARGET_SOURCE): EXTRA_ENV += GIT_NO_SSL_VERIFY=1
    

    Note that this has to come after the $(eval $(generic-package)) call, so either at the end of the .mk file or in an external Makefile.

  2. Instead of EXTRA_ENV, you can also override DL_WRAPPER:

    $(MYPKG_TARGET_SOURCE): DL_WRAPPER := GIT_NO_SSL_VERIFY=1 $(DL_WRAPPER)
    
  3. Patch Buildroot to add an environment override to downloads. The simplest way to do that would be to define DL_WRAPPER differently:

    DL_WRAPPER = $($(PKG)_DL_ENV) support/download/dl-wrapper
    

    (But if you want to send such a patch upstream, it should be done in each individual download method instead.)

Note: I haven't actually tried any of the above.

Upvotes: 1

Matt K
Matt K

Reputation: 618

It turns out that Buildroot supports this. For a given package, the $(PKG)_DL_OPTS variable is used to pass options to the package's download tool.

I realized that my package was not being cloned withgit, but downloaded as a tarball with wget. Setting the package's $(PKG)_DL_OPTS variable to --no-check-certificate fixed everything.

Just as a note, the $(PKG)_DL_OPTS variable was only added in the 2016.11 release of Buildroot. You'll need a more convoluted workaround for older versions.

Upvotes: 3

Related Questions