1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/bin/bash
###
### This is a script build all archs on ec2. It calls build-ec2-image
### and downloads everything it needs. Should be able to call on a fresh
### instance
###
### you can download it with:
### wget http://build-ubuntu-on-ec2.notlong.com -O ec2-build-on-ec2
set -e
suite=${1}
mod_dns=${2:-yes}
dest="$PWD/${suite}"
img_base="${suite}"
partfile="${dest}/partfile"
[ $# -eq 1 ] ||
{ echo "must give suite"; exit 1; }
# one time setup stuff
toinst=( )
for p in bzr python-vm-builder resolvconf dnsmasq virtualbox-ose qemu-kvm qemu-kvm-extras-static qemu-kvm-extras; do
ver=$(dpkg-query --show --showformat '${Version}\n' "${p}") || :
[ -z "${ver}" ] && toinst[${#toinst[@]}]="${p}"
done
[ ${#toinst} -eq 0 ] || sudo apt-get install --assume-yes "${toinst[@]}"
[ ${mod_dns} = "yes" ] && {
mark="### USE_EC2_MIRRORS ###"
if ! grep -q "${mark}" /etc/hosts; then
sudo service resolvconf restart
sudo ifdown eth0; sudo ifup eth0
mirror=$(sed -n '/archive.ubuntu.com/s,.*http://\([^/]*\).*,\1,p' \
/etc/apt/sources.list | sort -u )
echo "setting up mirror: archive.ubuntu.com -> ${mirror}"
ip=""
for n in 1 2 3 4; do
ip=$(host "${mirror}" |
awk '$2 == "has" && $3 == "address" { print $4 ; exit(0); }')
[ -z "${ip}" ] || break
echo "waiting a bit for dns"; sleep ${n}
done
[ -n "${ip}" ] || { echo "couldn't set up dnsmasq hack?"; exit 1; }
sudo sh -c "{ echo '${mark}'; echo '${ip} archive.ubuntu.com us.archive.ubuntu.com'; } >> /etc/hosts"
sudo service dnsmasq restart
fi
}
[ -f "/usr/share/debootstrap/scripts/${suite}" ] ||
sudo ln -s gutsy "/usr/share/debootstrap/scripts/${suite}"
[ -d vmbuilder-0.11 ] ||
bzr branch lp:~ubuntu-virt/vmbuilder/0.11 vmbuilder-0.11
[ -d automated-ec2-builds ] ||
bzr branch lp:~ubuntu-on-ec2/vmbuilder/automated-ec2-builds
[ -d live-build ] ||
bzr branch lp:~ubuntu-on-ec2/live-build/cloud-images live-build
[ -d ec2-publishing-scripts ] ||
bzr branch lp:~ubuntu-on-ec2/ubuntu-on-ec2/ec2-publishing-scripts
### end onetime setup
AB_D="${PWD}/automated-ec2-builds"
VB_D="${PWD}/vmbuilder-0.11"
EC2PUB_D="${PWD}/ec2-publishing-scripts"
PATH="${AB_D}:${VB_D}:${EC2PUB_D}:$PATH"
export LIVE_BUILD_PATH="${PWD}/live-build"
serial=$(date +%Y%m%d)
conf="${AB_D}/conf/${suite}"
source ${conf}.conf
build-ec2-image --serial=${serial} "${conf}.conf" "${dest}"
# Process nested configurations
[ -n "${extra_arches}" ] && {
for nested_conf in "${extra_arches}"
do
echo "Processing nested configuration file ${nested_conf}"
build-ec2-image --serial=${serial} "${AB_D}/conf/${nested_conf}" "${dest}"
done
}
|