-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
199 lines (179 loc) · 6.56 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
VM_NAME := CoreOS Packer
BOX_NAME := CoreOS Box
VERSION_ID := 1.2.9
BUILD_ID := `date -u '+%Y-%m-%d-%H%M'`
CHANNEL := master
PWD := `pwd`
box: coreos.box
disk: tmp/CoreOS.vmdk
coreos.box: tmp/CoreOS.vmdk box/change_host_name.rb box/configure_networks.rb box/vagrantfile.tpl
vagrant halt -f
#
# Clone
#
-VBoxManage unregistervm "${BOX_NAME}" --delete
VBoxManage clonevm "${VM_NAME}" --name "${BOX_NAME}" --register
#
# Clean up
#
VBoxManage storageattach "${BOX_NAME}" --storagectl "IDE Controller" --port 0 --device 0 --medium none
VBoxManage storageattach "${BOX_NAME}" --storagectl "IDE Controller" --port 1 --device 0 --medium none
VBoxManage storageattach "${BOX_NAME}" --storagectl "SATA Controller" --port 1 --device 0 --medium none
VBoxManage storageattach "${BOX_NAME}" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "${HOME}/VirtualBox VMs/${BOX_NAME}/${BOX_NAME}-disk2.vmdk"
VBoxManage closemedium disk "${HOME}/VirtualBox VMs/${BOX_NAME}/${BOX_NAME}-disk1.vmdk" --delete
VBoxManage modifyvm "${BOX_NAME}" --ostype Linux26_64
#
# Package
#
rm -f coreos.box
cd box; \
vagrant package --base "${BOX_NAME}" --output ../coreos.box --include change_host_name.rb,configure_networks.rb --vagrantfile vagrantfile.tpl
VBoxManage unregistervm "${BOX_NAME}" --delete
tmp/CoreOS.vmdk: Vagrantfile oem/coreos-setup-environment oem/motd oem/motdgen \
tmp/coreos-install tmp/cloud-config.yml tmp/docker-enter
vagrant destroy -f
VM_NAME="${VM_NAME}" vagrant up --no-provision
CHANNEL="${CHANNEL}" vagrant provision
vagrant suspend
parallels: coreos-parallels.box
coreos-parallels.box: tmp/CoreOS.vmdk parallels/metadata.json parallels/change_host_name.rb parallels/configure_networks.rb parallels/Vagrantfile
vagrant halt -f
#
# Convert VMDK to HDD
#
rm -rf "${HOME}/Documents/Parallels/CoreOS.hdd"
-prl_convert tmp/CoreOS.vmdk --allow-no-os
#
# Create Parallels VM
#
-prlctl unregister "${VM_NAME}"
rm -rf "${HOME}/Documents/Parallels/${VM_NAME}.pvm"
prlctl create "${VM_NAME}" --ostype linux --distribution linux-2.6 --no-hdd
mv "${HOME}/Documents/Parallels/CoreOS.hdd" "${HOME}/Documents/Parallels/${VM_NAME}.pvm/"
prlctl set "${VM_NAME}" --device-add hdd --image "${HOME}/Documents/Parallels/${VM_NAME}.pvm/CoreOS.hdd"
prlctl set "${VM_NAME}" --device-bootorder "hdd0 cdrom0"
#
# Clone
#
-prlctl unregister "${BOX_NAME}"
rm -rf "Parallels/${BOX_NAME}.pvm"
prlctl clone "${VM_NAME}" --name "${BOX_NAME}" --template --dst "${PWD}/parallels"
prlctl unregister "${VM_NAME}"
rm -rf "${HOME}/Documents/Parallels/${VM_NAME}.pvm"
#
# Clean up
#
rm -f "parallels/${BOX_NAME}.pvm/config.pvs.backup"
rm -f "parallels/${BOX_NAME}.pvm/CoreOS.hdd/DiskDescriptor.xml.Backup"
#
# Package
#
rm -f coreos-parallels.box
cd parallels; tar zcvf ../coreos-parallels.box *
prlctl unregister "${BOX_NAME}"
parallels/metadata.json:
mkdir -p parallels
echo '{"provider": "parallels"}' > parallels/metadata.json
parallels/change_host_name.rb: box/change_host_name.rb
mkdir -p parallels
cp box/change_host_name.rb parallels/change_host_name.rb
parallels/configure_networks.rb: box/configure_networks.rb
mkdir -p parallels
cp box/configure_networks.rb parallels/configure_networks.rb
parallels/Vagrantfile: box/vagrantfile.tpl
mkdir -p parallels
cp box/vagrantfile.tpl parallels/Vagrantfile
tmp/coreos-install:
mkdir -p tmp
ifneq ($(CHANNEL),master)
cp oem/coreos-install tmp/coreos-install
else
cp oem/coreos-install.dev tmp/coreos-install
endif
tmp/cloud-config.yml: oem/cloud-config.yml
mkdir -p tmp
sed -e "s/%VERSION_ID%/${VERSION_ID}/g" -e "s/%BUILD_ID%/${BUILD_ID}/g" oem/cloud-config.yml > tmp/cloud-config.yml
tmp/docker-enter:
curl -L https://raw.githubusercontent.com/YungSang/docker-attach/master/docker-nsenter -o tmp/docker-enter
chmod +x tmp/docker-enter
test: test/Vagrantfile coreos.box
@vagrant box add -f coreos coreos.box
@cd test; \
vagrant destroy -f; \
vagrant up; \
echo "-----> docker version"; \
DOCKER_HOST="tcp://localhost:2375"; \
docker version; \
echo "-----> docker images -t"; \
docker images -t; \
echo "-----> docker ps -a"; \
docker ps -a; \
echo "-----> nc localhost 8080"; \
nc localhost 8080; \
echo "-----> /etc/os-release"; \
vagrant ssh -c "cat /etc/os-release"; \
echo "-----> /etc/oem-release"; \
vagrant ssh -c "cat /etc/oem-release"; \
echo "-----> /etc/machine-id"; \
vagrant ssh -c "cat /etc/machine-id"; \
echo "-----> /etc/hostname"; \
vagrant ssh -c "cat /etc/hostname"; \
echo "-----> /etc/environment"; \
vagrant ssh -c "cat /etc/environment"; \
echo "-----> /etc/systemd/network/50-vagrant*.network"; \
vagrant ssh -c "cat /etc/systemd/network/50-vagrant*.network"; \
echo "-----> route"; \
vagrant ssh -c "route"; \
echo "-----> systemctl list-units"; \
vagrant ssh -c "systemctl list-units --no-pager"; \
echo '-----> docker-enter `docker ps -l -q` ls -l'; \
vagrant ssh -c 'docker-enter `docker ps -l -q` ls -l'; \
echo '-----> docker exec `docker ps -l -q` ls -l'; \
docker exec `docker ps -l -q` ls -l; \
vagrant suspend
ptest: DOCKER_HOST_IP=$(shell cd test; vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp")
ptest: ptestup
@cd test; \
echo "-----> docker version"; \
DOCKER_HOST="tcp://${DOCKER_HOST_IP}:2375"; \
docker version; \
echo "-----> docker images -t"; \
docker images -t; \
echo "-----> docker ps -a"; \
docker ps -a; \
echo "-----> nc ${DOCKER_HOST_IP} 8080"; \
nc ${DOCKER_HOST_IP} 8080; \
echo "-----> /etc/os-release"; \
vagrant ssh -c "cat /etc/os-release"; \
echo "-----> /etc/oem-release"; \
vagrant ssh -c "cat /etc/oem-release"; \
echo "-----> /etc/machine-id"; \
vagrant ssh -c "cat /etc/machine-id"; \
echo "-----> /etc/hostname"; \
vagrant ssh -c "cat /etc/hostname"; \
echo "-----> /etc/environment"; \
vagrant ssh -c "cat /etc/environment"; \
echo "-----> /etc/systemd/network/50-vagrant*.network"; \
vagrant ssh -c "cat /etc/systemd/network/50-vagrant*.network"; \
echo "-----> route"; \
vagrant ssh -c "route"; \
echo "-----> systemctl list-units"; \
vagrant ssh -c "systemctl list-units --no-pager"; \
echo '-----> docker-enter `docker ps -l -q` ls -l'; \
vagrant ssh -c 'docker-enter `docker ps -l -q` ls -l'; \
echo '-----> docker exec `docker ps -l -q` ls -l'; \
docker exec `docker ps -l -q` ls -l; \
vagrant suspend
ptestup: test/Vagrantfile coreos-parallels.box
@vagrant box add -f coreos coreos-parallels.box --provider parallels
@cd test; \
vagrant destroy -f; \
vagrant up --provider parallels; \
clean:
vagrant destroy -f
cd test; vagrant destroy -f
rm -f coreos.box
rm -rf tmp/
rm -f coreos-parallels.box
rm -rf parallels/
.PHONY: box test clean