@@ -55,14 +55,22 @@ def append_line_to_file(path, line):
5555 with open (path , "a" ) as file :
5656 file .write ("\n " + line + "\n " )
5757
58+
5859def install_x86_support_libraries ():
5960 """Install support libraries needed to build x86 on x86_64 hosts."""
6061 if utils .is_linux_os ():
61- utils .run_command (['apt' , 'install' , 'gcc-multilib' , 'g++-multilib' ], as_root = True )
62- utils .run_command (['dpkg' , '--add-architecture' , 'i386' ], as_root = True )
63- utils .run_command (['apt' , 'update' ], as_root = True )
64- utils .run_command (['apt' , 'install' , 'libglib2.0-dev:i386' ], as_root = True )
65- utils .run_command (['apt' , 'install' , 'libsecret-1-dev:i386' ], as_root = True )
62+ packages = ['gcc-multilib' , 'g++-multilib' , 'libglib2.0-dev:i386' , 'libsecret-1-dev:i386' ]
63+
64+ # First check if these packages exist on the machine already
65+ devnull = open (os .devnull , "w" )
66+ process = subprocess .run (["dpkg" , "-s" ] + packages , stdout = devnull , stderr = subprocess .STDOUT )
67+ devnull .close ()
68+ if process .returncode != 0 :
69+ # This implies not all of the required packages are already installed on user's machine
70+ # Install them.
71+ utils .run_command (['dpkg' , '--add-architecture' , 'i386' ], as_root = True )
72+ utils .run_command (['apt' , 'update' ], as_root = True )
73+ utils .run_command (['apt' , 'install' ] + packages , as_root = True )
6674
6775
6876def _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library ):
0 commit comments