Base box cleanup script and rootfs compression
This commit is contained in:
parent
8fec240ae6
commit
420a49c870
4 changed files with 32 additions and 3 deletions
|
@ -4,3 +4,18 @@ set -e
|
|||
source common/ui.sh
|
||||
|
||||
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!'
|
||||
|
|
|
@ -3,4 +3,13 @@ set -e
|
|||
|
||||
source common/ui.sh
|
||||
|
||||
debug 'Bringing container up'
|
||||
lxc-start -d -n ${CONTAINER} &>/dev/null || true
|
||||
|
||||
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
|
||||
|
|
|
@ -9,8 +9,10 @@ debug 'Bringing container up'
|
|||
lxc-start -d -n ${CONTAINER} &>/dev/null || true
|
||||
|
||||
# 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 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
|
||||
|
||||
warn 'TODO: Install provisioners'
|
||||
|
|
|
@ -19,6 +19,7 @@ export ARCH=$2
|
|||
export CONTAINER=$3
|
||||
export PACKAGE=$4
|
||||
export ROOTFS="/var/lib/lxc/${CONTAINER}/rootfs"
|
||||
export WORKING_DIR="/tmp/${CONTAINER}"
|
||||
|
||||
if [ -f ${PACKAGE} ]; then
|
||||
warn "The box '${PACKAGE}' already exists, skipping..."
|
||||
|
@ -26,6 +27,9 @@ if [ -f ${PACKAGE} ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
debug "Creating ${WORKING_DIR}"
|
||||
mkdir -p ${WORKING_DIR}
|
||||
|
||||
info "Building box to '${PACKAGE}'..."
|
||||
|
||||
./common/download.sh ubuntu ${RELEASE} ${ARCH} ${CONTAINER}
|
||||
|
@ -33,7 +37,6 @@ info "Building box to '${PACKAGE}'..."
|
|||
./debian/install-extras.sh ${CONTAINER}
|
||||
./debian/clean.sh ${CONTAINER}
|
||||
./common/package.sh ${CONTAINER} ${PACKAGE}
|
||||
touch $PACKAGE
|
||||
|
||||
info "Finished building '${PACKAGE}'!"
|
||||
echo
|
||||
|
|
Loading…
Reference in a new issue