aboutsummaryrefslogtreecommitdiffstats
path: root/packer/provision/agl_dependencies.sh
blob: 3f4fe7e0998902190c5b912fbb7ee0c28a7277c3 (plain)
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
# vim: sw=2 ts=2 sts=2 et :

set -x

cat /etc/apt/sources.list

# Make sure that we aren't using the vexxhost mirrors as they have issues
echo "---> Removing Vexxhost Ubuntu mirrors"
sed -i 's/ubuntu.mirror.vexxhost.com/us.archive.ubuntu.com/g' /etc/apt/sources.list

cat /etc/apt/sources.list

DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y -u dist-upgrade

DEBIAN_FRONTEND=noninteractive apt-get update && \
    apt-get -y install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat \
                       libsdl1.2-dev xterm make xsltproc docbook-utils fop dblatex xmlto autoconf automake \
                       libtool libglib2.0-dev libarchive-dev python-git git python python-minimal repo \
                       tree rsync python-yaml python-requests curl tar docker pandoc python3 \
                       ruby-all-dev ruby-ffi ruby-ffi-* jekyll ruby-redcarpet npm mkdocs nodejs


# we have a build blocker wrt useradd - I assume it is caused by /bin/sh being dash
# systemd: Performing useradd with
echo "dash dash/sh boolean false" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

cat <<EOFHOSTS >> /etc/hosts

# workaround for download-new
199.19.213.77 download-new.automotivelinux.org
10.30.72.8 download-internal.automotivelinux.org

EOFHOSTS


cat <<EOFSYSCTL >> /etc/sysctl.conf
# we have a lot of make jobs, this helps a lot
kernel.sched_child_runs_first = 1
# smooth over a lot of I/O requests and do less blocking
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 20
vm.dirty_expire_centisecs = 4320000
vm.dirtytime_expire_seconds = 432000
vm.dirty_bytes = 0
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 0


EOFSYSCTL

### webdocs
mkdir -p /opt/AGL
cd /opt/AGL/
mkdir webdocs
cd webdocs
git clone http://github.com/iotbzh/webdocs-tools
git clone http://github.com/iotbzh/webdocs-sample
cd ./webdocs-tools
npm install

### hope that is enough

# clone lava-boot to /opt/AGL/
mkdir -p /opt/AGL/
cd /opt/AGL/
git clone http://git.linaro.org/people/riku.voipio/lava-boot.git
cd lava-boot
sed -i '16iimport ssl' lava-boot
sed -i '17issl._create_default_https_context = ssl._create_unverified_context' lava-boot
sed -i -e 's#"~/.lava.yaml"#"/opt/AGL/lava-agl/lava.yaml"#' lava-boot


# AGL specific lab integration. To be moved into git repo and cloned or the like.
#################################################################################
mkdir -p /opt/AGL/lava-agl/
cat <<EOFBR >> /opt/AGL/lava-agl/boardready.py
#!/usr/bin/python
import xmlrpclib
import ssl
import sys
import time

# bug, ssl chain cannot be verified (letsencrypt)
# to be fixed
ssl._create_default_https_context = ssl._create_unverified_context

username = "$LAVAUSER"
token = "$LAVATOKEN"
myhostname = "$LAVAHOST"

print "Starting ..."
sys.stdout.flush()
arg = None
if len(sys.argv) > 1:
        arg = sys.argv[1]

if arg == None:
        print("No argument, need lava jobnumber as argument.")
        sys.stdout.flush()
        sys.exit(1)

server = xmlrpclib.ServerProxy("https://%s:%s@%s/RPC2" % (username, token, myhostname))
#print(arg)
#sys.stdout.flush()

# Poll loop
while True:
        try:
            x = server.scheduler.job_status(arg)['job_status']
        except:
            print("Error, quitting.")
            sys.stdout.flush()
            sys.exit(1)
            break
        if 'Cancelled' in x:
                sys.exit(1)
                break
        if 'Submitted' in x:
                print("Job submitted - pending")
                sys.stdout.flush()
                time.sleep(20)
                continue
        if 'Running' in x:
                print("Job Running now.")
                print("Remote boot takes around 5 minutes to complete (download+boot) - waiting ...")
                sys.stdout.flush()
                time.sleep(300)
                y = server.scheduler.job_status(arg)['job_status']
                if 'Running' in y:
                        break
                else:
                        continue
                break
        break
# end
EOFBR

cat <<EOFLAVAYAML > /opt/AGL/lava-agl/.lava.yaml
server: ${LAVAHOST}
user: ${LAVAUSER}
token: ${LAVATOKEN}
https: true
EOFLAVAYAML

