blob: 1607ddf2142d52aea8c556b48b7300c90ef47e21 [file] [log] [blame]
# Copyright 2020 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.
# Populates a directory with everything necessary to build a remote test driver
# container.
readonly script_dir="$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
. "${script_dir}/" || exit 1
# Script must run inside the chroot
assert_inside_chroot "$@"
# Do not run as root
DEFINE_string output_dir "" "Dir in which to put Dockerfile and dependencies"
# Parse command line flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
# Only now can we die on error. shflags functions leak non-zero error codes,
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
if [[ -z "${FLAGS_output_dir}" ]]; then
info "No --output_dir provided. Using temp dir instead"
output_dir=$(mktemp -d)
if [[ ! -d "${output_dir}" ]]; then
error "output_dir ${output_dir} must exist as a directory"
exit 1
if [[ -n "$(ls -A "${output_dir}")" ]]; then
error "output_dir ${output_dir} must be empty"
exit 1
# Write out a simple Dockerfile.
cat > "${output_dir}/Dockerfile" <<- EOF
FROM ubuntu:bionic
WORKDIR /usr/src/rtd/
COPY rtd/ .
# Create the remote test driver folder and copy test content into it.
mkdir "${rtd_dir}"
# Build and copy the tnull (fake) RTD.
sudo emerge tnull
cp /usr/bin/tnull "${rtd_dir}/"
# tast and tauto entries will eventually go here.
info "Done. Wrote output to ${output_dir}"