[sonic_debian_extension] fix packages.json generation and make the build fail when packages.json is not generated (#8044)

After https://github.com/Azure/sonic-buildimage/pull/7598 the packages.json generation is broken. This change fixes it make the whole build fail in case generation failed.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
This commit is contained in:
Stepan Blyshchak 2021-07-09 22:29:33 +03:00 committed by GitHub
parent 31c5797015
commit a294bfb03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,12 @@
{%- set docker_installation_targets = [] -%}
{%- for docker_installation_target in installer_images.strip().split() -%}
{%- set pkgname, docker_build_path, machine, image = docker_installation_target.split('|') -%}
{%- if not machine or (machine and machine == target_machine) -%}
{%- set _ = docker_installation_targets.append((pkgname, image)) -%}
{%- endif -%}
{%- endfor -%}
{
{% for docker_installation_target in installer_images.strip().split() -%}
{% set pkgname, docker_build_path, image = docker_installation_target.split('|') -%}
{% for pkgname, image in docker_installation_targets -%}
{% set imagefilepath = image.split(':')|first -%}
{% set imageversion = image.split(':')|last -%}
{% set imagefilename = imagefilepath.split('/')|last -%}

View File

@ -667,7 +667,11 @@ fi
SONIC_PACKAGE_MANAGER_FOLDER="/var/lib/sonic-package-manager/"
sudo mkdir -p $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER
j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json
target_machine="$TARGET_MACHINE" j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json
if [ "${PIPESTATUS[0]}" != "0" ]; then
echo "Failed to generate packages.json" >&2
exit 1
fi
# Copy docker_image_ctl.j2 for SONiC Package Manager
sudo cp $BUILD_TEMPLATES/docker_image_ctl.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/docker_image_ctl.j2