build: add checksum target

Add a new "checksum" make target which generates an sha256sums file over the
image files produced in bin/targets/ and automatically call it during make
world after the package index generation.

The advantage of this new target is that it is guaranteed to run after the
images, the SDK and the ImageBuilder archives have been generated to ensure
that they all end up in the checksum file. Fixes FS#51.

Uses sed to postprocess the OpenSSL digest output into an sha256sum command
compatible format.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2016-07-26 15:05:35 +02:00
parent 4d9fc1bd44
commit 27854a0a84
3 changed files with 17 additions and 0 deletions

View File

@ -83,9 +83,13 @@ prereq: $(target/stamp-prereq) tmp/.prereq_packages
exit 1; \ exit 1; \
fi fi
checksum: FORCE
$(call sha256sums,$(BIN_DIR))
prepare: .config $(tools/stamp-install) $(toolchain/stamp-install) prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
$(_SINGLE)$(SUBMAKE) -r package/index $(_SINGLE)$(SUBMAKE) -r package/index
$(_SINGLE)$(SUBMAKE) -r checksum
.PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean

View File

@ -371,6 +371,13 @@ define file_copy
$(CP) $(1) $(2) $(CP) $(1) $(2)
endef endef
# Calculate sha256sum of any plain file within a given directory
# $(1) => Input directory
define sha256sums
(cd $(1); find . -maxdepth 1 -type f -not -name 'sha256sums' -printf "%P\n" | sort | \
xargs openssl dgst -sha256 | sed -ne 's!^SHA256(\(.*\))= \(.*\)$$!\2 *\1!p' > sha256sums)
endef
# file extension # file extension
ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))

View File

@ -125,6 +125,7 @@ ifneq ($(USER_FILES),)
endif endif
$(MAKE) package_postinst $(MAKE) package_postinst
$(MAKE) build_image $(MAKE) build_image
$(MAKE) checksum
package_index: FORCE package_index: FORCE
@echo @echo
@ -170,6 +171,11 @@ build_image: FORCE
$(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \ $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \
$(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)") $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
checksum: FORCE
@echo
@echo Calculating checksums...
@$(call sha256sums,$(BIN_DIR))
clean: clean:
rm -rf $(TMP_DIR) $(DL_DIR) $(TARGET_DIR) $(BIN_DIR) rm -rf $(TMP_DIR) $(DL_DIR) $(TARGET_DIR) $(BIN_DIR)