From 723987478255583b68a9340ee7128f2a27610d29 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 22 May 2017 14:43:24 -0700 Subject: [PATCH] Add file hashing for static files Signed-off-by: Eli Uriegas (cherry picked from commit a1b7f6f3407546ff41ed2e0d16d7e1b2a8ac0ef4) Conflicts: components/packaging/static/Makefile Signed-off-by: Andrew Hsu --- components/packaging/static/Makefile | 4 ++++ components/packaging/static/hash_files | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 components/packaging/static/hash_files diff --git a/components/packaging/static/Makefile b/components/packaging/static/Makefile index 1c8d25d952e..1e7d9cdd055 100644 --- a/components/packaging/static/Makefile +++ b/components/packaging/static/Makefile @@ -25,6 +25,7 @@ static-linux: static-cli static-engine ## create tgz with linux x86_64 client an cp $(ENGINE_DIR)/bundles/$(ENGINE_VER)/binary-daemon/$$f build/linux/docker; \ done tar -C build/linux -c -z -f build/linux/docker-$(VERSION).tgz docker + $(HASH_CMD) build/linux hash_files: @echo "Hashing directory $(DIR_TO_HASH)" @@ -34,6 +35,7 @@ cross-mac: cross-all-cli ## create tgz with darwin x86_64 client only mkdir -p build/mac/docker cp $(CLI_DIR)/build/docker-darwin-amd64 build/mac/docker/docker tar -C build/mac -c -z -f build/mac/docker-$(VERSION).tgz docker + $(HASH_CMD) build/mac cross-win: cross-all-cli cross-win-engine ## create zip file with windows x86_64 client and server mkdir -p build/win/docker @@ -41,11 +43,13 @@ cross-win: cross-all-cli cross-win-engine ## create zip file with windows x86_64 cp $(ENGINE_DIR)/bundles/$(ENGINE_VER)/cross/windows/amd64/dockerd-$(ENGINE_VER).exe build/win/docker/dockerd.exe docker run --rm -v $(CURDIR)/build/win:/v -w /v alpine sh -c 'apk update&&apk add zip&&zip -r docker-$(VERSION).zip docker' $(CHOWN) -R $(shell id -u):$(shell id -g) build + $(HASH_CMD) bash hash_files build/win cross-arm: cross-all-cli ## create tgz with linux armhf client only mkdir -p build/arm/docker cp $(CLI_DIR)/build/docker-linux-arm build/arm/docker/docker tar -C build/arm -c -z -f build/arm/docker-$(VERSION).tgz docker + $(HASH_CMD) build/arm static-cli: $(MAKE) -C $(CLI_DIR) -f docker.Makefile VERSION=$(VERSION) build diff --git a/components/packaging/static/hash_files b/components/packaging/static/hash_files new file mode 100644 index 00000000000..a8851fcc0e7 --- /dev/null +++ b/components/packaging/static/hash_files @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Simple script to hash all the files in a given directory + +DIR_TO_LOOK_IN=${1:-build/linux} + +for f in $(find "$DIR_TO_LOOK_IN" -type f); do + for hash_algo in md5 sha256; do + "${hash_algo}sum" "$f" > "$f.$hash_algo" + done +done