From e8ae111907ed8ef099f5bfac4bbc3539044cac3f Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Fri, 21 Apr 2017 12:48:19 +0200 Subject: [PATCH 1/4] Simplify path specification for SOURCE and CCACHE directories After all, Docker deals fine with symlinks here, so calling stat/readlink is not needed. --- run.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/run.sh b/run.sh index 475417f..1ad902c 100755 --- a/run.sh +++ b/run.sh @@ -2,14 +2,8 @@ cd $(dirname $0) -if [[ $OSTYPE == "darwin"* ]]; then - SOURCE=$(stat -f %N $(pwd)/android) - CCACHE=$(stat -f %N $(pwd)/ccache) -else - SOURCE=$(readlink -f $(pwd)/android) - CCACHE=$(readlink -f $(pwd)/ccache) -fi - +SOURCE=$(pwd)/android +CCACHE=$(pwd)/ccache CONTAINER_HOME=/home/build CONTAINER=lineageos REPOSITORY=stucki/lineageos From 80265768b907da35a7946fa97ca4233b165bac8e Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Fri, 21 Apr 2017 12:50:59 +0200 Subject: [PATCH 2/4] Don't hardcode path for bash --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 1ad902c..e26236f 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd $(dirname $0) From b1d07d47e35279f2ad7e8e1c4ce1c534351d7105 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Fri, 21 Apr 2017 13:02:43 +0200 Subject: [PATCH 3/4] Use bash strict mode --- run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run.sh b/run.sh index e26236f..77fc831 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -euo pipefail + cd $(dirname $0) SOURCE=$(pwd)/android From 7149ec39deb2d77de8c6f9b4a3f25f9fa92060b2 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Fri, 21 Apr 2017 13:02:52 +0200 Subject: [PATCH 4/4] Remove unnecessary checks --- run.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/run.sh b/run.sh index 77fc831..08c3434 100755 --- a/run.sh +++ b/run.sh @@ -47,19 +47,14 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then USERID=$(id -u) GROUPID=$(id -g) docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID . - OK=$? # After successful build, delete existing containers IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) - if [[ $OK -eq 0 ]] && [[ -n "$IS_EXISTING" ]]; then + if [[ -n $IS_EXISTING ]]; then docker rm $CONTAINER fi fi -if [[ $OK -ne 0 ]]; then - exit 1 -fi - # With the given name $CONTAINER, reconnect to running container, start # an existing/stopped container or run a new one if one does not exist. IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null)