@@ -62,21 +62,24 @@ def install_x86_support_libraries():
62
62
packages = ('libglib2.0-dev:i386' , 'libsecret-1-dev:i386' )
63
63
64
64
# First check if these packages exist on the machine already
65
- import apt
66
- cache = apt .Cache ()
67
- package_installed = []
68
65
for package in packages :
69
- if package in cache .keys ():
70
- package_installed .append (cache [package ].is_installed )
71
- else :
72
- package_installed .append (False )
73
-
74
- if not all (package_installed ):
75
- utils .run_command (['apt' , 'install' , 'gcc-multilib' , 'g++-multilib' ], as_root = True )
76
- utils .run_command (['dpkg' , '--add-architecture' , 'i386' ], as_root = True )
77
- utils .run_command (['apt' , 'update' ], as_root = True )
78
- for package in packages :
79
- utils .run_command (['apt' , 'install' , package ], as_root = True )
66
+ devnull = open (os .devnull , "w" )
67
+ retval = subprocess .call (["dpkg" , "-s" , package ], stdout = devnull , stderr = subprocess .STDOUT )
68
+ devnull .close ()
69
+ # if package is not installed, dpkg returns a value other than 0 and in this case,
70
+ # we get out of this loop and install those packages.
71
+ if retval != 0 :
72
+ break
73
+ else :
74
+ # If the for loop iterated without breaking, all required packages are already installed.
75
+ # Nothing to do. Return from the function.
76
+ return
77
+
78
+ utils .run_command (['apt' , 'install' , 'gcc-multilib' , 'g++-multilib' ], as_root = True )
79
+ utils .run_command (['dpkg' , '--add-architecture' , 'i386' ], as_root = True )
80
+ utils .run_command (['apt' , 'update' ], as_root = True )
81
+ for package in packages :
82
+ utils .run_command (['apt' , 'install' , package ], as_root = True )
80
83
81
84
82
85
def _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library ):
0 commit comments