2014-03-08 02:34:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2014-03-08 05:23:06 +00:00
|
|
|
source common/ui.sh
|
|
|
|
|
2014-03-08 02:34:09 +00:00
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
|
|
echo "You should run this script as root (sudo)."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-03-10 00:35:53 +00:00
|
|
|
export DISTRIBUTION=$1
|
|
|
|
export RELEASE=$2
|
|
|
|
export ARCH=$3
|
|
|
|
export CONTAINER=$4
|
|
|
|
export PACKAGE=$5
|
2014-03-08 05:23:06 +00:00
|
|
|
export ROOTFS="/var/lib/lxc/${CONTAINER}/rootfs"
|
2014-03-08 13:42:28 +00:00
|
|
|
export WORKING_DIR="/tmp/${CONTAINER}"
|
2014-03-09 07:18:10 +00:00
|
|
|
export NOW=$(date -u)
|
2014-03-09 22:34:59 +00:00
|
|
|
export LOG=$(readlink -f .)/log/${CONTAINER}.log
|
2014-03-08 02:34:09 +00:00
|
|
|
|
2014-03-09 23:20:37 +00:00
|
|
|
mkdir -p $(dirname $LOG)
|
|
|
|
echo '############################################' > ${LOG}
|
|
|
|
echo "# Beginning build at $(date)" >> ${LOG}
|
|
|
|
touch ${LOG}
|
|
|
|
chmod +rw ${LOG}
|
|
|
|
|
2014-03-08 02:34:09 +00:00
|
|
|
if [ -f ${PACKAGE} ]; then
|
2014-03-08 05:23:06 +00:00
|
|
|
warn "The box '${PACKAGE}' already exists, skipping..."
|
2014-03-08 02:34:09 +00:00
|
|
|
echo
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2014-03-08 13:42:28 +00:00
|
|
|
debug "Creating ${WORKING_DIR}"
|
|
|
|
mkdir -p ${WORKING_DIR}
|
|
|
|
|
2014-03-08 05:23:06 +00:00
|
|
|
info "Building box to '${PACKAGE}'..."
|
2014-03-08 02:34:09 +00:00
|
|
|
|
2014-03-10 00:35:53 +00:00
|
|
|
./common/download.sh ${DISTRIBUTION} ${RELEASE} ${ARCH} ${CONTAINER}
|
2014-03-08 02:34:09 +00:00
|
|
|
./common/prepare-vagrant-user.sh ${CONTAINER}
|
|
|
|
./debian/install-extras.sh ${CONTAINER}
|
|
|
|
./debian/clean.sh ${CONTAINER}
|
|
|
|
./common/package.sh ${CONTAINER} ${PACKAGE}
|
|
|
|
|
2014-03-08 05:23:06 +00:00
|
|
|
info "Finished building '${PACKAGE}'!"
|
2014-03-09 22:36:48 +00:00
|
|
|
log "Run \`sudo lxc-destroy -n ${CONTAINER}\` or \`make clean\` to remove the container that was created along the way"
|
2014-03-08 02:34:09 +00:00
|
|
|
echo
|