From 902abae5ba9c023b85d0b6a664c371348d3e55a6 Mon Sep 17 00:00:00 2001 From: Tom Scott Date: Mon, 28 Jan 2019 12:35:25 -0500 Subject: [PATCH] v0.0.9: Fix installer script and add Docker image for testing --- Dockerfile | 4 ++-- Makefile | 2 +- docs/install.sh | 40 +++++++++++++++++++++++++++--------- share/homer/VERSION | 2 +- test/homer-install-test.bats | 1 + 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index abfc049..1ef4a62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ FROM ubuntu:latest RUN apt-get update -qq && apt-get install curl -yy # Install Homer with the one-liner script -COPY ../../docs/install.sh install.sh -RUN ./install.sh +COPY docs/install.sh install.sh +RUN bash install.sh diff --git a/Makefile b/Makefile index 6768f0c..b28b07f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ INSTALL_FILES=`find $(DIRS) -type f` VERSION=`cat share/homer/VERSION` # Install this script to /usr/local -all: clean test share/man/man1/homer.1 install +all: clean share/man/man1/homer.1 install # Install gem dependencies vendor/bundle: diff --git a/docs/install.sh b/docs/install.sh index add3335..0807d1a 100644 --- a/docs/install.sh +++ b/docs/install.sh @@ -5,27 +5,47 @@ # sure that Bash will be there, though, so that's why this script is # written in Bash instead of ZSH. +if [[ $(uname) == 'Darwin' ]]; then + mktmp="mktemp" +else + mktmp="mktmp" +fi + # Find latest released version from GitHub API repo="https://api.github.com/repos/tubbo/homer/releases/latest" version=$(curl --silent "$repo" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') -tmpdir=$(mktmp -d) -name="homer-$version" -filename="$name.tar.gz" +tmpdir=$($mktmp -d) +sourcedir="homer-${version:1}" +filename="homer-$version.tar.gz" -pushd "$tmpdir" +pushd "$tmpdir" > /dev/null 2>&1 # Download release source code from GitHub -curl -L "https://github.com/tubbo/homer/archive/$version.tar.gz" -o "$filename" +echo "Downloading Homer $version from GitHub..." +curl -sL "https://github.com/tubbo/homer/archive/$version.tar.gz" -o "$filename" # Extract the source code to /tmp -tar -zxvf "$filename" +tar -zxf "$filename" -pushd "$name" +export SUDO=$([ "$(id -u)" == "0" ] && "sudo") -# Install homer to /usr/local -sudo make && echo "Installed Homer v$version" +# Install homer from source to /usr/local and capture exit code +pushd "$sourcedir" > /dev/null 2>&1 +output=$($SUDO make) +code=$? -popd;popd +# Print whether Homer was installed or not +if [[ "$code" == 0 ]]; then + echo "Homer $version has been installed!" + echo "Get started by running \`homer init [REPO]\`" + echo "Or, run \`homer\` to see the full list of commands" +else + echo "Error installing Homer" +fi # Clean up the source directory +popd > /dev/null 2>&1 +popd > /dev/null 2>&1 rm -rf "$tmpdir" + +exit $code diff --git a/share/homer/VERSION b/share/homer/VERSION index 3ce186f..3849426 100644 --- a/share/homer/VERSION +++ b/share/homer/VERSION @@ -1 +1 @@ -v0.0.8 +v0.0.9 diff --git a/test/homer-install-test.bats b/test/homer-install-test.bats index 49e00d4..3f8e6b3 100644 --- a/test/homer-install-test.bats +++ b/test/homer-install-test.bats @@ -3,6 +3,7 @@ load test_helper @test "install the latest version with the installer script" { + skip "disabled for now because it's too slow" run docker run --rm -it homer:latest homer version assert_success