]>
Commit | Line | Data |
---|---|---|
c8145d11 JP |
1 | --- steam-launcher/bin_steamdeps.py.orig 2020-06-24 12:36:09.000000000 +0200 |
2 | +++ steam-launcher/bin_steamdeps.py 2020-06-24 13:18:56.355636195 +0200 | |
3 | @@ -27,24 +27,92 @@ | |
7b16f921 | 4 | # This is the set of supported dependency formats |
2837397a | 5 | SUPPORTED_STEAM_DEPENDENCY_VERSION = ['1'] |
7b16f921 | 6 | |
2837397a | 7 | -_arch = None |
7b16f921 | 8 | +ARCH = "i686" # updated during package build |
2837397a | 9 | |
7b16f921 JK |
10 | +PLD_PACKAGE_MAP = { |
11 | + "python-apt": None, | |
12 | + "xz-utils": "xz", | |
13 | + | |
14 | + "libc6": "glibc", | |
15 | + "libc6:i386": "@libc.so.6(GLIBC_2.15)", | |
16 | + "libc6:amd64": "@libc.so.6(GLIBC_2.15)(64bit)", | |
17 | + | |
18 | + # different libGL implementation pull different drivers & dependencies | |
19 | + "libgl1-mesa-dri:i386": "@libGL.so.1", | |
20 | + "libgl1-mesa-glx:i386": "@libGL.so.1", | |
21 | + } | |
22 | + | |
23 | +if "64" in ARCH: | |
24 | + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1()(64bit)" | |
25 | + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1()(64bit)" | |
26 | +else: | |
27 | + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1" | |
28 | + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1" | |
29 | + | |
30 | +PLD_ARCH_MAP = { | |
31 | + "x86_64": "amd64", | |
32 | + "i486": "i386", | |
33 | + "i586": "i386", | |
34 | + "i686": "i386", | |
35 | + } | |
36 | + | |
37 | +PLD_PKGNAME_RE = re.compile(r"^(.*)-([^-]*)-([^-]*?)(?:\.([^-]*))?$") | |
d58e2a57 JK |
38 | + |
39 | +PLD_CONFIG_FN = "/etc/sysconfig/steam-launcher" | |
40 | + | |
41 | +_config = None | |
42 | +def pld_get_config(): | |
2837397a JP |
43 | + """Load the sysconfig file. Accept shell-like syntax.""" |
44 | + global _config | |
45 | + if _config is not None: | |
46 | + return _config | |
47 | + config = {} | |
48 | + try: | |
49 | + with open(PLD_CONFIG_FN) as config_f: | |
50 | + for line in config_f: | |
51 | + line = line.strip() | |
52 | + if not line or line.startswith("#"): | |
53 | + continue | |
54 | + if "=" not in line: | |
55 | + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line) | |
56 | + continue | |
57 | + key, value = line.split("=", 1) | |
58 | + key = key.strip() | |
59 | + value = value.strip() | |
60 | + if value.startswith('"'): | |
61 | + if value.endswith('"'): | |
62 | + value = value[1:-1] | |
63 | + else: | |
64 | + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line) | |
65 | + continue | |
66 | + config[key] = value | |
67 | + except IOError as err: | |
68 | + print >>sys.stderr, "{0}: {1}".format(PLD_CONFIG_FN, err) | |
69 | + _config = config | |
70 | + return config | |
d58e2a57 JK |
71 | + |
72 | +def pld_config_enabled(variable, default=False): | |
2837397a JP |
73 | + config = pld_get_config() |
74 | + value = config.get(variable, default) | |
75 | + if value in (True, False): | |
76 | + return value | |
77 | + return value.lower() in ("yes", "true", "on") | |
d58e2a57 JK |
78 | + |
79 | +def pld_config_get(variable, default=None): | |
2837397a JP |
80 | + config = pld_get_config() |
81 | + return config.get(variable, default) | |
82 | ||
83 | # | |
7b16f921 JK |
84 | # Get the current package architecture |
85 | # This may be different than the actual architecture for the case of i386 | |
86 | # chroot environments on amd64 hosts. | |
2837397a | 87 | # |
7b16f921 | 88 | +# PLD: use the architecture the steam-launcher package was built for |
2837397a JP |
89 | def get_arch(): |
90 | """ | |
91 | Get the current architecture | |
92 | """ | |
93 | - global _arch | |
7b16f921 | 94 | - |
2837397a JP |
95 | - if _arch is None: |
96 | - _arch = subprocess.check_output( | |
97 | - ['dpkg', '--print-architecture']).decode("utf-8").strip() | |
98 | - return _arch | |
99 | + return PLD_ARCH_MAP[ARCH] | |
100 | ||
7b16f921 JK |
101 | |
102 | ### | |
c8145d11 | 103 | @@ -61,16 +129,27 @@ |
7b16f921 JK |
104 | # N.B. Version checks are not supported on virtual packages |
105 | # | |
2837397a | 106 | def is_provided(pkgname): |
c8145d11 JP |
107 | - """ |
108 | - Check to see if another package Provides this package | |
109 | - """ | |
110 | - cache = apt.Cache() | |
111 | - pkgs = cache.get_providing_packages(pkgname) | |
112 | - for pkg in pkgs: | |
113 | - if pkg.is_installed: | |
114 | - return True | |
2837397a JP |
115 | - return False |
116 | + if ":" in pkgname: | |
117 | + pkgname, arch = pkgname.split(":", 1) | |
118 | + else: | |
119 | + arch = None | |
c8145d11 | 120 | |
2837397a JP |
121 | + if pkgname.startswith("@"): |
122 | + pkgname = pkgname[1:] | |
c8145d11 | 123 | + |
2837397a JP |
124 | + process = subprocess.Popen(['rpm', '-q', '--what-provides', pkgname], |
125 | + stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
126 | + for line in process.stdout: | |
127 | + line = line.decode( "utf-8" ).strip() | |
128 | + match = PLD_PKGNAME_RE.match(line) | |
129 | + if ( match is None ): | |
130 | + continue | |
131 | + pkg_arch = match.group(4) | |
132 | + if arch and pkg_arch and PLD_ARCH_MAP[pkg_arch] != arch: | |
133 | + print("bad arch {0!r}!={1!r}".format(PLD_ARCH_MAP[pkg_arch], arch)) | |
134 | + continue | |
135 | + return True | |
136 | + return False | |
7b16f921 JK |
137 | |
138 | ### | |
139 | class Package: | |
c8145d11 | 140 | @@ -92,9 +171,17 @@ |
2837397a | 141 | return is_provided(self.name) |
7b16f921 | 142 | |
2837397a JP |
143 | for (op, version) in self.version_conditions: |
144 | - if subprocess.call(['dpkg', '--compare-versions', self.installed, | |
145 | - op, version]) != 0: | |
146 | - return False | |
7b16f921 JK |
147 | + rc = subprocess.call(['rpmvercmp', self.installed, version], stdout=open("/dev/null","w") ) |
148 | + if op in ("=", "==") and rc != 0: | |
149 | + return False | |
150 | + if op == ">" and rc != 1: | |
151 | + return False | |
d58e2a57 | 152 | + if op == ">=" and rc not in (0, 1): |
7b16f921 JK |
153 | + return False |
154 | + if op == "<" and rc != 2: | |
155 | + return False | |
d58e2a57 | 156 | + if op == "<=" and rc not in (0, 2): |
7b16f921 JK |
157 | + return False |
158 | ||
2837397a | 159 | return True |
7b16f921 | 160 | |
c8145d11 | 161 | @@ -120,6 +207,7 @@ |
7b16f921 | 162 | |
2837397a JP |
163 | |
164 | def remap_package(name): | |
165 | + return name | |
166 | if name in ( | |
167 | 'python-apt', | |
168 | ): | |
c8145d11 | 169 | @@ -224,6 +312,8 @@ |
2837397a | 170 | programs = [ |
2837397a JP |
171 | ("konsole", |
172 | ["konsole", "--nofork", "-p", "tabtitle=" + title, "-e"]), | |
173 | + ("Terminal", | |
174 | + ["Terminal", "--disable-server", "--title"+title, "-x"]), | |
175 | ("xterm", | |
176 | ["xterm", "-bg", "#383635", "-fg", "#d1cfcd", "-T", title, "-e"]), | |
c8145d11 JP |
177 | ("x-terminal-emulator", |
178 | @@ -240,7 +330,7 @@ | |
2837397a JP |
179 | ] |
180 | for (program, commandLine) in programs: | |
181 | if subprocess.call(['which', program], | |
182 | - stdout=subprocess.PIPE) == 0: | |
183 | + stdout=subprocess.PIPE, stderr=open("/dev/null", "w")) == 0: | |
184 | return commandLine | |
185 | ||
186 | # Fallback if no GUI terminal program is available | |
c8145d11 | 187 | @@ -255,17 +345,21 @@ |
2837397a JP |
188 | to do this, but nothing that exists yet does what we need. |
189 | """ | |
190 | ||
191 | - package_list = " ".join([package.name for package in packages]) | |
7b16f921 | 192 | - |
2837397a JP |
193 | # Create a temporary file to hold the installation completion status |
194 | (fd, status_file) = tempfile.mkstemp() | |
195 | os.close(fd) | |
196 | ||
197 | + # Create a poldek pset file to allow installing virtual deps | |
198 | + psetFile = tempfile.NamedTemporaryFile("w") | |
199 | + for package in packages: | |
200 | + print >> psetFile, package.name | |
201 | + psetFile.flush() | |
7b16f921 | 202 | + |
2837397a JP |
203 | # Create a script to run, in a secure way |
204 | (fd, script_file) = tempfile.mkstemp() | |
205 | - script = """#!/bin/sh | |
206 | + script = """#!/bin/sh{sh_flag} | |
d58e2a57 JK |
207 | check_sudo() |
208 | -{ | |
209 | +{{ | |
210 | # If your host file is misconfigured in certain circumstances this | |
211 | # can cause sudo to block for a while, which causes gksudo to go into | |
212 | # limbo and never return. | |
c8145d11 | 213 | @@ -282,31 +376,30 @@ |
d58e2a57 JK |
214 | else |
215 | return 0 | |
216 | fi | |
217 | -} | |
218 | +}} | |
7b16f921 | 219 | |
d58e2a57 | 220 | cat <<__EOF__ |
2837397a JP |
221 | Steam needs to install these additional packages: |
222 | - %s | |
223 | + {pkg_list} | |
d58e2a57 JK |
224 | __EOF__ |
225 | -check_sudo | |
226 | - | |
7b16f921 | 227 | -# Check to make sure 64-bit systems can get 32-bit packages |
2837397a JP |
228 | -if [ "$(dpkg --print-architecture)" = "amd64" ] && \ |
229 | - ! dpkg --print-foreign-architectures | grep i386 >/dev/null; then | |
7b16f921 JK |
230 | - sudo dpkg --add-architecture i386 |
231 | -fi | |
d58e2a57 JK |
232 | +[ -n "{sudo}" ] && check_sudo |
233 | ||
7b16f921 JK |
234 | # Update the package list, showing progress |
235 | -sudo apt-get update | while read line; do echo -n "."; done | |
d58e2a57 | 236 | +{sudo} poldek {poldek_options} --up |
7b16f921 JK |
237 | echo |
238 | ||
239 | # Install the packages! | |
240 | -sudo apt-get install %s | |
d58e2a57 JK |
241 | -echo $? >%s |
242 | +{sudo} poldek {poldek_options} -u --pset={pset} | |
243 | +echo $? >{status_file} | |
7b16f921 JK |
244 | echo -n "Press return to continue: " |
245 | read line | |
2837397a JP |
246 | -""" % (", ".join([package.name for package in packages]), package_list, |
247 | - status_file) | |
d58e2a57 | 248 | +""".format( |
2837397a JP |
249 | + pkg_list = ", ".join( [ package.name for package in packages ] ), |
250 | + pset=psetFile.name, | |
251 | + status_file=statusFile, | |
252 | + sh_flag=" -x" if pld_config_enabled("DEBUG") else "", | |
253 | + sudo="sudo" if pld_config_enabled("USE_SUDO") else "", | |
254 | + poldek_options=pld_config_get("POLDEK_OPTIONS", "")) | |
255 | os.write(fd, script.encode("utf-8")) | |
256 | os.close(fd) | |
257 | os.chmod(script_file, (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)) | |
c8145d11 | 258 | @@ -317,6 +410,7 @@ |
2837397a JP |
259 | except KeyboardInterrupt: |
260 | pass | |
261 | os.unlink(script_file) | |
262 | + psetFile.close() | |
263 | ||
264 | # Read the status out of the file, since if we ran the script in a | |
265 | # terminal the process status will be whether the terminal started | |
c8145d11 | 266 | @@ -328,6 +422,9 @@ |
2837397a JP |
267 | |
268 | os.unlink(status_file) | |
269 | ||
270 | + if status: | |
271 | + print("\nWARNING: dependencies install failed!\n") | |
d58e2a57 | 272 | + |
2837397a JP |
273 | return status |
274 | ||
275 | ||
c8145d11 | 276 | @@ -355,11 +452,11 @@ |
2837397a JP |
277 | "STEAM_DEPENDENCY_VERSION"]) |
278 | return False | |
279 | ||
280 | - # Make sure we can use dpkg on this system. | |
281 | + # Make sure we can use rpm on this system. | |
282 | try: | |
283 | - subprocess.call(['dpkg', '--version'], stdout=subprocess.PIPE) | |
284 | + subprocess.call(['rpm', '--version'], stdout=subprocess.PIPE) | |
285 | except FileNotFoundError: | |
286 | - sys.stderr.write("Couldn't find dpkg, please update steamdeps for " | |
287 | + sys.stderr.write("Couldn't find rpm, please update steamdeps for " | |
288 | "your distribution.\n") | |
289 | return False | |
290 | ||
c8145d11 | 291 | @@ -375,7 +472,11 @@ |
2837397a JP |
292 | sys.stderr.write("Usage: %s dependencies.txt\n" % sys.argv[0]) |
293 | return 1 | |
294 | ||
295 | - # Make sure we can open the file | |
296 | + # disable steam runtime, so their libs won't conflict our binaries | |
297 | + os.unsetenv("LD_LIBRARY_PATH") | |
298 | + os.unsetenv("LD_PRELOAD") | |
e0f04824 JK |
299 | + |
300 | + # Make sure we can open the file | |
2837397a JP |
301 | try: |
302 | fp = open(sys.argv[1]) | |
303 | except Exception as e: | |
c8145d11 | 304 | @@ -414,10 +515,20 @@ |
2837397a JP |
305 | |
306 | row = [] | |
307 | for section in line.split("|"): | |
308 | - package = create_package(section) | |
309 | + pld_pkg = PLD_PACKAGE_MAP.get(section, section) | |
310 | + if not pld_pkg: | |
311 | + continue | |
7b16f921 | 312 | + |
2837397a JP |
313 | + package = create_package( pld_pkg ) |
314 | if package is None: | |
315 | continue | |
316 | ||
317 | + if package.name in packages: | |
318 | + existing = packages[package.name] | |
319 | + if existing.version_conditions == package.version_conditions: | |
320 | + row.append( existing ) | |
321 | + continue | |
7b16f921 | 322 | + |
2837397a JP |
323 | packages[package.name] = package |
324 | row.append(package) | |
325 | ||
c8145d11 | 326 | @@ -445,22 +556,28 @@ |
2837397a JP |
327 | if "COLUMNS" in os.environ: |
328 | del os.environ["COLUMNS"] | |
329 | ||
330 | - process = subprocess.Popen(['dpkg', '-l'] + list(packages.keys()), | |
331 | - stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
332 | - installed_pattern = re.compile(r"^\Si\s+([^\s]+)\s+([^\s]+)") | |
333 | + pkg_names = [name.split(":", 1)[0] for name in packages.keys() if not name.startswith("@")] | |
334 | + process = subprocess.Popen( ['rpm', '-q'] + pkg_names, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) | |
335 | for line in process.stdout: | |
336 | line = line.decode("utf-8").strip() | |
337 | - match = re.match(installed_pattern, line) | |
338 | + match = PLD_PKGNAME_RE.match(line) | |
339 | if match is None: | |
340 | continue | |
341 | ||
342 | name = match.group(1) | |
343 | if name not in packages: | |
344 | - name = get_full_package_name(name) | |
345 | + if match.group(4): | |
346 | + arch = PLD_ARCH_MAP[match.group(4)] | |
347 | + name = "{0}:{1}".format(name, arch) | |
348 | + else: | |
349 | + name = getFullPackageName( name ) | |
350 | + if name not in packages: | |
351 | + continue | |
352 | packages[name].set_installed(match.group(2)) | |
353 | ||
354 | # See which ones need to be installed | |
355 | - needed = [] | |
356 | + consider_installed = pld_config_get("INSTALLED", "").split() | |
357 | + needed = set() | |
358 | for row in dependencies: | |
359 | if len(row) == 0: | |
360 | continue | |
c8145d11 | 361 | @@ -471,7 +588,10 @@ |
2837397a JP |
362 | satisfied = True |
363 | break | |
364 | if not satisfied: | |
365 | - needed.append(row[0]) | |
366 | + if row[0].name not in consider_installed: | |
367 | + needed.add( row[0] ) | |
368 | + else: | |
369 | + print("Considering {0} already installed".format(row[0].name)) | |
370 | ||
371 | # If we have anything to install, do it! | |
372 | if len(needed) > 0: | |
c8145d11 | 373 | @@ -485,7 +605,12 @@ |
2837397a JP |
374 | print("Package %s needs to be installed" % package.name, |
375 | file=sys.stderr) | |
376 | ||
377 | - return update_packages(needed) | |
378 | + if pld_config_enabled("INSTALL_PACKAGES", True): | |
379 | + print("Installing packages as configured through {0}...".format(PLD_CONFIG_FN)) | |
380 | + return updatePackages( needed ) | |
381 | + else: | |
382 | + print("\nWARNING: Dependencies missing, but package install disabled through {0}\n".format(PLD_CONFIG_FN)) | |
383 | + return 1 | |
384 | else: | |
385 | return 0 | |
d58e2a57 | 386 |