Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 429  / 2 Years ago, tue, april 26, 2022, 7:43:34

I'm trying to make a Debian package for a cmake project that, in single-threaded mode, takes 3 hours to compile. I'm trying to get a parallel build, but failing.


I've tried setting parallel=4 in my control file like so:


#!/usr/bin/make -f
export DEB_BUILD_OPTIONS="parallel=4"

%:
dh $@ --parallel

Based on the accepted answer on this previous question, but I get the following warning:


dh: warning: invalid flag in DEB_BUILD_OPTIONS: "parallel=4"

And debhelper still invokes make -j1.


I've tried variations on the theme based on other suggestions/comments I've found online, DEB_BUILD_OPTIONS="-j=4", DEB_BUILD_OPTIONS="-j4" etc to no effect. I've tried setting debian/compat to 10. Always the result is invalid flag. How can I make debhelper honor this setting?


I'm doing the build in an Ubuntu Focal x86_64 docker container, and my version of debhelper is 12.10ubuntu1.


More From » compiling

 Answers
4

Turns out, I had the Makefile syntax wrong.


The error message I was seeing came from a regular expression in dpkg itself excerpted here:


         unless (/^([a-z][a-z0-9_-]*)(?:=(S*))?$/) {
warning(g_('invalid flag in %s: %s'), $source, $_);
next;
}

I re-read that regular expression a million times before I realized that the second %s in the warning does not have quotes around it, which means in the error message:


dh: warning: invalid flag in DEB_BUILD_OPTIONS: "parallel=4"

The quotes around "parallel=4" are coming from the environment variable itself not from the format string.


The fix, is to change


export DEB_BUILD_OPTIONS="parallel=4"

to


export DEB_BUILD_OPTIONS = parallel=4

because when setting the environment variable, make is preserving the quotes in the first version. When make is doing the string interpolation, it makes no practical difference because the quotes get eaten by the shell, but when a subprocess reads the value from an environment, the " characters are preserved.


#!/usr/bin/make -f
export WITH_QUOTES="parallel=3"
export WITHOUT_QUOTES = parallel=3

all:
bash -c 'printf "WITH_QUOTES=%q
" "$$WITH_QUOTES"'
bash -c 'printf "WITHOUT_QUOTES=%q
" "$$WITHOUT_QUOTES"'

bash -c 'printf "WITH_QUOTES=%q
" "$WITH_QUOTES"'
WITH_QUOTES="parallel=3"
bash -c 'printf "WITHOUT_QUOTES=%q
" "$WITHOUT_QUOTES"'
WITHOUT_QUOTES=parallel=3

Having the actual value of the environment variable be "parallel=4" not parallel=4 both triggered the warning, and broke this regular expression that dh uses to parse it (note leading ^):


        if ($opt =~ /^parallel=(-?d+)$/ && $wanted eq 'parallel') {
return $1;
}

[#397] Wednesday, April 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laceanz

Total Points: 86
Total Questions: 113
Total Answers: 104

Location: Australia
Member since Thu, Jan 26, 2023
1 Year ago
laceanz questions
Sat, Oct 23, 21, 09:40, 3 Years ago
Sat, Nov 5, 22, 08:24, 2 Years ago
Sat, Mar 12, 22, 07:56, 2 Years ago
Tue, Mar 28, 23, 23:58, 1 Year ago
;