diff --git a/files/build_templates/packages.json.j2 b/files/build_templates/packages.json.j2 index 3c0d103403..3c44abb70a 100644 --- a/files/build_templates/packages.json.j2 +++ b/files/build_templates/packages.json.j2 @@ -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 -%} diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 36bc0e1212..702e4a712d 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -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