Merge remote-tracking branch 'origin/master'
[obnox/vagrant/vagrant-lxc-base-boxes.git] / mk-fedora.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='fedora'
12 export RELEASE=$1
13 export ARCH=$2
14 export CONTAINER=$3
15 export PACKAGE=$4
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 ./fedora/install-extras.sh ${CONTAINER}
40 ./common/prepare-vagrant-user.sh ${DISTRIBUTION} ${CONTAINER}
41 ./fedora/clean.sh ${CONTAINER}
42 ./common/package.sh ${CONTAINER} ${PACKAGE}
43
44 info "Finished building '${PACKAGE}'!"
45 log "Run \`sudo lxc-destroy -n ${CONTAINER}\` or \`make clean\` to remove the container that was created along the way"
46 echo