@@ -30,6 +30,7 @@ class ChromeForTesting:
3030 CHROME_BASE_DIR = ZEUZ_NODE_DOWNLOADS_DIR / "chrome_for_testing"
3131 CHROME_VERSIONS_DIR = CHROME_BASE_DIR / "versions"
3232 CHROME_INFO_FILE = CHROME_BASE_DIR / "info.json"
33+ CHROME_LINUX_UNAVAILABLE_DEPS_FILE = CHROME_BASE_DIR / "unavailable_linux_deps.txt"
3334
3435 def __init__ (self ):
3536 self .system = platform .system ().lower ()
@@ -41,7 +42,9 @@ def __init__(self):
4142 self .platform_key = "mac-arm64" if self .arch == "arm64" else "mac-x64"
4243 elif self .system == "linux" :
4344 self .platform_key = "linux64"
44- self .linux_helper = LinuxSystemHelper ()
45+ self .linux_helper = LinuxSystemHelper (
46+ unavailable_cache_file = self .CHROME_LINUX_UNAVAILABLE_DEPS_FILE
47+ )
4548 self ._install_linux_dependencies ()
4649 else :
4750 raise OSError (f"Unsupported platform: { self .system } /{ self .arch } " )
@@ -73,18 +76,94 @@ def _install_linux_dependencies(self):
7376 )
7477 return
7578
79+ install_deps , cached_unavailable = (
80+ self .linux_helper .filter_cached_unavailable_packages (missing_deps )
81+ )
82+ if cached_unavailable :
83+ print (
84+ "Warning: Skipping previously unavailable packages: "
85+ f"{ ', ' .join (cached_unavailable )} "
86+ )
87+
88+ if not install_deps :
89+ print (
90+ "All missing dependencies are marked unavailable. "
91+ "Skipping apt install."
92+ )
93+ return
94+
7695 privilege_cmd , privilege_mode = (
7796 self .linux_helper .get_privilege_escalation_command ()
7897 )
7998 print (
8099 f"Installing Chrome dependencies for Ubuntu using { privilege_mode } ..."
81100 )
82101 subprocess .run (privilege_cmd + ["apt-get" , "update" , "-qq" ], check = True )
83- subprocess .run (
84- privilege_cmd + ["apt-get" , "install" , "-y" ] + missing_deps ,
85- check = True ,
102+ install_result = subprocess .run (
103+ privilege_cmd + ["apt-get" , "install" , "-y" ] + install_deps ,
104+ capture_output = True ,
105+ text = True ,
106+ check = False ,
86107 )
87- print ("Dependencies installed successfully." )
108+ install_ok = install_result .returncode == 0
109+
110+ if install_result .returncode != 0 :
111+ apt_output = f"{ install_result .stdout } \n { install_result .stderr } "
112+ unavailable_from_apt = (
113+ self .linux_helper .extract_unavailable_packages_from_apt_output (
114+ apt_output
115+ )
116+ )
117+
118+ if unavailable_from_apt :
119+ newly_cached = self .linux_helper .add_unavailable_packages (
120+ unavailable_from_apt
121+ )
122+ if newly_cached :
123+ print (
124+ "Warning: Caching unavailable packages for future runs: "
125+ f"{ ', ' .join (sorted (newly_cached ))} "
126+ )
127+
128+ retry_deps = [
129+ package
130+ for package in install_deps
131+ if package not in unavailable_from_apt
132+ ]
133+
134+ if retry_deps :
135+ retry_result = subprocess .run (
136+ privilege_cmd
137+ + ["apt-get" , "install" , "-y" ]
138+ + retry_deps ,
139+ capture_output = True ,
140+ text = True ,
141+ check = False ,
142+ )
143+ if retry_result .returncode != 0 :
144+ print ("Warning: Could not install all dependencies." )
145+ print (
146+ retry_result .stderr .strip ()
147+ or retry_result .stdout .strip ()
148+ )
149+ else :
150+ install_ok = True
151+ else :
152+ print (
153+ "Warning: All attempted packages were unavailable in apt. "
154+ "Continuing without interruption."
155+ )
156+ else :
157+ print ("Warning: Could not install dependencies." )
158+ print (
159+ install_result .stderr .strip ()
160+ or install_result .stdout .strip ()
161+ )
162+
163+ if install_ok :
164+ print ("Dependencies installed successfully." )
165+ else :
166+ print ("Dependency installation completed with warnings." )
88167 else :
89168 return
90169
0 commit comments