Suppress warnings and spurious error messages for the clean, realclean
authorWard Vandewege <ward@curoverse.com>
Wed, 23 Jul 2014 01:18:15 +0000 (21:18 -0400)
committerWard Vandewege <ward@curoverse.com>
Wed, 23 Jul 2014 01:18:15 +0000 (21:18 -0400)
and deepclean targets.

refs #3219

docker/build.sh
docker/build_tools/Makefile
docker/build_tools/build.rb

index cbcc840667c4001365d5644be6fc4e1b16817d90..e990ccd8ede461af400ddcdb6cdc28e41a70efa1 100755 (executable)
@@ -11,4 +11,14 @@ then
     sudo apt-get -y install ruby1.9.3
 fi
 
-build_tools/build.rb $*
+build_tools/build.rb
+
+if [[ "$?" == "0" ]]; then
+    DOCKER=`which docker.io`
+
+    if [[ "$DOCKER" == "" ]]; then
+      DOCKER=`which docker`
+    fi
+
+    DOCKER=$DOCKER /usr/bin/make -f build_tools/Makefile $*
+fi
index ff9593561bc7e29ff60fd8d2cc2aaa15fa332075..74a04dff5e5d7be7b0369f0d79e1cda9f0d069cd 100644 (file)
@@ -1,31 +1,50 @@
+# This is the 'shell hack'. Call make with DUMP=1 to see the effect.
+ifdef DUMP
+OLD_SHELL := $(SHELL)
+SHELL = $(warning [$@])$(OLD_SHELL) -x
+endif
+
 all: skydns-image skydock-image api-image compute-image doc-image workbench-image keep-image sso-image shell-image
 
+IMAGE_FILES := $(shell ls *-image 2>/dev/null |grep -v debian-arvados-image)
+GENERATED_FILES := $(shell ls */generated/* 2>/dev/null)
+GENERATED_DIRS := $(shell ls */generated 2>/dev/null)
+
 # `make clean' removes the files generated in the build directory
 # but does not remove any docker images generated in previous builds
 clean:
-       -rm -rf build
-       -rm `ls *-image |grep -v debian-arvados-image` */generated/*
-       -@rmdir */generated
+       @echo "make clean"
+       -@rm -rf build
+       +@[ "$(IMAGE_FILES)$(GENERATED_FILES)" = "" ] || rm $(IMAGE_FILES) $(GENERATED_FILES) 2>/dev/null
+       +@[ "$(GENERATED_DIRS)" = "" ] || rmdir */generated 2>/dev/null
 
 DEBIAN_IMAGE := $(shell $(DOCKER) images -q arvados/debian |head -n1)
 
+REALCLEAN_CONTAINERS := $(shell $(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e doc_server -e workbench_server |cut -f 1 -d' ')
+REALCLEAN_IMAGES := $(shell $(DOCKER) images -q arvados/* |grep -v $(DEBIAN_IMAGE) 2>/dev/null)
+DEEPCLEAN_IMAGES := $(shell $(DOCKER) images -q arvados/*)
+SKYDNS_CONTAINERS := $(shell $(DOCKER) ps -a |grep -e crosbymichael/skydns -e crosbymichael/skydock |cut -f 1 -d' ')
+SKYDNS_IMAGES := $(shell $(DOCKER) images -q crosbymichael/skyd*)
+
 # `make realclean' will also remove the Arvados docker images (but not the
 # arvados/debian image) and force subsequent makes to build the entire chain
 # from the ground up
 realclean: clean
-       -[ -n "`$(DOCKER) ps -q`" ] && $(DOCKER) stop `$(DOCKER) ps -q`
-       -$(DOCKER) rm `$(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e doc_server -e workbench_server |cut -f 1 -d' '`
-       -$(DOCKER) rmi `$(DOCKER) images -q arvados/* |grep -v $(DEBIAN_IMAGE)`
+       @echo "make realclean"
+       +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
+       +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
+       +@[ "$(REALCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(REALCLEAN_IMAGES)
 
 # `make deepclean' will remove all Arvados docker images and the skydns/skydock
 # images and force subsequent makes to build the entire chain from the ground up
 deepclean: clean
-       -rm debian-arvados-image
-       -[ -n "`$(DOCKER) ps -q`" ] && $(DOCKER) stop `$(DOCKER) ps -q`
-       -$(DOCKER) rm `$(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e doc_server -e workbench_server |cut -f 1 -d' '`
-       -$(DOCKER) rmi `$(DOCKER) images -q arvados/*`
-       -$(DOCKER) rm `$(DOCKER) ps -a |grep -e crosbymichael/skydns -e crosbymichael/skydock |cut -f 1 -d' '`
-       -$(DOCKER) rmi `$(DOCKER) images -q crosbymichael/skyd*`
+       @echo "make deepclean"
+       -@rm -f debian-arvados-image 2>/dev/null
+       +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
+       +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
+       +@[ "$(DEEPCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(DEEPCLEAN_IMAGES)
+       +@[ "$(SKYDNS_CONTAINERS)" = '' ] || $(DOCKER) rm $(SKYDNS_CONTAINERS)
+       +@[ "$(SKYDNS_IMAGES)" = '' ] || $(DOCKER) rmi $(SKYDNS_IMAGES)
 
 # ============================================================
 # Dependencies for */generated files which are prerequisites
index 4fef3568cbabe8d0b0e54647e19d197015bc33e0..df76d52cd4bd5c95a35f5aad398dc5ad17fa55bd 100755 (executable)
@@ -96,8 +96,9 @@ def main options
       docker_ok? docker_path and
       debootstrap_ok? and
       File.exists? 'config.yml'
-    warn "Building Arvados."
-    system({"DOCKER" => docker_path}, '/usr/bin/make', '-f', options[:makefile], *ARGV)
+    exit 0
+  else
+    exit 6
   end
 end
 
@@ -243,6 +244,5 @@ if __FILE__ == $PROGRAM_NAME
       options[:makefile] = mk
     end
   end
-
   main options
 end