@@ -25,13 +25,41 @@ exec &> >(tee -a $build_log)
2525
2626# # Bail out if sources are already there
2727if [ -d tensorflow ] ; then
28- echo " You appear to have sources already" \
28+ printf " \n\n%s\n%s\n%s\n\n\n" \
29+ " You appear to have artefacts from a previous build lying around." \
30+ " Check for the following:" \
31+ " - tensorflow"
2932
30- if ! ([[ $* == * --force* ]] || [[ $* == * --use-existing-sources* ]]) ; then
31- echo " rerun with --force to overwrite sources or with" \
32- " --use-existing-sources to build your existing sources." 1>&2
33+ if ! ([[ $* == * --fresh* ]] || [[ $* == * --use-existing-sources* ]]) ; then
34+ printf " \n\n%s\n%s\n%s\n\n\n" \
35+ " Rerun with one of the following options:" \
36+ " - '--fresh': wipe the pre-existing sources and do a fresh build" \
37+ " - '--use-existing-sources': reuse the sources as is" 1>&2
3338 exit 1
3439 fi
40+
41+ # Wipe old build artefacts
42+ if [[ $* == * --fresh* ]]; then
43+ if [ -d tensorflow ]; then
44+ # Change permissions for folders created as root in docker
45+ if [ -d tensorflow/build_output ]; then
46+ if [ ! -z " $( docker ps -a --no-trunc | grep tf) " ]; then
47+ docker exec tf chown -R $( id -u) :$( id -g) build_output 2> /dev/null || true
48+ else
49+ printf " \n\n%s\n%s\n%s\n\n\n" \
50+ " Unable to locate docker container 'tf'. You may need to" \
51+ " rerun this script with sudo privileges to make sure everything" \
52+ " has been properly wiped."
53+ fi
54+ fi
55+
56+ # Wipe the container. Adapted from: tensorflow/ci/official/utilities/cleanup_docker.sh
57+ docker rm -f tf 2> /dev/null || true
58+
59+ # Wipe the folder
60+ rm -rf tensorflow
61+ fi
62+ fi
3563fi
3664
3765if ! [[ $* == * --use-existing-sources* ]]; then
0 commit comments