Set an environment variable for a build

Is it possible to set an env var for the build of a package? I’ve looked into Build Constraints and Build Configuration sections of the manual, but couldn’t find anything related…

Context:
I want to activate nodoc, noudeb and pkg.linux.nosource build profiles for my Debian kernel package as a workaround for disk space constraints. When building locally, this is done by setting DEB_BUILD_PROFILES env var.

Just like normally done in the shell, for example:

%build
export BUILD_PROFILES=default
%make

Please forgive my ignorance: where should I put this? Into my project config?
This seems to break the syntax:

All lines (except conditionals) have the form:

keyword: arguments

I think one can only define rpm macros in project config, and it’s up to the build recipes whether to use these macros.

If you don’t want to modify the current package, maybe you can create a new package to export the environment variable.

The critical feature of build profiles is that activating does not break build reproducibility. Modifying a package obviously will, so it’s not really a good solution in general (if I’m to modify the package, I can as well throw out some parts completely, but that’s not the point).

What I mean is creating a package, whose only duty is adding a file containing the needed export to /etc/profile.d or somewhere appropriate. Then Require: it in the project config.

1 Like

Now that is a sneaky hack! :wink:
I’ll try that: many thanks!