This repository has been archived by the owner on May 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (56 loc) · 2.05 KB
/
Makefile
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
# Copyright 2014 Joonas Kuorilehto
#################################################
## ORIGINAL OFFICIAL IMAGES
dist/trusty-server-cloudimg-amd64-disk1.img:
mkdir -p dist
wget -O $@ https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
# Fedora
dist/Fedora-x86_64-20-20140407-sda.qcow2:
mkdir -p dist
wget -O $@ http://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.qcow2
(cd dist && \
echo "ffd240c32b676179608e50d8640fcd1ac6b9bb67f1486c703c47b51dc52daf2f *Fedora-x86_64-20-20140407-sda.qcow2" \
| shasum -c)
#################################################
## Unpack and expand
# Ubuntu
ubuntu-trusty-amd64-10GB-root.qcow2: dist/trusty-server-cloudimg-amd64-disk1.img
qemu-img convert -O qcow2 $< $@
qemu-img resize $@ +8G
fedora-fc20-amd64-root.qcow2: dist/Fedora-x86_64-20-20140407-sda.qcow2
qemu-img convert -O qcow2 $< $@
qemu-img resize $@ +8G
#################################################
## Clone template to root filesystem
%-ubuntu-disk1.qcow2: ubuntu-trusty-amd64-10GB-root.qcow2
qemu-img create -f qcow2 -b $< $@
%-fc20-disk1.qcow2: fedora-fc20-amd64-root.qcow2
qemu-img create -f qcow2 -b $< $@
#################################################
## Create user-data image
%-seed.img: %.user-data
cloud-localds $@ $<
#################################################
# Define vm to libvirt
# Ubuntu
ubuntu-%: %-ubuntu-disk1.qcow2 %-seed.img
virt-install --nographics --noreboot \
--name $* \
--ram 768 \
--disk path=$<,format=qcow2 \
--cdrom $*-seed.img \
--boot=hd --livecd \
--bridge=br0 -m `python ./mac-generator.py $*` \
|| true
fc20-%: %-fc20-disk1.qcow2 %-seed.img
virt-install --nographics --noreboot \
--name $* \
--ram 1024 \
--disk path=$<,format=qcow2 \
--cdrom $*-seed.img \
--boot=hd --livecd \
--bridge=br0 -m `python ./mac-generator.py $*` \
|| true
# Do not remove image files as "intermediate files"
.PRECIOUS: %-ubuntu-disk1.qcow2 %-seed.img %-fc20-disk1.qcow2
#################################################