@@ -232,17 +232,17 @@ def mount_squash_fs(squashfs_path, mount_point):
232232 run_command_or_raise (["mount" , "-t" , "squashfs" , squashfs_path , mount_point ])
233233
234234
235- def umount (mount_point , read_only = True , recursive = False , force = True , remove_dir = True ):
235+ def umount (mount_point , read_only = True , recursive = False , force = True , remove_dir = True , raise_exception = True ):
236236 flags = []
237237 if read_only :
238238 flags .append ("-r" )
239239 if force :
240240 flags .append ("-f" )
241241 if recursive :
242242 flags .append ("-R" )
243- run_command_or_raise (["umount" , * flags , mount_point ])
243+ run_command_or_raise (["umount" , * flags , mount_point ], raise_exception = raise_exception )
244244 if remove_dir :
245- run_command_or_raise (["rm" , "-rf" , mount_point ])
245+ run_command_or_raise (["rm" , "-rf" , mount_point ], raise_exception = raise_exception )
246246
247247
248248def mount_overlay_fs (lowerdir , upperdir , workdir , mount_point ):
@@ -350,14 +350,18 @@ def get_path(path):
350350 run_command_or_raise (["mount" , "--bind" ,
351351 os .path .join (VAR_RUN_PATH , DOCKERD_SOCK ),
352352 os .path .join (new_image_mount , "tmp" , DOCKERD_SOCK )])
353+ run_command_or_raise (["chroot" , new_image_mount , "sh" , "-c" , "command -v {}" .format (SONIC_PACKAGE_MANAGER )])
354+ except SonicRuntimeException as err :
355+ echo_and_log ("Warning: SONiC Application Extension is not supported in this image: {}" .format (err ), LOG_ERR , fg = "red" )
356+ else :
353357 run_command_or_raise (["chroot" , new_image_mount , SONIC_PACKAGE_MANAGER , "migrate" ,
354358 os .path .join ("/" , tmp_dir , packages_file ),
355359 "--dockerd-socket" , os .path .join ("/" , tmp_dir , DOCKERD_SOCK ),
356360 "-y" ])
357361 finally :
358- run_command ( "chroot {} {} stop" . format ( new_image_mount , DOCKER_CTL_SCRIPT ) )
359- umount (new_image_mount , recursive = True , read_only = False , remove_dir = False )
360- umount (new_image_mount )
362+ run_command_or_raise ([ "chroot" , new_image_mount , DOCKER_CTL_SCRIPT , " stop"], raise_exception = False )
363+ umount (new_image_mount , recursive = True , read_only = False , remove_dir = False , raise_exception = False )
364+ umount (new_image_mount , raise_exception = False )
361365
362366
363367# Main entrypoint
0 commit comments