Skip to content

Commit 1bfb597

Browse files
stepanblyschakCarl Keene
authored andcommitted
[sonic_debian_extension] fix packages.json generation and make the build fail when packages.json is not generated (sonic-net#8044)
After sonic-net#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 <[email protected]>
1 parent 2fd4936 commit 1bfb597

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

files/build_templates/packages.json.j2

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
{%- set docker_installation_targets = [] -%}
2+
{%- for docker_installation_target in installer_images.strip().split() -%}
3+
{%- set pkgname, docker_build_path, machine, image = docker_installation_target.split('|') -%}
4+
{%- if not machine or (machine and machine == target_machine) -%}
5+
{%- set _ = docker_installation_targets.append((pkgname, image)) -%}
6+
{%- endif -%}
7+
{%- endfor -%}
18
{
2-
{% for docker_installation_target in installer_images.strip().split() -%}
3-
{% set pkgname, docker_build_path, image = docker_installation_target.split('|') -%}
9+
{% for pkgname, image in docker_installation_targets -%}
410
{% set imagefilepath = image.split(':')|first -%}
511
{% set imageversion = image.split(':')|last -%}
612
{% set imagefilename = imagefilepath.split('/')|last -%}

files/build_templates/sonic_debian_extension.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,11 @@ fi
667667

668668
SONIC_PACKAGE_MANAGER_FOLDER="/var/lib/sonic-package-manager/"
669669
sudo mkdir -p $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER
670-
j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json
670+
target_machine="$TARGET_MACHINE" j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json
671+
if [ "${PIPESTATUS[0]}" != "0" ]; then
672+
echo "Failed to generate packages.json" >&2
673+
exit 1
674+
fi
671675

672676
# Copy docker_image_ctl.j2 for SONiC Package Manager
673677
sudo cp $BUILD_TEMPLATES/docker_image_ctl.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/docker_image_ctl.j2

0 commit comments

Comments
 (0)