From e7e7be65ecbd9284965d9f1ed39b23586449e8d7 Mon Sep 17 00:00:00 2001 From: Ross Philipson Date: Fri, 14 Oct 2016 15:47:57 -0400 Subject: [PATCH 1/2] [build] Add cleanup script. OXT-507 Signed-off-by: Ross Philipson --- build-scripts/clean.sh | 140 +++++++++++++++++++++++++++++++++++++++++ build-scripts/setup.sh | 3 + 2 files changed, 143 insertions(+) create mode 100755 build-scripts/clean.sh diff --git a/build-scripts/clean.sh b/build-scripts/clean.sh new file mode 100755 index 000000000..a3617fbaf --- /dev/null +++ b/build-scripts/clean.sh @@ -0,0 +1,140 @@ +#!/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 + + 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 < Date: Fri, 14 Oct 2016 16:39:02 -0400 Subject: [PATCH 2/2] [build] clean.sh - various fixes from comments on PR OXT-507 Signed-off-by: Ross Philipson --- build-scripts/clean.sh | 13 +++++++++---- build-scripts/setup.sh | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build-scripts/clean.sh b/build-scripts/clean.sh index a3617fbaf..b25c2dbe5 100755 --- a/build-scripts/clean.sh +++ b/build-scripts/clean.sh @@ -45,11 +45,16 @@ if [ "$IN_CONTAINER" = "y" ]; then 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 + for i in $BDLIST; do echo "Cleaning up: $i" rm -rf $i done + exit 0 fi @@ -60,7 +65,7 @@ CLEAN_ALL="" usage() { cat >&2 <