6
# Read in the common files
7
source "${kvm}/functions/common"
8
source "${kvm}/functions/retry"
10
# Apply the build stuff
11
find . -iname "*build_properties" | xargs -I FILE cp FILE .
12
[ -e "build_properties" ] &&
13
source build_properties ||
14
fail "Failed to read build_properties. I don't know what I'm doing!"
16
rm {failed,success} || /bin/true
18
# Copy the target disk image
19
disk_orig="${SUITE}-server-cloudimg-${ARCH}-disk1.img"
20
disk_cp="${disk_orig//cloudimg/cloudimg-sce}"
21
disk_root="/srv/ec2-images/${SUITE}/${SERIAL:-current}"
22
disk_working="${WORKSPACE}/${disk_cp}.tmp"
23
disk_final="${WORKSPACE}/${disk_cp}"
24
raw_f="${WORKSPACE}/raw_f-$(date +%s).img"
26
cp "${disk_root}/${disk_orig}" "${disk_working}" ||
27
fail "Unable to copy ${disk_orig} from ${disk_root}"
29
# Launch KVM to do the work
30
${kvm}/launch_kvm.sh \
31
--id "${ARCH}-${BUILD_ID}" \
32
--user-data "${kvm}/config/cloud-vps.cfg" \
33
--cloud-config "${kvm}/templates/img-smartcloud.tmpl" \
34
--extra-disk "${disk_working}" \
36
--raw-disk "${raw_f}" \
38
--img-url /srv/builder/images/precise-builder-latest.img ||
39
fail "KVM instance failed to build image."
42
rm "${raw_f}" || /bin/true
45
qemu-img convert -O raw "${disk_working}" "${disk_final}" ||
46
fail "Failed to convert disk to raw format"
49
rm "${disk_working}" ||
53
gzip "${disk_final}" ||
54
fail "Failed to compress ${disk_final}"
56
cp ${WORKSPACE}/packages.log ${disk_final}.packages