#!/bin/bash
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

set -ex

main() {
  cd "$(dirname "$0")"

  local kokoro_simulator_root=/tmp/kokoro_simulator
  local src_root="${kokoro_simulator_root}"/git/crosvm
  local base_image_tarball="${kokoro_simulator_root}"/crosvm-base.tar.xz
  local base_image="crosvm-base"

  mkdir -p "${kokoro_simulator_root}"
  if [[ ! -e "${base_image_tarball}" ]]; then
    if [[ "$(docker images -q ${base_image} 2> /dev/null)" == "" ]]; then
      docker build -t ${base_image} - < Dockerfile
    fi
    docker save ${base_image} | xz -T 0 -z >"${base_image_tarball}"
  fi

  if [[ ! -e "${src_root}" ]]; then
    mkdir -p "${kokoro_simulator_root}"/git
    ln -s "$(realpath ../)" "${src_root}"
  fi

  export KOKORO_ARTIFACTS_DIR="${kokoro_simulator_root}"
  export KOKORO_GFILE_DIR="${kokoro_simulator_root}"

  ./build.sh
}

main "$@"

#!/bin/bash
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

set -ex

main() {
  cd "$(dirname "$0")"

  local kokoro_simulator_root=/tmp/kokoro_simulator
  local src_root="${kokoro_simulator_root}"/git/crosvm
  local base_image_tarball="${kokoro_simulator_root}"/crosvm-base.tar.xz
  local base_image="crosvm-base"

  mkdir -p "${kokoro_simulator_root}"
  if [[ ! -e "${base_image_tarball}" ]]; then
    if [[ "$(docker images -q ${base_image} 2> /dev/null)" == "" ]]; then
      docker build -t ${base_image} .
    fi
    docker save ${base_image} | xz -T 0 -z >"${base_image_tarball}"
  fi

  if [[ ! -e "${src_root}" ]]; then
    mkdir -p "${kokoro_simulator_root}"/git
    ln -s "$(realpath ../)" "${src_root}"
  fi

  export KOKORO_ARTIFACTS_DIR="${kokoro_simulator_root}"
  export KOKORO_GFILE_DIR="${kokoro_simulator_root}"

  ./build.sh
}

main "$@"

Fix docker build step in simulator script
kokoro: Fix docker build step in simulator script

The old command no longer works as of CL:1419397 because the pkgconfig
path in COPY needs to be interpreted relative to the Dockerfile path.
The kokoro/README.md instructions were updated in CL:1431356 but the
simulator script was not.

Patch received via email from Gabriel <g2p.code@gmail.com>.
https://github.com/g2p/crosvm/commit/0e6bb00b90d5ee3c002fc95a22217afe90fe0c52

TEST=run kokoro simulator

Change-Id: I09d556cab9a4c1942098e0796e39e221f365c3af
Reviewed-on: https://chromium-review.googlesource.com/1513497
Commit-Ready: ChromeOS CL Exonerator Bot <fa429e5907f00867f797423aea74327bb02c91b6@appspot.gserviceaccount.com>
Tested-by: David Tolnay <1480464b87745a0822a0e8b7545ca981d8e7352e@chromium.org>
Tested-by: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Stephen Barber <7719587e4b5a49340661b214ec85602f3918d06f@chromium.org>
