Skip to content

Commit 8673956

Browse files
committed
using subprocess instead of apt python module.
apt python module is not installed on github runners. Instead of adding another dependency, using vanilla python modules to get the job done.
1 parent b80562a commit 8673956

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

scripts/gha/build_desktop.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,24 @@ def install_x86_support_libraries():
6262
packages = ('libglib2.0-dev:i386', 'libsecret-1-dev:i386')
6363

6464
# First check if these packages exist on the machine already
65-
import apt
66-
cache = apt.Cache()
67-
package_installed = []
6865
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)
8083

8184

8285
def _install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library):

0 commit comments

Comments
 (0)