forked from gasolin/foxbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
276 lines (245 loc) · 12.4 KB
/
Vagrantfile
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# -*- mode: ruby -*-
# vi: set ft=ruby :
# To use this script and prepare your build environment, run the following
# command in the same directory as the Vagrantfile.
# B2G_PATH={path to your B2G directory} vagrant up
VAGRANTFILE_API_VERSION = "2"
# This script will be run on the first start and it will set up the build
# environment.
# All you need to do afterwards is:
# * vagrant ssh
# * Unplug/Plug the phone; run `adb devices` to make sure that the phone is
# listed.
# * cd B2G
# * ./configure.sh {your device}
# * ./build.sh
$bootstrap = <<SCRIPT
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Installing all build prerequisites "
apt-get update
# add firefox nightly repo
apt-get install python-software-properties -y
add-apt-repository ppa:ubuntu-mozilla-daily/ppa -y
apt-get update
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Install git and repo "
apt-get install -y git-core
if [ -f /bin/repo ]
then
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /bin/repo
chmod a+x /bin/repo
fi
echo " Install prerequisite libraries "
add-apt-repository -y ppa:nilarimogard/webupd8
apt-get update
apt-get install -y autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev libasound2 make zip android-tools-adb
# Set ccache max size to 3GB
ccache --max-size 3GB
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Set the permission filters to the right devices "
# Source http://developer.android.com/tools/device.html
if [ -f /etc/udev/rules.d/51-android.rules ]
then
rm /etc/udev/rules.d/51-android.rules
fi
cat <<EOF >> /etc/udev/rules.d/51-android.rules
#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="vagrant"
#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="vagrant"
#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="vagrant"
#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="vagrant"
#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="vagrant"
#Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="vagrant"
#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="vagrant"
#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="vagrant"
#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="vagrant"
#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="vagrant"
#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="vagrant"
#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666", GROUP="vagrant"
#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="vagrant"
#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="vagrant"
#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="vagrant"
#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="vagrant"
#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="vagrant"
#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666", GROUP="vagrant"
#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666", GROUP="vagrant"
#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="vagrant"
#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="vagrant"
#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", GROUP="vagrant"
#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="vagrant"
#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="vagrant"
#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="vagrant"
#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="vagrant"
#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="vagrant"
EOF
chmod a+r /etc/udev/rules.d/51-android.rules
service udev restart
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Install Java "
# Not sure if it's necessary but the build complaints about the Java version.
apt-get purge -y openjdk*
add-apt-repository -y ppa:webupd8team/java
apt-get update
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
apt-get install -y oracle-java7-installer
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Enable GUI "
#apt-get install -y x-window-system gnome-core
# xorg xfce4 menu
apt-get install -y x-window-system xfce4
# get firefox nightly
apt-get install -y firefox-trunk
# clean all unrequired packages
apt-get autoremove -y
echo "███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗"
echo "██╔════╝██╔═══██╗╚██╗██╔╝██╔══██╗██╔═══██╗╚██╗██╔╝"
echo "█████╗ ██║ ██║ ╚███╔╝ ██████╔╝██║ ██║ ╚███╔╝ "
echo "██╔══╝ ██║ ██║ ██╔██╗ ██╔══██╗██║ ██║ ██╔██╗ "
echo "██║ ╚██████╔╝██╔╝ ██╗██████╔╝╚██████╔╝██╔╝ ██╗"
echo "╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
echo " Create helper scripts "
echo " Create 'gui.sh' to start GUI "
echo "sudo startxfce4&" > gui.sh
chmod a+x gui.sh
echo " Create 'init_B2G.sh to fetch B2G repository "
echo "#!/bin/bash
if [ -d B2G/.git ]
then
echo "The git directory exists."
echo "update B2G repository"
cd B2G
git pull
cd ..
else
rm B2G/README.md
# purge mac temp
rm B2G/.DS_Store
echo "clone B2G repository"
git clone https://github.com/mozilla-b2g/B2G.git B2G
fi" > init_B2G.sh
chmod a+x init_B2G.sh
echo " Create 'init_gaia.sh' to fetch gaia source "
echo "#!/bin/bash
if [ -d gaia/.git ]
then
echo "The git directory exists."
echo "update gaia repository"
cd gaia
gaia pull
cd ..
else
rm gaia/README.md
# purge mac temp
rm gaia/.DS_Store
echo "clone gaia repository"
git clone https://github.com/mozilla-b2g/gaia.git gaia
fi" > init_gaia.sh
chmod a+x init_gaia.sh
# Vagrant script
SCRIPT
# Detect if B2G_PATH is exist
if (defined?(ENV['B2G_PATH'])).nil?
B2G_PATH = nil
else
B2G_PATH = ENV['B2G_PATH']
end
# Detect if GECKO_PATH is exist
if (defined?(ENV['GECKO_PATH'])).nil?
GECKO_PATH = nil
else
GECKO_PATH = ENV['GECKO_PATH']
end
# Detect if GAIA_PATH is exist
if (defined?(ENV['GAIA_PATH'])).nil?
GAIA_PATH = nil
else
GAIA_PATH = ENV['GAIA_PATH']
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
# Run the bootsrap script on start.
config.vm.provision "shell", inline: $bootstrap
# Use ubuntu 12.04
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# Assign static IP to be able to use nfs option (if you have a conflict,
# change it to something else).
config.vm.network "private_network", ip: "192.168.50.4"
# Use *_PATH environment variable to sync with vm's /home/vagrant/*
# directory.
if (B2G_PATH != nil)
config.vm.synced_folder B2G_PATH, "/home/vagrant/B2G", nfs: true
end
if (GECKO_PATH != nil)
config.vm.synced_folder GECKO_PATH, "/home/vagrant/gecko", nfs: true
end
if (GAIA_PATH != nil)
config.vm.synced_folder GAIA_PATH, "/home/vagrant/gaia", nfs: true
end
config.vm.provider "virtualbox" do |v|
# Enable GUI
v.gui = true
# Enable 4GB of RAM
v.customize ["modifyvm", :id, "--memory", "4096"]
# Enable usb
v.customize ["modifyvm", :id, "--usb", "on"]
# Filter the following devices: inari, keon, android
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'android', '--vendorid', '0x18d1']
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'foxconn', '--vendorid', '0x0489']
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'hwawei', '--vendorid', '0x12d1']
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'lg', '--vendorid', '0x1004']
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'qualcomm', '--vendorid', '0x05c6']
v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'zte', '--vendorid', '0x19d2']
end
end