Makefile: add tainting support
PATCH 1/2 Makefile: add tainting support
From: Angelo Compagnucci <[email protected]>
Packages who harms the build reproducibility can declare FOO_TAINTS variable.
If a package taints the build it will be added to a list of tainting packages.
The build ends with a warning if the tainting packages list is not empty.
Moreover, legal info will show a warning in presence of a tainting package.
--- Makefile | 11 +++++++++++ package/pkg-generic.mk | 9 +++++++++ 2 files changed, 20 insertions(+)
Makefile +11 -0
@@ -758,12 +758,22 @@ endif touch $(TARGET_DIR)/usr +# Check here if there are packages declaring they harm +# the reproducibility of the build +.PHONY: check-tainted +check-tainted: +ifneq ($(BR2_TAINTED_BY),) + $(error Buildroot is tainted (by: $(BR2_TAINTED_BY)).) +endif + .PHONY: target-post-image target-post-image: $(TARGETS_ROOTFS) target-finalize @rm -f $(ROOTFS_COMMON_TAR) @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \ $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) + @if [ ! -z "$(BR2_TAINTED_BY)" ]; then \ + echo "WARNING: Buildroot is tainted (by: $(BR2_TAINTED_BY))"; fi .PHONY: source source: $(foreach p,$(PACKAGES),$(p)-all-source)
@@ -1070,6 +1080,7 @@ help: @echo ' source - download all sources needed for offline-build' @echo ' external-deps - list external packages used' @echo ' legal-info - generate info about license compliance' + @echo ' check-tainted - check if any selected package harms build reproducibility' @echo ' printvars - dump all the internal variables' @echo @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
package/pkg-generic.mk +9 -0
@@ -542,6 +542,10 @@ ifndef $(2)_REDISTRIBUTE endif endif +ifdef $(2)_TAINTS + BR2_TAINTED_BY+=$$($(2)_RAWNAME) +endif + $(2)_REDISTRIBUTE ?= YES $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_BASENAME_RAW)
@@ -900,6 +904,11 @@ else $(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep)) endif # license files +# Save a legal warning if tainted +ifeq ($$(call qstrip,$$($(2)_TAINTS)),YES) + $(Q)$$(call legal-warning-pkg,$$($(2)_RAWNAME),unknown license for additional modules or dependencies) +endif + ifeq ($$($(2)_SITE_METHOD),local) # Packages without a tarball: don't save and warn @$$(call legal-warning-nosource,$$($(2)_RAWNAME),local)
Signature · 1 line
2.7.4
PATCH 2/2 package/nodejs: taint the build on external modules
From: Angelo Compagnucci <[email protected]>
This patch enables the tainting of the build when an external module is added.
--- package/nodejs/nodejs.mk | 1 + 1 file changed, 1 insertion(+)
package/nodejs/nodejs.mk +1 -0
@@ -160,6 +160,7 @@ NPM = $(TARGET_CONFIGURE_OPTS) \ # We can only call NPM if there's something to install. # ifneq ($(NODEJS_MODULES_LIST),) +NODEJS_TAINTS = YES define NODEJS_INSTALL_MODULES # If you're having trouble with module installation, adding -d to the # npm install call below and setting npm_config_rollback=false can both
Signature · 1 line
2.7.4
PATCH 1/2 Makefile: add tainting support
In reply to Angelo CompagnucciHi Angelo,
Some nits that were already present in v1 but I didn't review before...
Quoted 10 lines · Angelo Compagnucci
From: Angelo Compagnucci <[email protected]>
Packages who harms the build reproducibility can declare
FOO_TAINTSvariable.
If a package taints the build it will be added to a list of tainting packages.
The build ends with a warning if the tainting packages list is not empty.
Moreover, legal info will show a warning in presence of a tainting package.
Commit message wrapping is a bit weird. Wrap at 72 columns.
Quoted 12 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- Makefile | 11 +++++++++++ package/pkg-generic.mk | 9 +++++++++ 2 files changed, 20 insertions(+)Makefile +0
-0
Makefile endif · line 762
Quoted 5 lines
Makefile +2
-0@@ -758,12 +758,22 @@ endif touch $(TARGET_DIR)/usr +# Check here if there are packages declaring they harm +# the reproducibility of the build
As Thomas said, reproducibility is not the only issue here.
Also, wrap at 80 columns.
But really the comment is not necessary IMO.
Makefile endif · line 766
Quoted 4 lines
Makefile +4
-0+.PHONY: check-tainted +check-tainted: +ifneq ($(BR2_TAINTED_BY),) + $(error Buildroot is tainted (by: $(BR2_TAINTED_BY)).)
^^^^^^^^^ Your configuration
Makefile endif · line 775
Quoted 9 lines
Makefile +3
-0+endif + .PHONY: target-post-image target-post-image: $(TARGETS_ROOTFS) target-finalize @rm -f $(ROOTFS_COMMON_TAR) @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \ $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) + @if [ ! -z "$(BR2_TAINTED_BY)" ]; then \
Personally I'd prefer $(if $(BR2_TAINTED_BY), at echo ...) here. But if you keep
the shell condition:
Makefile endif · line 776
Quoted 1 line
Makefile +1
-0+ echo "WARNING: Buildroot is tainted (by: $(BR2_TAINTED_BY))"; fi
fi should be on a separate line.
Makefile help: · line 1083
Quoted 8 lines
Makefile +1
-0.PHONY: source source: $(foreach p,$(PACKAGES),$(p)-all-source)@@ -1070,6 +1080,7 @@ help: @echo ' source - download all sources needed for offline-build' @echo ' external-deps - list external packages used' @echo ' legal-info - generate info about license compliance' + @echo ' check-tainted - check if any selected package harms build reproducibility'
Not just reproducibility. but I don't really have a suggestion to improve that
isn't very long...
package/pkg-generic.mk ifndef $(2)_REDISTRIBUTE · line 546
Quoted 13 lines
Makefile +0
-0@echo ' printvars - dump all the internal variables' @echo @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'package/pkg-generic.mk +2
-0@@ -542,6 +542,10 @@ ifndef $(2)_REDISTRIBUTE endif endif +ifdef $(2)_TAINTS + BR2_TAINTED_BY+=$$($(2)_RAWNAME)
We normally don't indent inside make conditions.
package/pkg-generic.mk else · line 907
Quoted 10 lines
package/pkg-generic.mk +3
-0+endif + $(2)_REDISTRIBUTE ?= YES $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_BASENAME_RAW)@@ -900,6 +904,11 @@ else $(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep)) endif # license files +# Save a legal warning if tainted
Comment is useless IMO, the code speaks for itself.
package/pkg-generic.mk else · line 909
Quoted 2 lines
package/pkg-generic.mk +2
-0+ifeq ($$(call qstrip,$$($(2)_TAINTS)),YES) + $(Q)$$(call legal-warning-pkg,$$($(2)_RAWNAME),unknown license for additional modules or dependencies)
Er, this explanation is very specific... I think we could also add taints if
e.g. a git (or github-helper) download doesn't specify a full sha1, because then we're also not guaranteed to have reproducibility.
So for the legal warning, I'd rather think of something separate.
But actually, that can be changed if/when we actually do add taints for other
situations as well. So this bit is OK as it is for me.
Regards,
Arnout
Quoted 6 lines
package/pkg-generic.mk +2
-0+endif + ifeq ($$($(2)_SITE_METHOD),local) # Packages without a tarball: don't save and warn @$$(call legal-warning-nosource,$$($(2)_RAWNAME),local)
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF