@@ -55,14 +55,22 @@ def append_line_to_file(path, line):
55
55
with open (path , "a" ) as file :
56
56
file .write ("\n " + line + "\n " )
57
57
58
+
58
59
def install_x86_support_libraries ():
59
60
"""Install support libraries needed to build x86 on x86_64 hosts."""
60
61
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 )
66
74
67
75
68
76
def _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library ):
0 commit comments