fvp|juno_utils.sh: several changes on yaml generation

This is a collection of changes required in order to produce correct
yaml files which ultimatelly are consumed by LAVA on behalf of
Open CI jobs [1]. Changes are done on top of [2], with the aim of
keeping [2] intact (the revert) and clearly identifying those required
changes while implementing & testing [1].

[1] https://review.trustedfirmware.org/c/ci/tf-a-job-configs/+/6217
[2] https://review.trustedfirmware.org/c/ci/tf-a-ci-scripts/+/6223

Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Change-Id: I8506416ef66ba283b336c82208ffc07bf0b2dc3b
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 5fb2ae3..3987631 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -233,6 +233,8 @@
 gen_fvp_yaml() {
     local yaml_template_file="$workspace/fvp_template.yaml"
     local yaml_file="$workspace/fvp.yaml"
+    local job_file="$workspace/job.yaml"
+    lava_model_params="$workspace/lava_model_params"
 
     # this function expects a template, quit if it is not present
     if [ ! -f "$yaml_template_file" ]; then
@@ -265,9 +267,11 @@
 
     docker_name="${docker_registry}$container_name"
 
-    version_string="\"ARM ${model}"' [^\\n]+'"\""
+    # generic version string
+    local version_string="\"Fast Models"' [^\\n]+'"\""
 
-    sed -e "s|\${ACTIONS_DEPLOY_IMAGES_BL1}|${bl1}|" \
+    sed -e "s|\${ARMLMD_LICENSE_FILE}|${armlmd_license_file}|" \
+	-e "s|\${ACTIONS_DEPLOY_IMAGES_BL1}|${bl1}|" \
         -e "s|\${ACTIONS_DEPLOY_IMAGES_FIP}|${fip}|" \
         -e "s|\${ACTIONS_DEPLOY_IMAGES_DTB}|${dtb}|" \
         -e "s|\${ACTIONS_DEPLOY_IMAGES_IMAGE}|${image}|" \
@@ -280,16 +284,28 @@
         < "$yaml_template_file" \
         > "$yaml_file"
 
+    # LAVA expects 'macro' names for binaries, so replace them
+    sed -e "s|bl1.bin|{BL1}|" \
+	-e "s|fip.bin|{FIP}|" \
+	-e "s|kernel.bin|{IMAGE}|" \
+	-e "s|initrd.bin|{RAMDISK}|" \
+	< "$archive/model_params" \
+	> "$lava_model_params"
+
+
     # include the model parameters
     while read -r line; do
         if [ -n "$line" ]; then
 	    yaml_line="- \"${line}\""
             sed -i -e "/\${BOOT_ARGUMENTS}/i \ \ \ \ $yaml_line" "$yaml_file"
         fi
-    done < "$archive/model_params"
+    done < "$lava_model_params"
+
     sed -i -e '/\${BOOT_ARGUMENTS}/d' "$yaml_file"
+    cp "$yaml_file" "$job_file"
 
     archive_file "$yaml_file"
+    archive_file "$job_file"
 }
 
 docker_registry_append() {
diff --git a/juno_utils.sh b/juno_utils.sh
index 890f026..9fa1b0d 100644
--- a/juno_utils.sh
+++ b/juno_utils.sh
@@ -18,8 +18,8 @@
 juno32_recovery_root="$linaro_release/juno32-latest-busybox-uboot"
 juno32_recovery_root_oe="$linaro_release/juno32-latest-oe-uboot"
 
-juno_rootfs_url="$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz"
-juno32_rootfs_url="$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz"
+juno_rootfs_url="${juno_rootfs_url:-$linaro_release/linaro-image-minimal-genericarmv8-20170127-888.rootfs.tar.gz}"
+juno32_rootfs_url="${juno32_rootfs_url:-$linaro_release/linaro-image-alip-genericarmv7a-20150710-336.rootfs.tar.gz}"
 
 get_optee_bin() {
 	local tmpdir="$(mktempdir)"
@@ -85,13 +85,16 @@
 }
 
 gen_juno_yaml() {
-	local yaml_file="$workspace/juno.yaml"
+        local yaml_file="$workspace/juno.yaml"
+        local job_file="$workspace/job.yaml"
 	local payload_type="${payload_type:?}"
 
 	bin_mode="$mode" \
 		"$ci_root/script/gen_juno_${payload_type}_yaml.sh" > "$yaml_file"
 
+        cp "$yaml_file" "$job_file"
 	archive_file "$yaml_file"
+        archive_file "$job_file"
 }
 
 juno_aarch32_runtime() {
diff --git a/script/gen_fvp_linux_yaml.sh b/script/gen_fvp_linux_yaml.sh
index 7d4c1cf..f7cf188 100755
--- a/script/gen_fvp_linux_yaml.sh
+++ b/script/gen_fvp_linux_yaml.sh
@@ -48,6 +48,7 @@
 
 - boot:
     method: fvp
+    license_variable: ARMLMD_LICENSE_FILE=\${ARMLMD_LICENSE_FILE}
     docker:
       name: \${BOOT_DOCKER_NAME}
       local: true
diff --git a/script/gen_fvp_tftf_yaml.sh b/script/gen_fvp_tftf_yaml.sh
index 0c5693e..46563f9 100755
--- a/script/gen_fvp_tftf_yaml.sh
+++ b/script/gen_fvp_tftf_yaml.sh
@@ -46,6 +46,7 @@
 
 - boot:
     method: fvp
+    license_variable: ARMLMD_LICENSE_FILE=\${ARMLMD_LICENSE_FILE}
     docker:
       name: \${BOOT_DOCKER_NAME}
       local: true
diff --git a/script/gen_juno_linux_reboot_yaml.sh b/script/gen_juno_linux_reboot_yaml.sh
index 9690406..324f7f1 100755
--- a/script/gen_juno_linux_reboot_yaml.sh
+++ b/script/gen_juno_linux_reboot_yaml.sh
@@ -29,7 +29,7 @@
 
 bootloader_prompt="${bootloader_prompt:-juno#}"
 recovery_img_url="${recovery_img_url:-$(get_recovery_image_url)}"
-nfs_rootfs="${nfs_rootfs:-$juno_rootfs_url}"
+nfs_rootfs="${juno_rootfs_url:-$nfs_rootfs}"
 linux_prompt="${linux_prompt:-root@(.*):~#}"
 os="${os:-debian}"