Skip to content

Commit 2d78c98

Browse files
MarkAtwoodsameehj
authored andcommitted
build(sbom): Makefile.am hygiene
Five small Makefile.am improvements from the wolfssl-1zj review pass. None changes user-facing behaviour for any correct invocation; each closes a specific failure mode that either silently corrupts an SBOM or leaks state. * sbom: lib glob: $(addprefix "$(abs_builddir)/...") quotes the prefix so an abs_builddir containing a space no longer word-splits the test -f loop. Matches the sbom: target's existing pattern (1zj.7). * SOURCE_DATE_EPOCH is only exported when 'git log -1 --format=%ct' returned a non-empty string. Previously the fallback echo on a shallow clone or corrupt repo silently exported SOURCE_DATE_EPOCH='', which gen-sbom then treated as 'no SDE' (warning + wallclock fallback) defeating the reproducibility intent (1zj.9). * --license-override and --license-text are now passed to gen-sbom only when their corresponding Make var is set ($(if VAR,...)). The previous unconditional passthrough relied on gen-sbom's argparse default '' to treat empty as unset; a future gen-sbom change distinguishing those cases would have silently mis-emitted SBOMs (1zj.10). * install-bomsh replaces the two-tar pipeline with cp -R src/. dst/. POSIX sh masks pipeline source-side errors; a permission failure on 'tar cf - .' was followed by 'tar xf -' on an empty stream succeeding, leaving a silent partial install. cp -R is a single command whose exit code propagates cleanly (1zj.11). * uninstall-hook now depends on uninstall-sbom + uninstall-bomsh instead of duplicating their bodies. Both targets are .PHONY so the dep edge resolves; the cleanup paths stay in lockstep with install-sbom / install-bomsh automatically (1zj.12). (BOMSH_OMNIBORDIR cleanup at make-clean time is handled by the existing clean-local target in doc/include.am, which the original PR commit extended. An earlier review attempted to add a duplicate clean-local here; that silently overrode the doc cleanups it relied on. The duplicate is not present in this squashed commit.) Closes wolfssl-1zj.6, wolfssl-1zj.7, wolfssl-1zj.9, wolfssl-1zj.10, wolfssl-1zj.11, wolfssl-1zj.12, wolfssl-e8o.1
1 parent 19ebc90 commit 2d78c98

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

Makefile.am

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,18 @@ sbom:
426426
echo "SBOM: hashing $$sbom_lib"; \
427427
if test -z "$${SOURCE_DATE_EPOCH:-}" && test -n "$(GIT)" && \
428428
$(GIT) -C "$(srcdir)" rev-parse --git-dir >/dev/null 2>&1; then \
429-
SOURCE_DATE_EPOCH=`$(GIT) -C "$(srcdir)" log -1 --format=%ct 2>/dev/null || echo`; \
430-
export SOURCE_DATE_EPOCH; \
429+
sde=`$(GIT) -C "$(srcdir)" log -1 --format=%ct 2>/dev/null`; \
430+
if test -n "$$sde"; then \
431+
SOURCE_DATE_EPOCH="$$sde"; \
432+
export SOURCE_DATE_EPOCH; \
433+
fi; \
431434
fi; \
432435
$(PYTHON3) $(srcdir)/scripts/gen-sbom \
433436
--name $(PACKAGE) \
434437
--version $(PACKAGE_VERSION) \
435438
--license-file $(srcdir)/LICENSING \
436-
--license-override '$(SBOM_LICENSE_OVERRIDE)' \
437-
--license-text '$(SBOM_LICENSE_TEXT)' \
439+
$(if $(SBOM_LICENSE_OVERRIDE),--license-override '$(SBOM_LICENSE_OVERRIDE)') \
440+
$(if $(SBOM_LICENSE_TEXT),--license-text '$(SBOM_LICENSE_TEXT)') \
438441
--options-h $(abs_builddir)/wolfssl/options.h \
439442
--lib "$$sbom_lib" \
440443
--dep-libz $(ENABLED_LIBZ) \
@@ -499,9 +502,9 @@ bomsh:
499502
fi; \
500503
bomsh_artifact=""; \
501504
for lib in \
502-
$(addprefix $(abs_builddir)/src/.libs/,$(WOLFSSL_LIB_DSO_BASENAMES)) \
503-
$(abs_builddir)/src/.libs/libwolfssl.a \
504-
$(abs_builddir)/src/libwolfssl.a; do \
505+
$(addprefix "$(abs_builddir)/src/.libs"/,$(WOLFSSL_LIB_DSO_BASENAMES)) \
506+
"$(abs_builddir)/src/.libs/libwolfssl.a" \
507+
"$(abs_builddir)/src/libwolfssl.a"; do \
505508
if test -f "$$lib"; then bomsh_artifact="$$lib"; break; fi; \
506509
done; \
507510
if test -z "$$bomsh_artifact"; then \
@@ -520,8 +523,7 @@ bomsh:
520523
install-bomsh: bomsh
521524
$(MKDIR_P) '$(DESTDIR)$(bomshdir)/omnibor'
522525
@if test -d '$(BOMSH_OMNIBORDIR)'; then \
523-
(cd '$(BOMSH_OMNIBORDIR)' && tar cf - .) | \
524-
(cd '$(DESTDIR)$(bomshdir)/omnibor' && tar xf -); \
526+
cp -R '$(BOMSH_OMNIBORDIR)/.' '$(DESTDIR)$(bomshdir)/omnibor/'; \
525527
fi
526528
@if test -f '$(abs_builddir)/$(BOMSH_SPDX_OUT)'; then \
527529
$(INSTALL_DATA) '$(abs_builddir)/$(BOMSH_SPDX_OUT)' '$(DESTDIR)$(bomshdir)/'; \
@@ -534,11 +536,9 @@ uninstall-bomsh:
534536
CLEANFILES += $(BOMSH_RAWLOG) $(BOMSH_RAWLOG_BASE).sha256 $(BOMSH_CONF) $(BOMSH_SPDX_OUT)
535537

536538
# Hook SBOM/Bomsh cleanup into `make uninstall` so packagers don't leave
537-
# stale artefacts behind after install-sbom/install-bomsh. rm -f is
538-
# idempotent, so this is safe whether or not those targets were ever run.
539-
uninstall-hook:
540-
-rm -f $(DESTDIR)$(sbomdir)/$(SBOM_CDX)
541-
-rm -f $(DESTDIR)$(sbomdir)/$(SBOM_SPDX)
542-
-rm -f $(DESTDIR)$(sbomdir)/$(SBOM_SPDX_TV)
543-
-rm -rf $(DESTDIR)$(bomshdir)/omnibor
544-
-rm -f $(DESTDIR)$(bomshdir)/$(BOMSH_SPDX_OUT)
539+
# stale artefacts behind after install-sbom/install-bomsh. uninstall-sbom
540+
# and uninstall-bomsh use `rm -f` / `rm -rf` so they are idempotent and
541+
# safe whether or not those targets were ever run. Depending on them
542+
# rather than duplicating their bodies keeps the cleanup paths in lock
543+
# step with install-sbom/install-bomsh.
544+
uninstall-hook: uninstall-sbom uninstall-bomsh

0 commit comments

Comments
 (0)