2014-03-25 03:26:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
source common/ui.sh
|
|
|
|
|
|
|
|
# TODO: Create file with build date / time on container
|
|
|
|
|
|
|
|
info "Packaging '${CONTAINER}' to '${PACKAGE}'..."
|
|
|
|
|
|
|
|
if [ -f ${WORKING_DIR}/rootfs.tar.gz ]; then
|
|
|
|
log "Removing previous rootfs tarball"
|
|
|
|
rm -f ${WORKING_DIR}/rootfs.tar.gz
|
|
|
|
fi
|
|
|
|
|
2018-04-15 03:30:48 +00:00
|
|
|
log "Compressing container's rootfs (sudo needed)"
|
2014-03-25 03:26:19 +00:00
|
|
|
pushd $(dirname ${ROOTFS}) &>>${LOG}
|
2018-04-15 03:30:48 +00:00
|
|
|
sudo tar --numeric-owner --anchored --exclude=./rootfs/dev/log -czf \
|
2014-03-25 03:26:19 +00:00
|
|
|
${WORKING_DIR}/rootfs.tar.gz ./rootfs/*
|
|
|
|
popd &>>${LOG}
|
2018-04-15 03:30:48 +00:00
|
|
|
sudo chown ${UID} ${WORKING_DIR}/rootfs.tar.gz
|
2014-03-25 03:26:19 +00:00
|
|
|
|
|
|
|
# Prepare package contents
|
|
|
|
log 'Preparing box package contents'
|
2015-01-07 09:52:08 +00:00
|
|
|
if [ -f conf/${DISTRIBUTION}-${RELEASE} ]; then
|
|
|
|
cp conf/${DISTRIBUTION}-${RELEASE} ${WORKING_DIR}/lxc-config
|
|
|
|
else
|
|
|
|
cp conf/${DISTRIBUTION} ${WORKING_DIR}/lxc-config
|
|
|
|
fi
|
2014-03-25 03:26:19 +00:00
|
|
|
cp conf/metadata.json ${WORKING_DIR}
|
|
|
|
sed -i "s/<TODAY>/${NOW}/" ${WORKING_DIR}/metadata.json
|
|
|
|
|
|
|
|
# Vagrant box!
|
|
|
|
log 'Packaging box'
|
|
|
|
TARBALL=$(readlink -f ${PACKAGE})
|
|
|
|
(cd ${WORKING_DIR} && tar -czf $TARBALL ./*)
|