Use $CONTAINER instead of $RELEASE for configuring /etc/hosts
[obnox/vagrant/vagrant-lxc-base-boxes.git] / mk-debian.sh
1 #!/bin/bash
2 set -e
3
4 source common/ui.sh
5
6 if [ "$(id -u)" != "0" ]; then
7   echo "You should run this script as root (sudo)."
8   exit 1
9 fi
10
11 export DISTRIBUTION=$1
12 export RELEASE=$2
13 export ARCH=$3
14 export CONTAINER=$4
15 export PACKAGE=$5
16 export ROOTFS="/var/lib/lxc/${CONTAINER}/rootfs"
17 export WORKING_DIR="/tmp/${CONTAINER}"
18 export NOW=$(date -u)
19 export LOG=$(readlink -f .)/log/${CONTAINER}.log
20
21 mkdir -p $(dirname $LOG)
22 echo '############################################' > ${LOG}
23 echo "# Beginning build at $(date)" >> ${LOG}
24 touch ${LOG}
25 chmod +rw ${LOG}
26
27 if [ -f ${PACKAGE} ]; then
28   warn "The box '${PACKAGE}' already exists, skipping..."
29   echo
30   exit
31 fi
32
33 debug "Creating ${WORKING_DIR}"
34 mkdir -p ${WORKING_DIR}
35
36 info "Building box to '${PACKAGE}'..."
37
38 ./common/download.sh ${DISTRIBUTION} ${RELEASE} ${ARCH} ${CONTAINER}
39 ./debian/vagrant-lxc-fixes.sh ${DISTRIBUTION} ${RELEASE} ${ARCH} ${CONTAINER}
40 ./debian/install-extras.sh ${CONTAINER}
41 ./common/prepare-vagrant-user.sh ${CONTAINER}
42 ./debian/clean.sh ${CONTAINER}
43 ./common/package.sh ${CONTAINER} ${PACKAGE}
44
45 info "Finished building '${PACKAGE}'!"
46 log "Run \`sudo lxc-destroy -n ${CONTAINER}\` or \`make clean\` to remove the container that was created along the way"
47 echo