Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 715a1233 authored by Johannes Berg's avatar Johannes Berg
Browse files

wireless: don't write C files on failures



Change the scripting inside the shipped/extra certs C code
generation to not write the file when there are any failures.
That way, if the build aborts due to failures, we don't get
into a situation where a dummy file has been created and the
next build succeeds, but not with the desired output.

Fixes: 90a53e44 ("cfg80211: implement regdb signature checking")
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 71334963
Loading
Loading
Loading
Loading
+38 −10
Original line number Diff line number Diff line
@@ -25,17 +25,45 @@ endif

$(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.x509)
	@$(kecho) "  GEN     $@"
	@echo '#include "reg.h"' > $@
	@echo 'const u8 shipped_regdb_certs[] = {' >> $@
	@for f in $^ ; do od -An -v -tx1 < $$f | sed -e 's/ /\n/g' | sed -e 's/^[0-9a-f]\+$$/\0/;t;d' | sed -e 's/^/0x/;s/$$/,/' >> $@ ; done
	@echo '};' >> $@
	@echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);' >> $@
	@(set -e; \
	  allf=""; \
	  for f in $^ ; do \
	      # similar to hexdump -v -e '1/1 "0x%.2x," "\n"' \
	      thisf=$$(od -An -v -tx1 < $$f | \
	                   sed -e 's/ /\n/g' | \
	                   sed -e 's/^[0-9a-f]\+$$/\0/;t;d' | \
	                   sed -e 's/^/0x/;s/$$/,/'); \
	      # file should not be empty - maybe command substitution failed? \
	      test ! -z "$$thisf";\
	      allf=$$allf$$thisf;\
	  done; \
	  ( \
	      echo '#include "reg.h"'; \
	      echo 'const u8 shipped_regdb_certs[] = {'; \
	      echo "$$allf"; \
	      echo '};'; \
	      echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \
	  ) >> $@)

$(obj)/extra-certs.c: $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%) \
		      $(wildcard $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%)/*.x509)
	@$(kecho) "  GEN     $@"
	@echo '#include "reg.h"' > $@
	@echo 'const u8 extra_regdb_certs[] = {' >> $@
	@for f in $^ ; do test -f $$f && od -An -v -tx1 < $$f | sed -e 's/ /\n/g' | sed -e 's/^[0-9a-f]\+$$/\0/;t;d' | sed -e 's/^/0x/;s/$$/,/' >> $@ ; done
	@echo '};' >> $@
	@echo 'unsigned int extra_regdb_certs_len = sizeof(extra_regdb_certs);' >> $@
	@(set -e; \
	  allf=""; \
	  for f in $^ ; do \
	      # similar to hexdump -v -e '1/1 "0x%.2x," "\n"' \
	      thisf=$$(od -An -v -tx1 < $$f | \
	                   sed -e 's/ /\n/g' | \
	                   sed -e 's/^[0-9a-f]\+$$/\0/;t;d' | \
	                   sed -e 's/^/0x/;s/$$/,/'); \
	      # file should not be empty - maybe command substitution failed? \
	      test ! -z "$$thisf";\
	      allf=$$allf$$thisf;\
	  done; \
	  ( \
	      echo '#include "reg.h"'; \
	      echo 'const u8 extra_regdb_certs[] = {'; \
	      echo "$$allf"; \
	      echo '};'; \
	      echo 'unsigned int extra_regdb_certs_len = sizeof(extra_regdb_certs);'; \
	  ) >> $@)