diff --git a/build-scripts/clean.sh b/build-scripts/clean.sh new file mode 100755 index 000000000..b25c2dbe5 --- /dev/null +++ b/build-scripts/clean.sh @@ -0,0 +1,145 @@ +#!/bin/bash -e +# +# OpenXT build script. +# Software license: see accompanying LICENSE file. +# +# Copyright (c) 2016 Assured Information Security, Inc. +# +# Contributions by Ross Philipson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Invocation: +# Used to cleanup a single build or all builds. +# +# N.B. this script starts outside the containers in the OUT OF CONTAINER +# block. It then sets the variables in the IN CONTAINER part and sends +# the modified script to each container to run the IN CONTAINER block. +# Finally back out in the OUT OF CONTAINER block it cleans up the local +# build dirs in xt-builds. + +BDLIST= + +#------------ IN CONTAINER ------------ + +IN_CONTAINER=%IN_CONTAINER% +C_BUILD_DIR=%C_BUILD_DIR% +C_CLEAN_ALL=%C_CLEAN_ALL% + +if [ "$IN_CONTAINER" = "y" ]; then + if [ -n "$C_BUILD_DIR" ]; then + echo "Cleaning up: $C_BUILD_DIR" + rm -rf $C_BUILD_DIR + exit 0 + fi + + if [ -z "$C_CLEAN_ALL" ]; then + exit 0 + fi + + BDLIST=`ls | grep -e "^[0-9]\{6\}-[0-9]\+$"` + for i in $BDLIST; do + echo "Cleaning up: $i" + rm -rf $i + done + + exit 0 +fi + +#------------ OUT OF CONTAINER ------------ + +BUILD_DIR="" +CLEAN_ALL="" + +usage() { + cat >&2 <