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
4 # This is the set of supported dependency formats
5 SUPPORTED_STEAM_DEPENDENCY_VERSION = ['1']
8 +ARCH = "i686" # updated during package build
15 + "libc6:i386": "@libc.so.6(GLIBC_2.15)",
16 + "libc6:amd64": "@libc.so.6(GLIBC_2.15)(64bit)",
18 + # different libGL implementation pull different drivers & dependencies
19 + "libgl1-mesa-dri:i386": "@libGL.so.1",
20 + "libgl1-mesa-glx:i386": "@libGL.so.1",
24 + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1()(64bit)"
25 + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1()(64bit)"
27 + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1"
28 + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1"
37 +PLD_PKGNAME_RE = re.compile(r"^(.*)-([^-]*)-([^-]*?)(?:\.([^-]*))?$")
39 +PLD_CONFIG_FN = "/etc/sysconfig/steam-launcher"
42 +def pld_get_config():
43 + """Load the sysconfig file. Accept shell-like syntax."""
45 + if _config is not None:
49 + with open(PLD_CONFIG_FN) as config_f:
50 + for line in config_f:
52 + if not line or line.startswith("#"):
55 + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
57 + key, value = line.split("=", 1)
59 + value = value.strip()
60 + if value.startswith('"'):
61 + if value.endswith('"'):
64 + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
67 + except IOError as err:
68 + print >>sys.stderr, "{0}: {1}".format(PLD_CONFIG_FN, err)
72 +def pld_config_enabled(variable, default=False):
73 + config = pld_get_config()
74 + value = config.get(variable, default)
75 + if value in (True, False):
77 + return value.lower() in ("yes", "true", "on")
79 +def pld_config_get(variable, default=None):
80 + config = pld_get_config()
81 + return config.get(variable, default)
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.
88 +# PLD: use the architecture the steam-launcher package was built for
91 Get the current architecture
96 - _arch = subprocess.check_output(
97 - ['dpkg', '--print-architecture']).decode("utf-8").strip()
99 + return PLD_ARCH_MAP[ARCH]
104 # N.B. Version checks are not supported on virtual packages
106 def is_provided(pkgname):
108 - Check to see if another package Provides this package
110 - cache = apt.Cache()
111 - pkgs = cache.get_providing_packages(pkgname)
113 - if pkg.is_installed:
117 + pkgname, arch = pkgname.split(":", 1)
121 + if pkgname.startswith("@"):
122 + pkgname = pkgname[1:]
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 ):
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))
141 return is_provided(self.name)
143 for (op, version) in self.version_conditions:
144 - if subprocess.call(['dpkg', '--compare-versions', self.installed,
145 - op, version]) != 0:
147 + rc = subprocess.call(['rpmvercmp', self.installed, version], stdout=open("/dev/null","w") )
148 + if op in ("=", "==") and rc != 0:
150 + if op == ">" and rc != 1:
152 + if op == ">=" and rc not in (0, 1):
154 + if op == "<" and rc != 2:
156 + if op == "<=" and rc not in (0, 2):
164 def remap_package(name):
172 ["konsole", "--nofork", "-p", "tabtitle=" + title, "-e"]),
174 + ["Terminal", "--disable-server", "--title"+title, "-x"]),
176 ["xterm", "-bg", "#383635", "-fg", "#d1cfcd", "-T", title, "-e"]),
177 ("x-terminal-emulator",
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:
186 # Fallback if no GUI terminal program is available
187 @@ -255,17 +345,21 @@
188 to do this, but nothing that exists yet does what we need.
191 - package_list = " ".join([package.name for package in packages])
193 # Create a temporary file to hold the installation completion status
194 (fd, status_file) = tempfile.mkstemp()
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
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}
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.
213 @@ -282,31 +376,30 @@
221 Steam needs to install these additional packages:
227 -# Check to make sure 64-bit systems can get 32-bit packages
228 -if [ "$(dpkg --print-architecture)" = "amd64" ] && \
229 - ! dpkg --print-foreign-architectures | grep i386 >/dev/null; then
230 - sudo dpkg --add-architecture i386
232 +[ -n "{sudo}" ] && check_sudo
234 # Update the package list, showing progress
235 -sudo apt-get update | while read line; do echo -n "."; done
236 +{sudo} poldek {poldek_options} --up
239 # Install the packages!
240 -sudo apt-get install %s
242 +{sudo} poldek {poldek_options} -u --pset={pset}
243 +echo $? >{status_file}
244 echo -n "Press return to continue: "
246 -""" % (", ".join([package.name for package in packages]), package_list,
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"))
257 os.chmod(script_file, (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR))
259 except KeyboardInterrupt:
261 os.unlink(script_file)
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
268 os.unlink(status_file)
271 + print("\nWARNING: dependencies install failed!\n")
276 @@ -355,11 +452,11 @@
277 "STEAM_DEPENDENCY_VERSION"])
280 - # Make sure we can use dpkg on this system.
281 + # Make sure we can use rpm on this system.
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")
292 sys.stderr.write("Usage: %s dependencies.txt\n" % sys.argv[0])
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")
300 + # Make sure we can open the file
302 fp = open(sys.argv[1])
303 except Exception as e:
304 @@ -414,10 +515,20 @@
307 for section in line.split("|"):
308 - package = create_package(section)
309 + pld_pkg = PLD_PACKAGE_MAP.get(section, section)
313 + package = create_package( pld_pkg )
317 + if package.name in packages:
318 + existing = packages[package.name]
319 + if existing.version_conditions == package.version_conditions:
320 + row.append( existing )
323 packages[package.name] = package
326 @@ -445,22 +556,28 @@
327 if "COLUMNS" in os.environ:
328 del os.environ["COLUMNS"]
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)
342 name = match.group(1)
343 if name not in packages:
344 - name = get_full_package_name(name)
346 + arch = PLD_ARCH_MAP[match.group(4)]
347 + name = "{0}:{1}".format(name, arch)
349 + name = getFullPackageName( name )
350 + if name not in packages:
352 packages[name].set_installed(match.group(2))
354 # See which ones need to be installed
356 + consider_installed = pld_config_get("INSTALLED", "").split()
358 for row in dependencies:
365 - needed.append(row[0])
366 + if row[0].name not in consider_installed:
367 + needed.add( row[0] )
369 + print("Considering {0} already installed".format(row[0].name))
371 # If we have anything to install, do it!
374 print("Package %s needs to be installed" % package.name,
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 )
382 + print("\nWARNING: Dependencies missing, but package install disabled through {0}\n".format(PLD_CONFIG_FN))