cat <<EOFPORTERUPLOADYAML > /opt/AGL/lava-agl/porter_nbd_upload.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'http://localhost/porter/upload/\${KERNELIMAGE}'
          nbdroot: 'http://localhost/porter/upload/\${ROOTFSTOBOOT}'
          ramdisk: 'http://localhost/porter/upload/\${NETBOOTIMAGE}'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
    - command: lava_command_run
      parameters:
          commands:
              - "while test ! -f /jta.done ; do echo \"Waiting for JTA to finish ... \" ; sleep 20 ; done"
          timeout: 22100
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600

EOFPORTERUPLOADYAML

cat <<EOFPORTERUPLOADYAML1 > /opt/AGL/lava-agl/porter_nbd_upload_stress.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'http://localhost/porter/upload/\${KERNELIMAGE}'
          nbdroot: 'http://localhost/porter/upload/\${ROOTFSTOBOOT}'
          ramdisk: 'http://localhost/porter/upload/\${NETBOOTIMAGE}'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
    - command: lava_command_run
      parameters:
          commands:
              - "stress -v -t 120 -c 1 -m 1 -i 1 "
          timeout: 300
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600

EOFPORTERUPLOADYAML1

cat <<EOFPORTERUPLOADYAML1 > /opt/AGL/lava-agl/porter_nbd_upload_simple.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'http://localhost/porter/upload/\${KERNELIMAGE}'
          nbdroot: 'http://localhost/porter/upload/\${ROOTFSTOBOOT}'
          ramdisk: 'http://localhost/porter/upload/\${NETBOOTIMAGE}'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600

EOFPORTERUPLOADYAML1

cat <<EOFPORTERSNAPYAML > /opt/AGL/lava-agl/porter_nbd_snapshot.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/uImage+dtb'
          nbdroot: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/core-image-minimal-porter.ext4'
          ramdisk: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/initramfs-netboot-image-porter.ext4.gz.u-boot'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
    - command: lava_command_run
      parameters:
          commands:
              - "while test ! -f /jta.done ; do echo \"Waiting for JTA to finish ... \" ; sleep 20 ; done"
          timeout: 22100
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600
EOFPORTERSNAPYAML

cat <<EOFPORTERSNAPYAML1 > /opt/AGL/lava-agl/porter_nbd_snapshot_stress.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/uImage+dtb'
          nbdroot: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/core-image-minimal-porter.ext4'
          ramdisk: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/initramfs-netboot-image-porter.ext4.gz.u-boot'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600
EOFPORTERSNAPYAML1

cat <<EOFPORTERSNAPYAML1 > /opt/AGL/lava-agl/porter_nbd_snapshot_simple.yaml
actions:
    - command: deploy_linaro_kernel
      parameters:
          kernel: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/uImage+dtb'
          nbdroot: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/core-image-minimal-porter.ext4'
          ramdisk: 'https://download.automotivelinux.org/AGL/snapshots/master/latest/porter-nogfx/deploy/images/porter/initramfs-netboot-image-porter.ext4.gz.u-boot'
          login_prompt: 'porter login:'
          username: 'root'
    - command: boot_linaro_image
      parameters:
          test_image_prompt: 'root@porter:~#'
device_type: 'renesas-porter'
logging_level: INFO
job_name: '\${JOB_NAME}'
timeout: 22600
EOFPORTERSNAPYAML1


cat <<EOFUPLOAD > /opt/AGL/lava-agl/upload4lava.sh
#!/bin/bash
#set -x

if test x"" != x"\$1"; then
Y=\$(echo "\$1" | sed -e "s#\.\.##g" -e "s#/##g")
curl -T "\$Y" https://porter.automotivelinux.org/porter/upload/\$Y --insecure
else
echo "Help: \$0 file"
fi

EOFUPLOAD

cat <<EOFDELETE > /opt/AGL/lava-agl/delete4lava.sh
#!/bin/bash
#set -x

if test x"" != x"\$1"; then
Y=\$(echo "\$1" | sed -e "s#\.\.##g" -e "s#/##g")
curl -X DELETE https://porter.automotivelinux.org/porter/upload/\$Y --insecure
else
echo "Help: \$0 file"
fi

EOFDELETE

cat <<EOFDEPLOY > /opt/AGL/lava-agl/deploy.sh
#!/bin/bash
#set -x
set -e
PORTERYAML="porter_nbd_snapshot.yaml"

if test x"" != x"\$1" ; then
    PORTERYAML="\$1"
fi
if test -f /opt/AGL/lava-agl/\${PORTERYAML}; then
    /opt/AGL/lava-agl/boardready.py \$(/opt/AGL/lava-boot/lava-boot -j /opt/AGL/lava-agl/\${PORTERYAML} -a -q | sed -e "s#.*job/##g")
else
    echo "\${PORTERYAML} not found."
    exit 1
fi
EOFDEPLOY

chmod a+x /opt/AGL/lava-agl/*