]> git.pld-linux.org Git - packages/steam-launcher.git/blob - steamdeps.patch
d49dcedbe95c5f8e4f31d64425614d24d260719b
[packages/steam-launcher.git] / steamdeps.patch
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 @@
4  # This is the set of supported dependency formats
5  SUPPORTED_STEAM_DEPENDENCY_VERSION = ['1']
6  
7 -_arch = None
8 +ARCH = "i686" # updated during package build
9  
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"^(.*)-([^-]*)-([^-]*?)(?:\.([^-]*))?$")
38 +
39 +PLD_CONFIG_FN = "/etc/sysconfig/steam-launcher"
40 +
41 +_config = None
42 +def pld_get_config():
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
71 +
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):
76 +        return value
77 +    return value.lower() in ("yes", "true", "on")
78 +
79 +def pld_config_get(variable, default=None):
80 +    config = pld_get_config()
81 +    return config.get(variable, default)
82  
83  #
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.
87  #
88 +# PLD: use the architecture the steam-launcher package was built for
89  def get_arch():
90      """
91      Get the current architecture
92      """
93 -    global _arch
94 -
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  
101  
102  ###
103 @@ -61,16 +129,27 @@
104  # N.B. Version checks are not supported on virtual packages
105  #
106  def is_provided(pkgname):
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
115 -    return False
116 +    if ":" in pkgname:
117 +        pkgname, arch = pkgname.split(":", 1)
118 +    else:
119 +        arch = None
120  
121 +    if pkgname.startswith("@"):
122 +        pkgname = pkgname[1:]
123 +
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
137  
138  ###
139  class Package:
140 @@ -92,9 +171,17 @@
141              return is_provided(self.name)
142  
143          for (op, version) in self.version_conditions:
144 -            if subprocess.call(['dpkg', '--compare-versions', self.installed,
145 -                                op, version]) != 0:
146 -                return False
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
152 +                    if op == ">=" and rc not in (0, 1):
153 +                        return False
154 +                    if op == "<" and rc != 2:
155 +                        return False
156 +                    if op == "<=" and rc not in (0, 2):
157 +                        return False
158  
159          return True
160  
161 @@ -120,6 +207,7 @@
162  
163  
164  def remap_package(name):
165 +    return name
166      if name in (
167              'python-apt',
168      ):
169 @@ -224,6 +312,8 @@
170          programs = [
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"]),
177              ("x-terminal-emulator",
178 @@ -240,7 +330,7 @@
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
187 @@ -255,17 +345,21 @@
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])
192 -
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()
202 +
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}
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.
213 @@ -282,31 +376,30 @@
214      else
215          return 0
216      fi
217 -}
218 +}}
219  
220  cat <<__EOF__
221  Steam needs to install these additional packages:
222 -    %s
223 +    {pkg_list}
224  __EOF__
225 -check_sudo
226 -
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
231 -fi
232 +[ -n "{sudo}" ] && check_sudo
233  
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
237  echo
238  
239  # Install the packages!
240 -sudo apt-get install %s
241 -echo $? >%s
242 +{sudo} poldek {poldek_options} -u --pset={pset}
243 +echo $? >{status_file}
244  echo -n "Press return to continue: "
245  read line
246 -""" % (", ".join([package.name for package in packages]), package_list,
247 -       status_file)
248 +""".format(
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))
258 @@ -317,6 +410,7 @@
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
266 @@ -328,6 +422,9 @@
267  
268      os.unlink(status_file)
269  
270 +    if status:
271 +        print("\nWARNING: dependencies install failed!\n")
272 +
273      return status
274  
275  
276 @@ -355,11 +452,11 @@
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  
291 @@ -375,7 +472,11 @@
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")
299 +
300 +        # Make sure we can open the file
301      try:
302          fp = open(sys.argv[1])
303      except Exception as e:
304 @@ -414,10 +515,20 @@
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
312 +
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
322 +
323              packages[package.name] = package
324              row.append(package)
325  
326 @@ -445,22 +556,28 @@
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
361 @@ -471,7 +588,10 @@
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:
373 @@ -485,7 +605,12 @@
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
386  
This page took 0.059075 seconds and 2 git commands to generate.