1bf215546Sopenharmony_ci#!/bin/bash
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ciset -e
4bf215546Sopenharmony_ciset -o xtrace
5bf215546Sopenharmony_ci
6bf215546Sopenharmony_ci# Fetch the arm-built rootfs image and unpack it in our x86 container (saves
7bf215546Sopenharmony_ci# network transfer, disk usage, and runtime on test jobs)
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ciif wget -q --method=HEAD "${ARTIFACTS_PREFIX}/${FDO_UPSTREAM_REPO}/${ARTIFACTS_SUFFIX}/${arch}/done"; then
10bf215546Sopenharmony_ci  ARTIFACTS_URL="${ARTIFACTS_PREFIX}/${FDO_UPSTREAM_REPO}/${ARTIFACTS_SUFFIX}/${arch}"
11bf215546Sopenharmony_cielse
12bf215546Sopenharmony_ci  ARTIFACTS_URL="${ARTIFACTS_PREFIX}/${CI_PROJECT_PATH}/${ARTIFACTS_SUFFIX}/${arch}"
13bf215546Sopenharmony_cifi
14bf215546Sopenharmony_ci
15bf215546Sopenharmony_ciwget ${ARTIFACTS_URL}/lava-rootfs.tgz -O rootfs.tgz
16bf215546Sopenharmony_cimkdir -p /rootfs-$arch
17bf215546Sopenharmony_citar -C /rootfs-$arch '--exclude=./dev/*' -zxf rootfs.tgz
18bf215546Sopenharmony_cirm rootfs.tgz
19bf215546Sopenharmony_ci
20bf215546Sopenharmony_ciif [[ $arch == "arm64" ]]; then
21bf215546Sopenharmony_ci    mkdir -p /baremetal-files
22bf215546Sopenharmony_ci    pushd /baremetal-files
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci    wget ${ARTIFACTS_URL}/Image
25bf215546Sopenharmony_ci    wget ${ARTIFACTS_URL}/Image.gz
26bf215546Sopenharmony_ci    wget ${ARTIFACTS_URL}/cheza-kernel
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci    DEVICE_TREES=""
29bf215546Sopenharmony_ci    DEVICE_TREES="$DEVICE_TREES apq8016-sbc.dtb"
30bf215546Sopenharmony_ci    DEVICE_TREES="$DEVICE_TREES apq8096-db820c.dtb"
31bf215546Sopenharmony_ci    DEVICE_TREES="$DEVICE_TREES tegra210-p3450-0000.dtb"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci    for DTB in $DEVICE_TREES; do
34bf215546Sopenharmony_ci        wget ${ARTIFACTS_URL}/$DTB
35bf215546Sopenharmony_ci    done
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci    popd
38bf215546Sopenharmony_cielif [[ $arch == "armhf" ]]; then
39bf215546Sopenharmony_ci    mkdir -p /baremetal-files
40bf215546Sopenharmony_ci    pushd /baremetal-files
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci    wget ${ARTIFACTS_URL}/zImage
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci    DEVICE_TREES="imx6q-cubox-i.dtb"
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci    for DTB in $DEVICE_TREES; do
47bf215546Sopenharmony_ci        wget ${ARTIFACTS_URL}/$DTB
48bf215546Sopenharmony_ci    done
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci    popd
51bf215546Sopenharmony_cifi
52