Makefile: add check-package-external target

The new target provides a convenient way to run utils/check-package on
any external trees, using .checkpackageignore files from the
respective trees if present.

While .checkpackageignore should be used as little as possible, in a
few cases adding overrides for false-positives to the affected files
is not feasible, a practical example of this is a Markdown file
misidentified as Python by libmagic (likely due to code blocks).

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
[Arnout: set ${ignore} explicitly to empty, in case it exists in the
environment.]
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
Fiona Klute
2025-09-29 11:24:31 +02:00
committed by Arnout Vandecappelle
parent 287d06f5d7
commit fe48905080

View File

@@ -125,7 +125,8 @@ endif
noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
defconfig %_defconfig allyesconfig allnoconfig alldefconfig syncconfig release \
randpackageconfig allyespackageconfig allnopackageconfig \
print-version olddefconfig distclean manual manual-% check-package
print-version olddefconfig distclean manual manual-% check-package \
check-package-external
# Some global targets do not trigger a build, but are used to collect
# metadata, or do various checks. When such targets are triggered,
@@ -1255,10 +1256,29 @@ release:
print-version:
@echo $(BR2_VERSION_FULL)
# $(1): br2-external path
# $(2): br2-external description
define check-package-external
@$(call MESSAGE,"Checking packages in $(2)")
$(Q)if [ -r "$(1)/.checkpackageignore" ]; then \
ignore="--ignore-list=$(1)/.checkpackageignore" ; \
else \
ignore=""; \
fi ; \
$(TOPDIR)/utils/check-package \
--br2-external $${ignore} \
`git -C $(1) ls-tree -r --format='$(1)/%(path)' HEAD`
endef
check-package:
$(Q)./utils/check-package `git ls-tree -r --name-only HEAD` \
--ignore-list=$(TOPDIR)/.checkpackageignore
check-package-external:
$(foreach name,$(BR2_EXTERNAL_NAMES),\
$(call check-package-external,$(BR2_EXTERNAL_$(name)_PATH),\
$(BR2_EXTERNAL_$(name)_DESC))$(sep))
.PHONY: .checkpackageignore
.checkpackageignore:
$(Q)./utils/check-package --failed-only `git ls-tree -r --name-only HEAD` \