Skip to content

Commit

Permalink
Merge pull request #1 from seemethere/add_file_hashing
Browse files Browse the repository at this point in the history
Add file hashing for static files
  • Loading branch information
andrewhsu authored May 22, 2017
2 parents c4e3bb1 + 533a843 commit 48d4119
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion static/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ CLI_DIR:=$(CURDIR)/../../cli
ENGINE_VER=$(shell cat $(ENGINE_DIR)/VERSION)
VERSION=$(shell cat $(ENGINE_DIR)/VERSION)
CHOWN=docker run --rm -v $(CURDIR):/v -w /v alpine chown
HASH_CMD=docker run -v $(CURDIR):/sum -it -w /sum debian:jessie bash hash_files
DIR_TO_HASH:=build/linux

.PHONY: help clean static static-linux cross-mac cross-win cross-arm static-cli static-engine cross-all-cli cross-win-engine
.PHONY: help clean static static-linux cross-mac cross-win cross-arm static-cli static-engine cross-all-cli cross-win-engine hash_files

help: ## show make targets
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
Expand All @@ -24,6 +26,10 @@ static-linux: static-cli static-engine ## create tgz with linux x86_64 client an
done
tar -C build/linux -c -z -f build/linux/docker-$(VERSION).tgz docker

hash_files:
@echo "Hashing directory $(DIR_TO_HASH)"
$(HASH_CMD) "$(DIR_TO_HASH)"

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
Expand Down
11 changes: 11 additions & 0 deletions static/hash_files
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 48d4119

Please sign in to comment.