[buildout]
parts =
  parameters
  modify-image-script
  template-full-build-script

# eggs given by software.cfg
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}

#################################### Tools, sources getter ##################################

[clone-depot-tools]
# needed for the "repo" command (to download many git repositories)
recipe = slapos.recipe.build:gitclone
repository = https://chromium.googlesource.com/chromium/tools/depot_tools.git
branch = master

[depot-tools]
export-path =
  export PATH=${clone-depot-tools:location}:"$PATH";

############################################################################################

[parameters]
# for use of the "parameters" XML configuration given from the
# webrunner interface
# if needed, .serialized => json (more complex structures are OK, but need another 
# jinja template for reading the content of the parameters)
recipe = slapos.cookbook:slapconfiguration
computer = ${slap_connection:computer_id}
partition = ${slap_connection:partition_id}
url = ${slap_connection:server_url}
key = ${slap_connection:key_file}
cert = ${slap_connection:cert_file}

[directory]
recipe = slapos.cookbook:mkdirectory
log = ${buildout:directory}/var/log
run = ${buildout:directory}/etc/run
cros_location = ${buildout:directory}/parts/chromiumos


[template-full-build-script]
# create the instance.cfg file in the buildout directory
# (use jinja for templating)
recipe = slapos.recipe.template:jinja2
template = {{ scripts_dir }}/cros_full_build.sh.in
rendered = ${directory:run}/cros_full_build.sh
# md5sum = 
mode = 0770
context =
# for access to the eggs from the instance
  key instance_log_dir directory:log
  key cros_location directory:cros_location
  key depot_tools_export_path_cmd depot-tools:export-path
  key branch parameters:configuration.branch
  key boards_list parameters:configuration.boards

[modify-image-script]
# create the script that will modify the image after the build
recipe = slapos.recipe.template:jinja2
template = {{ scripts_dir }}/modify_image.sh.in
rendered = ${directory:cros_location}/src/scripts/modify_image.sh
mode = 0770
commands = sudo rm /tmp/m/etc/init/openssh-server.conf
           sudo emerge-$${BOARD} --root=/tmp/m --root-deps=rdeps --usepkgonly git
context =
  key board parameters:configuration.boards
  key commands :commands