2014-03-08 02:34:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2014-03-08 05:34:51 +00:00
|
|
|
source common/ui.sh
|
2014-03-08 02:34:09 +00:00
|
|
|
|
2014-03-09 06:55:10 +00:00
|
|
|
# TODO: Create file with build date / time on container
|
|
|
|
|
2014-03-08 05:34:51 +00:00
|
|
|
info "Packaging '${CONTAINER}' to '${PACKAGE}'..."
|
2014-03-08 13:42:28 +00:00
|
|
|
|
|
|
|
debug 'Stopping container'
|
|
|
|
lxc-stop -n ${CONTAINER} &>/dev/null || true
|
|
|
|
|
2014-03-09 06:55:10 +00:00
|
|
|
if [ -f ${WORKING_DIR}/rootfs.tar.gz ]; then
|
|
|
|
log "Removing previous rootfs tarbal"
|
|
|
|
rm -f ${WORKING_DIR}/rootfs.tar.gz
|
|
|
|
fi
|
2014-03-08 13:42:28 +00:00
|
|
|
|
|
|
|
log "Compressing container's rootfs"
|
2014-03-09 06:55:10 +00:00
|
|
|
pushd $(dirname ${ROOTFS}) &>/dev/null
|
|
|
|
tar --numeric-owner --anchored --exclude=./rootfs/dev/log -czf \
|
|
|
|
${WORKING_DIR}/rootfs.tar.gz ./rootfs/*
|
|
|
|
popd &>/dev/null
|
2014-03-08 13:42:28 +00:00
|
|
|
|
|
|
|
# Prepare package contents
|
2014-03-09 06:55:10 +00:00
|
|
|
pushd ${WORKING_DIR} &>/dev/null
|
|
|
|
warn "TODO: Package on `pwd`"
|
|
|
|
warn "TODO: Add creation date"
|
|
|
|
warn "TODO: Fix hostname (its too big!)"
|
|
|
|
popd &>/dev/null
|
2014-03-08 13:42:28 +00:00
|
|
|
|
2014-03-09 06:55:10 +00:00
|
|
|
# cp $LXC_TEMPLATE .
|
|
|
|
# cp $LXC_CONF .
|
|
|
|
# cp $METATADA_JSON .
|
|
|
|
# chmod +x lxc-template
|
|
|
|
# sed -i "s/<TODAY>/${NOW}/" metadata.json
|
|
|
|
#
|
|
|
|
# # Vagrant box!
|
|
|
|
# tar -czf $PKG ./*
|
|
|
|
#
|
|
|
|
# chmod +rw ${WORKING_DIR}/${PKG}
|
|
|
|
# mkdir -p ${CWD}/output
|
|
|
|
# mv ${WORKING_DIR}/${PKG} ${CWD}/output
|
|
|
|
#
|
|
|
|
# # Clean up after ourselves
|
|
|
|
# rm -rf ${WORKING_DIR}
|
|
|
|
# lxc-destroy -n ${RELEASE}-base
|
|
|
|
#
|
|
|
|
# echo "The base box was built successfully to ${CWD}/output/${PKG}"
|