1 --- steam-launcher/bin_steamdeps.py.orig 2020-07-29 17:44:37.000000000 +0200
2 +++ steam-launcher/bin_steamdeps.py 2020-07-29 19:54:23.553743588 +0200
4 # This is the set of supported dependency formats
5 SUPPORTED_STEAM_DEPENDENCY_VERSION = ['1']
9 +ARCH = "i686" # updated during package build
16 + "libc6:i386": "@libc.so.6(GLIBC_2.15)",
17 + "libc6:amd64": "@libc.so.6(GLIBC_2.15)(64bit)",
19 + # different libGL implementation pull different drivers & dependencies
20 + "libgl1-mesa-dri:i386": "@libGL.so.1",
21 + "libgl1-mesa-glx:i386": "@libGL.so.1",
25 + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1()(64bit)"
26 + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1()(64bit)"
28 + PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1"
29 + PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1"
38 +PLD_PKGNAME_RE = re.compile(r"^(.*)-([^-]*)-([^-]*?)(?:\.([^-]*))?$")
40 +PLD_CONFIG_FN = "/etc/sysconfig/steam-launcher"
43 +def pld_get_config():
44 + """Load the sysconfig file. Accept shell-like syntax."""
46 + if _config is not None:
50 + with open(PLD_CONFIG_FN) as config_f:
51 + for line in config_f:
53 + if not line or line.startswith("#"):
56 + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
58 + key, value = line.split("=", 1)
60 + value = value.strip()
61 + if value.startswith('"'):
62 + if value.endswith('"'):
65 + print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
68 + except IOError as err:
69 + print >>sys.stderr, "{0}: {1}".format(PLD_CONFIG_FN, err)
73 +def pld_config_enabled(variable, default=False):
74 + config = pld_get_config()
75 + value = config.get(variable, default)
76 + if value in (True, False):
78 + return value.lower() in ("yes", "true", "on")
80 +def pld_config_get(variable, default=None):
81 + config = pld_get_config()
82 + return config.get(variable, default)
87 # This may be different than the actual architecture for the case of i386
88 # chroot environments on amd64 hosts.
90 +# PLD: use the architecture the steam-launcher package was built for
93 Get the current architecture
98 - _arch = subprocess.check_output(
99 - ['dpkg', '--print-architecture']).decode("utf-8").strip()
102 + return PLD_ARCH_MAP[ARCH]
105 def get_full_package_name(name):
106 @@ -126,16 +193,27 @@
107 # N.B. Version checks are not supported on virtual packages
109 def is_provided(pkgname):
111 - Check to see if another package Provides this package
113 - cache = apt.Cache()
114 - pkgs = cache.get_providing_packages(pkgname)
116 - if pkg.is_installed:
120 + pkgname, arch = pkgname.split(":", 1)
124 + if pkgname.startswith("@"):
125 + pkgname = pkgname[1:]
127 + process = subprocess.Popen(['rpm', '-q', '--what-provides', pkgname],
128 + stdout=subprocess.PIPE, stderr=subprocess.PIPE)
129 + for line in process.stdout:
130 + line = line.decode( "utf-8" ).strip()
131 + match = PLD_PKGNAME_RE.match(line)
132 + if ( match is None ):
134 + pkg_arch = match.group(4)
135 + if arch and pkg_arch and PLD_ARCH_MAP[pkg_arch] != arch:
136 + print("bad arch {0!r}!={1!r}".format(PLD_ARCH_MAP[pkg_arch], arch))
144 return is_provided(self.name)
146 for (op, version) in self.version_conditions:
147 - if subprocess.call(['dpkg', '--compare-versions', self.installed,
148 - op, version]) != 0:
150 + rc = subprocess.call(['rpmvercmp', self.installed, version], stdout=open("/dev/null","w") )
151 + if op in ("=", "==") and rc != 0:
153 + if op == ">" and rc != 1:
155 + if op == ">=" and rc not in (0, 1):
157 + if op == "<" and rc != 2:
159 + if op == "<=" and rc not in (0, 2):
167 def remap_package(name):
175 ["konsole", "--nofork", "-p", "tabtitle=" + title, "-e"]),
177 + ["Terminal", "--disable-server", "--title"+title, "-x"]),
179 ["xterm", "-bg", "#383635", "-fg", "#d1cfcd", "-T", title, "-e"]),
180 ("x-terminal-emulator",
183 for (program, commandLine) in programs:
184 if subprocess.call(['which', program],
185 - stdout=subprocess.PIPE) == 0:
186 + stdout=subprocess.PIPE, stderr=open("/dev/null", "w")) == 0:
189 # Fallback if no GUI terminal program is available
190 @@ -320,17 +409,21 @@
191 to do this, but nothing that exists yet does what we need.
194 - package_list = " ".join([package.name for package in packages])
196 # Create a temporary file to hold the installation completion status
197 (fd, status_file) = tempfile.mkstemp()
200 + # Create a poldek pset file to allow installing virtual deps
201 + psetFile = tempfile.NamedTemporaryFile("w")
202 + for package in packages:
203 + print >> psetFile, package.name
206 # Create a script to run, in a secure way
207 (fd, script_file) = tempfile.mkstemp()
208 - script = """#!/bin/sh
209 + script = """#!/bin/sh{sh_flag}
213 # If your host file is misconfigured in certain circumstances this
214 # can cause sudo to block for a while, which causes gksudo to go into
215 # limbo and never return.
216 @@ -347,31 +440,30 @@
224 Steam needs to install these additional packages:
230 -# Check to make sure 64-bit systems can get 32-bit packages
231 -if [ "$(dpkg --print-architecture)" = "amd64" ] && \
232 - ! dpkg --print-foreign-architectures | grep i386 >/dev/null; then
233 - sudo dpkg --add-architecture i386
235 +[ -n "{sudo}" ] && check_sudo
237 # Update the package list, showing progress
238 -sudo apt-get update | while read line; do echo -n "."; done
239 +{sudo} poldek {poldek_options} --up
242 # Install the packages!
243 -sudo apt-get install %s
245 +{sudo} poldek {poldek_options} -u --pset={pset}
246 +echo $? >{status_file}
247 echo -n "Press return to continue: "
249 -""" % (", ".join([package.name for package in packages]), package_list,
252 + pkg_list = ", ".join( [ package.name for package in packages ] ),
253 + pset=psetFile.name,
254 + status_file=statusFile,
255 + sh_flag=" -x" if pld_config_enabled("DEBUG") else "",
256 + sudo="sudo" if pld_config_enabled("USE_SUDO") else "",
257 + poldek_options=pld_config_get("POLDEK_OPTIONS", ""))
258 os.write(fd, script.encode("utf-8"))
260 os.chmod(script_file, (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR))
262 except KeyboardInterrupt:
264 os.unlink(script_file)
267 # Read the status out of the file, since if we ran the script in a
268 # terminal the process status will be whether the terminal started
271 os.unlink(status_file)
274 + print("\nWARNING: dependencies install failed!\n")
279 @@ -419,11 +515,11 @@
280 "STEAM_DEPENDENCY_VERSION"])
283 - # Make sure we can use dpkg on this system.
284 + # Make sure we can use rpm on this system.
286 - subprocess.call(['dpkg', '--version'], stdout=subprocess.PIPE)
287 + subprocess.call(['rpm', '--version'], stdout=subprocess.PIPE)
288 except FileNotFoundError:
289 - sys.stderr.write("Couldn't find dpkg, please update steamdeps for "
290 + sys.stderr.write("Couldn't find rpm, please update steamdeps for "
291 "your distribution.\n")
298 - # Make sure we can open the file
299 + # disable steam runtime, so their libs won't conflict our binaries
300 + os.unsetenv("LD_LIBRARY_PATH")
301 + os.unsetenv("LD_PRELOAD")
303 + # Make sure we can open the file
305 fp = open(args.dependencies)
306 except Exception as e:
307 @@ -496,10 +596,20 @@
310 for section in line.split("|"):
311 - package = create_package(section)
312 + pld_pkg = PLD_PACKAGE_MAP.get(section, section)
316 + package = create_package( pld_pkg )
320 + if package.name in packages:
321 + existing = packages[package.name]
322 + if existing.version_conditions == package.version_conditions:
323 + row.append( existing )
326 packages[package.name] = package
329 @@ -544,22 +654,28 @@
330 if "COLUMNS" in os.environ:
331 del os.environ["COLUMNS"]
333 - process = subprocess.Popen(['dpkg', '-l'] + list(packages.keys()),
334 - stdout=subprocess.PIPE, stderr=subprocess.PIPE)
335 - installed_pattern = re.compile(r"^\Si\s+([^\s]+)\s+([^\s]+)")
336 + pkg_names = [name.split(":", 1)[0] for name in packages.keys() if not name.startswith("@")]
337 + process = subprocess.Popen( ['rpm', '-q'] + pkg_names, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
338 for line in process.stdout:
339 line = line.decode("utf-8").strip()
340 - match = re.match(installed_pattern, line)
341 + match = PLD_PKGNAME_RE.match(line)
345 name = match.group(1)
346 if name not in packages:
347 - name = get_full_package_name(name)
349 + arch = PLD_ARCH_MAP[match.group(4)]
350 + name = "{0}:{1}".format(name, arch)
352 + name = getFullPackageName( name )
353 + if name not in packages:
355 packages[name].set_installed(match.group(2))
357 # See which ones need to be installed
359 + consider_installed = pld_config_get("INSTALLED", "").split()
361 for row in dependencies:
368 - needed.append(row[0])
369 + if row[0].name not in consider_installed:
370 + needed.add( row[0] )
372 + print("Considering {0} already installed".format(row[0].name))
374 # If we have anything to install, do it!
380 - return update_packages(needed)
381 + if pld_config_enabled("INSTALL_PACKAGES", True):
382 + print("Installing packages as configured through {0}...".format(PLD_CONFIG_FN))
383 + return updatePackages( needed )
385 + print("\nWARNING: Dependencies missing, but package install disabled through {0}\n".format(PLD_CONFIG_FN))