Maytham Alsudany pushed to branch master at lintian / lintian
Commits:
-
be30cc13
by Maytham Alsudany at 2025-03-20T00:26:34+00:00
6 changed files:
- lib/Lintian/Check/Debian/Rules.pm
- + t/recipes/checks/debian/rules/debian-rules-calls-nproc/build-spec/debian/rules
- + t/recipes/checks/debian/rules/debian-rules-calls-nproc/build-spec/fill-values
- + t/recipes/checks/debian/rules/debian-rules-calls-nproc/eval/desc
- + t/recipes/checks/debian/rules/debian-rules-calls-nproc/eval/hints
- + tags/d/debian-rules-calls-nproc.tag
Changes:
| ... | ... | @@ -456,6 +456,12 @@ sub source { |
| 456 | 456 | $pointer);
|
| 457 | 457 | }
|
| 458 | 458 | |
| 459 | + if ($line =~ /\$\$\(\s*((\/usr)?\/bin\/)?nproc\s*\)/s
|
|
| 460 | + || $line =~ /\$\(shell \s*((\/usr)?\/bin\/)?nproc\s*\)/s
|
|
| 461 | + || $line =~ /`\s*((\/usr)?\/bin\/)?nproc\s*\`/s) {
|
|
| 462 | + $self->pointed_hint('debian-rules-calls-nproc',$pointer);
|
|
| 463 | + }
|
|
| 464 | + |
|
| 459 | 465 | if ($line !~ /^ifn?(?:eq|def)\s/ && $line =~ /^([^\s:][^:]*):+(.*)/s) {
|
| 460 | 466 | my ($target_names, $target_dependencies) = ($1, $2);
|
| 461 | 467 | @current_targets = split $SPACE, $target_names;
|
| 1 | +#!/usr/bin/make -f
|
|
| 2 | + |
|
| 3 | +NUM_CPUS=`/usr/bin/nproc`
|
|
| 4 | + |
|
| 5 | +%:
|
|
| 6 | + dh $@
|
|
| 7 | + |
|
| 8 | +override_dh_auto_build:
|
|
| 9 | + # This use of `nproc` will not cause a hint.
|
|
| 10 | + @echo "Building with $$(nproc) jobs."
|
|
| 11 | + dh_auto_build -- -j $(shell nproc)
|
|
| 12 | + echo Just saying the word nproc also will not cause a hint. |
| 1 | +Skeleton: source-native
|
|
| 2 | +Testname: debian-rules-calls-nproc
|
|
| 3 | +Description: debian/rules calls nproc |
| 1 | +Testname: debian-rules-calls-nproc
|
|
| 2 | +Check: debian/rules |
| 1 | +debian-rules-calls-nproc (source): debian-rules-calls-nproc [debian/rules:3]
|
|
| 2 | +debian-rules-calls-nproc (source): debian-rules-calls-nproc [debian/rules:11]
|
|
| 3 | +debian-rules-calls-nproc (source): debian-rules-calls-nproc [debian/rules:10] |
| 1 | +Tag: debian-rules-calls-nproc
|
|
| 2 | +Severity: warning
|
|
| 3 | +Check: debian/rules
|
|
| 4 | +Explanation: The <code>debian/rules</code> file for this package appears to
|
|
| 5 | + use nproc to determine the number of jobs to run in parallel during the
|
|
| 6 | + package build. This violates the Debian Policy, as the build must respect
|
|
| 7 | + "parallel=N" when passed in DEB_BUILD_OPTIONS.
|
|
| 8 | + .
|
|
| 9 | + To determine the number of jobs to run in parallel during the package build,
|
|
| 10 | + you can use the DEB_BUILD_OPTION_PARALLEL variable from
|
|
| 11 | + <code>/usr/share/dpkg/buildopts.mk</code>, which is set to the value of "N"
|
|
| 12 | + when "parallel=N" is passed.
|
|
| 13 | + .
|
|
| 14 | + include /usr/share/dpkg/buildopts.mk
|
|
| 15 | + NUM_CPUS=$(DEB_BUILD_OPTION_PARALLEL)
|
|
| 16 | + .
|
|
| 17 | + You can also use Make's <code>addprefix</code> to add a prefix like "-j" if
|
|
| 18 | + the DEB_BUILD_OPTION_PARALLEL variable is present, which can then be passed as
|
|
| 19 | + an argument.
|
|
| 20 | +See-Also: debian-policy 4.9.1 |