Permalink
Browse files

Supporting offline resource files

These bits add a make target for `fetch_resources`

- Parse the resources.dist file in $CHARM_ROOT
- Fetch and sha1sum the resources parsed out of resources.dist
- Print feedback about sum verification, all files isolated in `$CHARM_ROOT/resources`
  • Loading branch information...
1 parent ee50182 commit 1b8648d41fa336496efbff47e6a643e550361ee6 @chuckbutler committed May 9, 2016
Showing with 53 additions and 0 deletions.
  1. +28 −0 Makefile
  2. +1 −0 resources.dist
  3. +24 −0 scripts/download_resources.sh
View
@@ -0,0 +1,28 @@
+#!/usr/bin/make
+
+all: lint unit_test
+
+
+.PHONY: clean
@mbruzek

mbruzek May 9, 2016

I don't understand why you are using .PHONY so often in this Makefile. I read up on the feature in Makefiles: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html it seems only useful when you would have a file with the make target name, or are doing recursive make calls.

@chuckbutler

chuckbutler May 9, 2016

Owner

This came from the templated Makefile in layer-basic. I overrode the contents with what was there before + added a make target.

+clean:
+ @rm -rf .tox
+
+.PHONY: apt_prereqs
+apt_prereqs:
+ @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip)
+ @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox)
+
+.PHONY: lint
+lint: apt_prereqs
+ @tox --notest
+ @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests)
+ @charm proof
+
+.PHONY: unit_test
+unit_test: apt_prereqs
+ @echo Starting tests...
+ tox
+
+.PHONY: fetch_resources
+fetch_resources:
+ scripts/download_resources.sh
View
@@ -0,0 +1 @@
+etcd|2.2.3|etcd-v2.2.3-linux-amd64.tar.gz|https://github.com/coreos/etcd/releases/download/v2.2.3/etcd-v2.2.3-linux-amd64.tar.gz|208d5f05f1ef2715198904f46c7fde3f9b7bdec6
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+#!/bin/bash
+mkdir -p $(pwd)/resources
+
+while IFS="|" read app version file url checksum
@mbruzek

mbruzek May 9, 2016

Nice use of bash here #Ilearnedtoday ^

+do
+ echo "Downloading $app Version: $version"
+ echo $url
@chuckbutler

chuckbutler May 9, 2016

Owner

oops these need to go.

+ echo $file
+ curl -L -v $url -o resources/$file 2>> logfile.txt
+ # make here a special case, if the file is not present
+ calculated_sum=$(sha1sum "resources/$file" | /usr/bin/cut -f 1 -d " ")
+ # compare checksum
+ case "$calculated_sum" in
+ "$checksum")
+ echo -e " \033[m\033[42m OK \033[0m crypto signature compared and correct.";
@mbruzek

mbruzek May 9, 2016

Ohh fancy colors!

+ ;;
+ *)
+ echo -e " \033[m\033[41m ERROR \033[0m cryptographic verification failed!";
+ esac
+done < "resources.dist"

2 comments on commit 1b8648d

Did this code already land? I don't see the normal merge option here?

Owner

chuckbutler replied May 9, 2016

Its not landed. Its in flight :) i have a lot more to do in here to support this change.

Please sign in to comment.