Base box cleanup script and rootfs compression

This commit is contained in:
Fabio Rehm 2014-03-08 10:42:28 -03:00
parent 8fec240ae6
commit 420a49c870
4 changed files with 32 additions and 3 deletions

View file

@ -4,3 +4,18 @@ set -e
source common/ui.sh source common/ui.sh
info "Packaging '${CONTAINER}' to '${PACKAGE}'..." info "Packaging '${CONTAINER}' to '${PACKAGE}'..."
debug 'Stopping container'
lxc-stop -n ${CONTAINER} &>/dev/null || true
debug "Removing previous rootfs tarbal"
rm -f ${WORKING_DIR}/rootfs.tar.gz
log "Compressing container's rootfs"
cd $(dirname ${ROOTFS})
tar --numeric-owner -czf ${WORKING_DIR}/rootfs.tar.gz ./rootfs/*
# Prepare package contents
cd ${WORKING_DIR}
warn 'TODO: Package!'

View file

@ -3,4 +3,13 @@ set -e
source common/ui.sh source common/ui.sh
debug 'Bringing container up'
lxc-start -d -n ${CONTAINER} &>/dev/null || true
info "Cleaning up '${CONTAINER}'..." info "Cleaning up '${CONTAINER}'..."
log 'Removing temporary files...'
lxc-attach -n ${CONTAINER} -- rm -rf /tmp/*
log 'Removing downloaded packages...'
lxc-attach -n ${CONTAINER} -- apt-get clean

View file

@ -9,8 +9,10 @@ debug 'Bringing container up'
lxc-start -d -n ${CONTAINER} &>/dev/null || true lxc-start -d -n ${CONTAINER} &>/dev/null || true
# TODO: Support for setting this from outside # TODO: Support for setting this from outside
PACKAGES=(vim curl wget man-db bash-completion python-software-properties software-properties-common) UBUNTU_PACKAGES=(vim curl wget man-db bash-completion python-software-properties software-properties-common)
lxc-attach -n ${CONTAINER} -- apt-get update lxc-attach -n ${CONTAINER} -- apt-get update
lxc-attach -n ${CONTAINER} -- apt-get install ${PACKAGES[*]} -y --force-yes lxc-attach -n ${CONTAINER} -- apt-get install ${UBUNTU_PACKAGES[*]} -y --force-yes
lxc-attach -n ${CONTAINER} -- apt-get upgrade -y --force-yes lxc-attach -n ${CONTAINER} -- apt-get upgrade -y --force-yes
warn 'TODO: Install provisioners'

View file

@ -19,6 +19,7 @@ export ARCH=$2
export CONTAINER=$3 export CONTAINER=$3
export PACKAGE=$4 export PACKAGE=$4
export ROOTFS="/var/lib/lxc/${CONTAINER}/rootfs" export ROOTFS="/var/lib/lxc/${CONTAINER}/rootfs"
export WORKING_DIR="/tmp/${CONTAINER}"
if [ -f ${PACKAGE} ]; then if [ -f ${PACKAGE} ]; then
warn "The box '${PACKAGE}' already exists, skipping..." warn "The box '${PACKAGE}' already exists, skipping..."
@ -26,6 +27,9 @@ if [ -f ${PACKAGE} ]; then
exit exit
fi fi
debug "Creating ${WORKING_DIR}"
mkdir -p ${WORKING_DIR}
info "Building box to '${PACKAGE}'..." info "Building box to '${PACKAGE}'..."
./common/download.sh ubuntu ${RELEASE} ${ARCH} ${CONTAINER} ./common/download.sh ubuntu ${RELEASE} ${ARCH} ${CONTAINER}
@ -33,7 +37,6 @@ info "Building box to '${PACKAGE}'..."
./debian/install-extras.sh ${CONTAINER} ./debian/install-extras.sh ${CONTAINER}
./debian/clean.sh ${CONTAINER} ./debian/clean.sh ${CONTAINER}
./common/package.sh ${CONTAINER} ${PACKAGE} ./common/package.sh ${CONTAINER} ${PACKAGE}
touch $PACKAGE
info "Finished building '${PACKAGE}'!" info "Finished building '${PACKAGE}'!"
echo echo