boxes: Implement make clean

This commit is contained in:
Fabio Rehm 2014-03-09 19:36:48 -03:00
parent ff3baf1cd4
commit 85d36bfd41
3 changed files with 33 additions and 3 deletions

View file

@ -12,5 +12,8 @@ $(UBUNTU_BOXES):
@sudo chmod +rw $(PACKAGE)
clean:
@echo "Implement clean"
@exit 1
@for r in $(UBUNTU_BOXES); do \
sudo -E ./clean.sh $${r}\
vagrant-lxc-base-$${r}-amd64-${TODAY} \
output/vagrant-lxc-$${r}-amd64-${TODAY}.box; \
done

27
boxes/clean.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
set -e
source common/ui.sh
export RELEASE=$1
export CONTAINER=$2
export PACKAGE=$3
export LOG=$(readlink -f .)/log/${CONTAINER}.log
info "Cleaning ${RELEASE} artifacts..."
# If container exists, check if want to continue
if $(lxc-ls | grep -q ${CONTAINER}); then
log "Removing '${CONTAINER}' container"
lxc-stop -n ${CONTAINER} &>/dev/null || true
lxc-destroy -n ${CONTAINER}
else
log "The container '${CONTAINER}' does not exist"
fi
if [ -e ${PACKAGE} ]; then
log "Removing '${PACKAGE}'"
rm -f ${PACKAGE}
else
log "The package '${PACKAGE}' does not exist"
fi

View file

@ -36,5 +36,5 @@ info "Building box to '${PACKAGE}'..."
./common/package.sh ${CONTAINER} ${PACKAGE}
info "Finished building '${PACKAGE}'!"
log "Run \`sudo lxc-destroy -n ${CONTAINER}\` to remove the container that was created along the way"
log "Run \`sudo lxc-destroy -n ${CONTAINER}\` or \`make clean\` to remove the container that was created along the way"
echo