]> git.pld-linux.org Git - packages/steam-launcher.git/blob - steamdeps.patch
up to 1.0.0.72
[packages/steam-launcher.git] / steamdeps.patch
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
3 @@ -34,8 +34,80 @@
4  # This is the set of supported dependency formats
5  SUPPORTED_STEAM_DEPENDENCY_VERSION = ['1']
6  
7 -_arch = None
8 -
9 +ARCH = "i686" # updated during package build
10
11 +PLD_PACKAGE_MAP = {
12 +        "python-apt": None,
13 +        "xz-utils": "xz",
14 +
15 +        "libc6": "glibc",
16 +        "libc6:i386": "@libc.so.6(GLIBC_2.15)",
17 +        "libc6:amd64": "@libc.so.6(GLIBC_2.15)(64bit)",
18 +
19 +        # different libGL implementation pull different drivers & dependencies
20 +        "libgl1-mesa-dri:i386": "@libGL.so.1",
21 +        "libgl1-mesa-glx:i386": "@libGL.so.1",
22 +        }
23 +
24 +if "64" in ARCH:
25 +        PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1()(64bit)"
26 +        PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1()(64bit)"
27 +else:
28 +        PLD_PACKAGE_MAP["libgl1-mesa-dri"] = "@libGL.so.1"
29 +        PLD_PACKAGE_MAP["libgl1-mesa-glx"] = "@libGL.so.1"
30 +
31 +PLD_ARCH_MAP = {
32 +        "x86_64": "amd64",
33 +        "i486": "i386",
34 +        "i586": "i386",
35 +        "i686": "i386",
36 +        }
37 +
38 +PLD_PKGNAME_RE = re.compile(r"^(.*)-([^-]*)-([^-]*?)(?:\.([^-]*))?$")
39 +
40 +PLD_CONFIG_FN = "/etc/sysconfig/steam-launcher"
41 +
42 +_config = None
43 +def pld_get_config():
44 +    """Load the sysconfig file. Accept shell-like syntax."""
45 +    global _config
46 +    if _config is not None:
47 +        return _config
48 +    config = {}
49 +    try:
50 +        with open(PLD_CONFIG_FN) as config_f:
51 +            for line in config_f:
52 +                line = line.strip()
53 +                if not line or line.startswith("#"):
54 +                    continue
55 +                if "=" not in line:
56 +                    print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
57 +                    continue
58 +                key, value = line.split("=", 1)
59 +                key = key.strip()
60 +                value = value.strip()
61 +                if value.startswith('"'):
62 +                    if value.endswith('"'):
63 +                        value = value[1:-1]
64 +                    else:
65 +                        print >>sys.stderr, "{0}: syntax error: {1!r}".format(PLD_CONFIG_FN, line)
66 +                        continue
67 +                config[key] = value
68 +    except IOError as err:
69 +        print >>sys.stderr, "{0}: {1}".format(PLD_CONFIG_FN, err)
70 +    _config = config
71 +    return config
72 +
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):
77 +        return value
78 +    return value.lower() in ("yes", "true", "on")
79 +
80 +def pld_config_get(variable, default=None):
81 +    config = pld_get_config()
82 +    return config.get(variable, default)
83  
84  class OsRelease:
85      def __init__(self):
86 @@ -100,17 +172,12 @@
87  # This may be different than the actual architecture for the case of i386
88  # chroot environments on amd64 hosts.
89  #
90 +# PLD: use the architecture the steam-launcher package was built for
91  def get_arch():
92      """
93      Get the current architecture
94      """
95 -    global _arch
96 -
97 -    if _arch is None:
98 -        _arch = subprocess.check_output(
99 -            ['dpkg', '--print-architecture']).decode("utf-8").strip()
100 -    return _arch
101 -
102 +    return PLD_ARCH_MAP[ARCH]
103  
104  ###
105  def get_full_package_name(name):
106 @@ -126,16 +193,27 @@
107  # N.B. Version checks are not supported on virtual packages
108  #
109  def is_provided(pkgname):
110 -    """
111 -    Check to see if another package Provides this package
112 -    """
113 -    cache = apt.Cache()
114 -    pkgs = cache.get_providing_packages(pkgname)
115 -    for pkg in pkgs:
116 -        if pkg.is_installed:
117 -            return True
118 -    return False
119 +    if ":" in pkgname:
120 +        pkgname, arch = pkgname.split(":", 1)
121 +    else:
122 +        arch = None
123  
124 +    if pkgname.startswith("@"):
125 +        pkgname = pkgname[1:]
126 +
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 ):
133 +            continue
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))
137 +            continue
138 +        return True
139 +    return False
140  
141  ###
142  class Package:
143 @@ -157,9 +235,17 @@
144              return is_provided(self.name)
145  
146          for (op, version) in self.version_conditions:
147 -            if subprocess.call(['dpkg', '--compare-versions', self.installed,
148 -                                op, version]) != 0:
149 -                return False
150 +                    rc = subprocess.call(['rpmvercmp', self.installed, version], stdout=open("/dev/null","w") )
151 +                    if op in ("=", "==") and rc != 0:
152 +                        return False
153 +                    if op == ">" and rc != 1:
154 +                        return False
155 +                    if op == ">=" and rc not in (0, 1):
156 +                        return False
157 +                    if op == "<" and rc != 2:
158 +                        return False
159 +                    if op == "<=" and rc not in (0, 2):
160 +                        return False
161  
162          return True
163  
164 @@ -185,6 +271,7 @@
165  
166  
167  def remap_package(name):
168 +    return name
169      if name in (
170              'python-apt',
171      ):
172 @@ -289,6 +376,8 @@
173          programs = [
174              ("konsole",
175               ["konsole", "--nofork", "-p", "tabtitle=" + title, "-e"]),
176 +            ("Terminal",
177 +             ["Terminal", "--disable-server", "--title"+title, "-x"]),
178              ("xterm",
179               ["xterm", "-bg", "#383635", "-fg", "#d1cfcd", "-T", title, "-e"]),
180              ("x-terminal-emulator",
181 @@ -305,7 +394,7 @@
182          ]
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:
187                  return commandLine
188  
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.
192      """
193  
194 -    package_list = " ".join([package.name for package in packages])
195 -
196      # Create a temporary file to hold the installation completion status
197      (fd, status_file) = tempfile.mkstemp()
198      os.close(fd)
199  
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
204 +    psetFile.flush()
205 +
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}
210  check_sudo()
211 -{
212 +{{
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,33 +440,32 @@
217      else
218          return 0
219      fi
220 -}
221 +}}
222  
223  cat <<__EOF__
224  Steam needs to install these additional packages:
225 -    %s
226 +    {pkg_list}
227  __EOF__
228 -check_sudo
229 -
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
234 -fi
235 +[ -n "{sudo}" ] && check_sudo
236  
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
240  echo
241  
242  # Install the packages using the option "--no-remove" to avoid
243  # unexpected dependencies cycle that end up removing packages that are
244  # essential for the OS to run
245 -sudo apt-get install --no-remove %s
246 -echo $? >%s
247 +{sudo} poldek {poldek_options} -u --pset={pset}
248 +echo $? >{status_file}
249  echo -n "Press return to continue: "
250  read line
251 -""" % (", ".join([package.name for package in packages]), package_list,
252 -       status_file)
253 +""".format(
254 +        pkg_list = ", ".join( [ package.name for package in packages ] ),
255 +        pset=psetFile.name,
256 +        status_file=statusFile,
257 +        sh_flag=" -x" if pld_config_enabled("DEBUG") else "",
258 +        sudo="sudo" if pld_config_enabled("USE_SUDO") else "",
259 +        poldek_options=pld_config_get("POLDEK_OPTIONS", ""))
260      os.write(fd, script.encode("utf-8"))
261      os.close(fd)
262      os.chmod(script_file, (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR))
263 @@ -382,6 +474,7 @@
264      except KeyboardInterrupt:
265          pass
266      os.unlink(script_file)
267 +    psetFile.close()
268  
269      # Read the status out of the file, since if we ran the script in a
270      # terminal the process status will be whether the terminal started
271 @@ -393,6 +486,9 @@
272  
273      os.unlink(status_file)
274  
275 +    if status:
276 +        print("\nWARNING: dependencies install failed!\n")
277 +
278      return status
279  
280  
281 @@ -419,11 +515,11 @@
282              "STEAM_DEPENDENCY_VERSION"])
283          return False
284  
285 -    # Make sure we can use dpkg on this system.
286 +    # Make sure we can use rpm on this system.
287      try:
288 -        subprocess.call(['dpkg', '--version'], stdout=subprocess.PIPE)
289 +        subprocess.call(['rpm', '--version'], stdout=subprocess.PIPE)
290      except FileNotFoundError:
291 -        sys.stderr.write("Couldn't find dpkg, please update steamdeps for "
292 +        sys.stderr.write("Couldn't find rpm, please update steamdeps for "
293                           "your distribution.\n")
294          return False
295  
296 @@ -457,7 +553,11 @@
297          os_release.dump()
298          return 0
299  
300 -    # Make sure we can open the file
301 +    # disable steam runtime, so their libs won't conflict our binaries
302 +    os.unsetenv("LD_LIBRARY_PATH")
303 +    os.unsetenv("LD_PRELOAD")
304 +
305 +        # Make sure we can open the file
306      try:
307          fp = open(args.dependencies)
308      except Exception as e:
309 @@ -496,10 +596,20 @@
310  
311          row = []
312          for section in line.split("|"):
313 -            package = create_package(section)
314 +            pld_pkg = PLD_PACKAGE_MAP.get(section, section)
315 +            if not pld_pkg:
316 +                continue
317 +
318 +            package = create_package( pld_pkg )
319              if package is None:
320                  continue
321  
322 +            if package.name in packages:
323 +                existing = packages[package.name]
324 +                if existing.version_conditions == package.version_conditions:
325 +                    row.append( existing )
326 +                    continue
327 +
328              packages[package.name] = package
329              row.append(package)
330  
331 @@ -544,22 +654,28 @@
332      if "COLUMNS" in os.environ:
333          del os.environ["COLUMNS"]
334  
335 -    process = subprocess.Popen(['dpkg', '-l'] + list(packages.keys()),
336 -                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
337 -    installed_pattern = re.compile(r"^\Si\s+([^\s]+)\s+([^\s]+)")
338 +    pkg_names = [name.split(":", 1)[0] for name in packages.keys() if not name.startswith("@")]
339 +    process = subprocess.Popen( ['rpm', '-q'] + pkg_names, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
340      for line in process.stdout:
341          line = line.decode("utf-8").strip()
342 -        match = re.match(installed_pattern, line)
343 +        match = PLD_PKGNAME_RE.match(line)
344          if match is None:
345              continue
346  
347          name = match.group(1)
348          if name not in packages:
349 -            name = get_full_package_name(name)
350 +            if match.group(4):
351 +                arch = PLD_ARCH_MAP[match.group(4)]
352 +                name = "{0}:{1}".format(name, arch)
353 +            else:
354 +                name = getFullPackageName( name )
355 +            if name not in packages:
356 +                continue
357          packages[name].set_installed(match.group(2))
358  
359      # See which ones need to be installed
360 -    needed = set()
361 +    consider_installed = pld_config_get("INSTALLED", "").split()
362 +    needed = set()
363      for row in dependencies:
364          if len(row) == 0:
365              continue
366 @@ -570,7 +686,10 @@
367                  satisfied = True
368                  break
369          if not satisfied:
370 -            needed.add(row[0])
371 +            if row[0].name not in consider_installed:
372 +                needed.add( row[0] )
373 +            else:
374 +                print("Considering {0} already installed".format(row[0].name))
375  
376      # If we have anything to install, do it!
377      if len(needed) > 0:
378 @@ -587,8 +706,12 @@
379              # ones listed in "ensure_installed_packages". If they were already
380              # installed, this forces apt to keep them into consideration when
381              # it evaluates the new packages dependencies.
382 -            needed.update(ensure_installed_packages)
383 -            return update_packages(sorted(needed, key=lambda x: x.name))
384 +            if pld_config_enabled("INSTALL_PACKAGES", True):
385 +                print("Installing packages as configured through {0}...".format(PLD_CONFIG_FN))
386 +                return updatePackages( needed )
387 +            else:
388 +                print("\nWARNING: Dependencies missing, but package install disabled through {0}\n".format(PLD_CONFIG_FN))
389 +                return 1
390      else:
391          return 0
392  
This page took 0.093063 seconds and 3 git commands to generate.