]> git.pld-linux.org Git - packages/steam-launcher.git/blob - steamdeps.patch
up to 1.0.0.63
[packages/steam-launcher.git] / steamdeps.patch
1 --- steam-launcher/bin_steamdeps.py.orig    2020-06-15 16:29:37.582721048 +0200
2 +++ steam-launcher/bin_steamdeps.py    2020-06-15 16:58:54.551881214 +0200
3 @@ -20,24 +20,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 @@ -50,31 +118,32 @@
104      else:
105          return name
106  
107 -
108  #
109  # Check to see if another package Provides this package
110  # N.B. Version checks are not supported on virtual packages
111  #
112  def is_provided(pkgname):
113 -    try:
114 -        process = subprocess.Popen(['apt-cache', 'showpkg', pkgname],
115 -                                   stdout=subprocess.PIPE,
116 -                                   stderr=subprocess.PIPE)
117 -        pattern = re.compile(r'^Reverse Provides:')
118 -        providers = {}
119 -        for line in process.stdout:
120 -            if re.match(pattern, str(line, 'utf-8')):
121 -                for provider in process.stdout:
122 -                    (name, version) = provider.split()
123 -                    providers[name] = version
124 -                for provider in providers.keys():
125 -                    if has_package(provider):
126 -                        return True
127 -                return False
128 -    except (OSError, FileNotFoundError):
129 -        return False
130 -    return False
131 +    if ":" in pkgname:
132 +        pkgname, arch = pkgname.split(":", 1)
133 +    else:
134 +        arch = None
135 +
136 +    if pkgname.startswith("@"):
137 +        pkgname = pkgname[1:]
138  
139 +    process = subprocess.Popen(['rpm', '-q', '--what-provides', pkgname],
140 +                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
141 +    for line in process.stdout:
142 +        line = line.decode( "utf-8" ).strip()
143 +        match = PLD_PKGNAME_RE.match(line)
144 +        if ( match is None ):
145 +            continue
146 +        pkg_arch = match.group(4)
147 +        if arch and pkg_arch and PLD_ARCH_MAP[pkg_arch] != arch:
148 +            print("bad arch {0!r}!={1!r}".format(PLD_ARCH_MAP[pkg_arch], arch))
149 +            continue
150 +        return True
151 +    return False
152  
153  ###
154  class Package:
155 @@ -96,9 +165,17 @@
156              return is_provided(self.name)
157  
158          for (op, version) in self.version_conditions:
159 -            if subprocess.call(['dpkg', '--compare-versions', self.installed,
160 -                                op, version]) != 0:
161 -                return False
162 +                    rc = subprocess.call(['rpmvercmp', self.installed, version], stdout=open("/dev/null","w") )
163 +                    if op in ("=", "==") and rc != 0:
164 +                        return False
165 +                    if op == ">" and rc != 1:
166 +                        return False
167 +                    if op == ">=" and rc not in (0, 1):
168 +                        return False
169 +                    if op == "<" and rc != 2:
170 +                        return False
171 +                    if op == "<=" and rc not in (0, 2):
172 +                        return False
173  
174          return True
175  
176 @@ -111,18 +188,7 @@
177  
178  ###
179  def has_package(package):
180 -    process = subprocess.Popen(['dpkg', '-l', package], stdout=subprocess.PIPE,
181 -                               stderr=subprocess.PIPE)
182 -    installed_pattern = re.compile(r"^\Si\s+([^\s]+)\s+([^\s]+)")
183 -    for line in process.stdout:
184 -        line = line.decode("utf-8").strip()
185 -        match = re.match(installed_pattern, line)
186 -        if match is None:
187 -            continue
188 -
189 -        return True
190 -    return False
191 -
192 +    return is_provided(package)
193  
194  def is_glvnd():
195      try:
196 @@ -139,6 +205,7 @@
197  
198  
199  def remap_package(name):
200 +    return name
201      if name in (
202              'python-apt',
203      ):
204 @@ -218,10 +285,13 @@
205      """
206      if "DISPLAY" in os.environ:
207          programs = [
208 -            ("gnome-terminal",
209 -             ["gnome-terminal", "--disable-factory", "-t", title, "-e"]),
210 +            # PLD: --disable-factory doesn't work any more
211 +            #("gnome-terminal",
212 +            # ["gnome-terminal", "--disable-factory", "-t", title, "-e"]),
213              ("konsole",
214               ["konsole", "--nofork", "-p", "tabtitle=" + title, "-e"]),
215 +            ("Terminal",
216 +             ["Terminal", "--disable-server", "--title"+title, "-x"]),
217              ("xterm",
218               ["xterm", "-bg", "#383635", "-fg", "#d1cfcd", "-T", title, "-e"]),
219              (
220 @@ -230,7 +300,7 @@
221          ]
222          for (program, commandLine) in programs:
223              if subprocess.call(['which', program],
224 -                               stdout=subprocess.PIPE) == 0:
225 +                               stdout=subprocess.PIPE, stderr=open("/dev/null", "w")) == 0:
226                  return commandLine
227  
228      # Fallback if no GUI terminal program is available
229 @@ -245,17 +315,21 @@
230      to do this, but nothing that exists yet does what we need.
231      """
232  
233 -    package_list = " ".join([package.name for package in packages])
234 -
235      # Create a temporary file to hold the installation completion status
236      (fd, status_file) = tempfile.mkstemp()
237      os.close(fd)
238  
239 +    # Create a poldek pset file to allow installing virtual deps
240 +    psetFile = tempfile.NamedTemporaryFile("w")
241 +    for package in packages:
242 +        print >> psetFile, package.name
243 +    psetFile.flush()
244 +
245      # Create a script to run, in a secure way
246      (fd, script_file) = tempfile.mkstemp()
247 -    script = """#!/bin/sh
248 +    script = """#!/bin/sh{sh_flag}
249  check_sudo()
250 -{
251 +{{
252      # If your host file is misconfigured in certain circumstances this
253      # can cause sudo to block for a while, which causes gksudo to go into
254      # limbo and never return.
255 @@ -272,31 +346,30 @@
256      else
257          return 0
258      fi
259 -}
260 +}}
261  
262  cat <<__EOF__
263  Steam needs to install these additional packages:
264 -    %s
265 +    {pkg_list}
266  __EOF__
267 -check_sudo
268 -
269 -# Check to make sure 64-bit systems can get 32-bit packages
270 -if [ "$(dpkg --print-architecture)" = "amd64" ] && \
271 -   ! dpkg --print-foreign-architectures | grep i386 >/dev/null; then
272 -    sudo dpkg --add-architecture i386
273 -fi
274 +[ -n "{sudo}" ] && check_sudo
275  
276  # Update the package list, showing progress
277 -sudo apt-get update | while read line; do echo -n "."; done
278 +{sudo} poldek {poldek_options} --up
279  echo
280  
281  # Install the packages!
282 -sudo apt-get install %s
283 -echo $? >%s
284 +{sudo} poldek {poldek_options} -u --pset={pset}
285 +echo $? >{status_file}
286  echo -n "Press return to continue: "
287  read line
288 -""" % (", ".join([package.name for package in packages]), package_list,
289 -       status_file)
290 +""".format(
291 +        pkg_list = ", ".join( [ package.name for package in packages ] ),
292 +        pset=psetFile.name,
293 +        status_file=statusFile,
294 +        sh_flag=" -x" if pld_config_enabled("DEBUG") else "",
295 +        sudo="sudo" if pld_config_enabled("USE_SUDO") else "",
296 +        poldek_options=pld_config_get("POLDEK_OPTIONS", ""))
297      os.write(fd, script.encode("utf-8"))
298      os.close(fd)
299      os.chmod(script_file, (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR))
300 @@ -307,6 +380,7 @@
301      except KeyboardInterrupt:
302          pass
303      os.unlink(script_file)
304 +    psetFile.close()
305  
306      # Read the status out of the file, since if we ran the script in a
307      # terminal the process status will be whether the terminal started
308 @@ -318,6 +392,9 @@
309  
310      os.unlink(status_file)
311  
312 +    if status:
313 +        print("\nWARNING: dependencies install failed!\n")
314 +
315      return status
316  
317  
318 @@ -345,11 +422,11 @@
319              "STEAM_DEPENDENCY_VERSION"])
320          return False
321  
322 -    # Make sure we can use dpkg on this system.
323 +    # Make sure we can use rpm on this system.
324      try:
325 -        subprocess.call(['dpkg', '--version'], stdout=subprocess.PIPE)
326 +        subprocess.call(['rpm', '--version'], stdout=subprocess.PIPE)
327      except FileNotFoundError:
328 -        sys.stderr.write("Couldn't find dpkg, please update steamdeps for "
329 +        sys.stderr.write("Couldn't find rpm, please update steamdeps for "
330                           "your distribution.\n")
331          return False
332  
333 @@ -365,7 +442,11 @@
334          sys.stderr.write("Usage: %s dependencies.txt\n" % sys.argv[0])
335          return 1
336  
337 -    # Make sure we can open the file
338 +    # disable steam runtime, so their libs won't conflict our binaries
339 +    os.unsetenv("LD_LIBRARY_PATH")
340 +    os.unsetenv("LD_PRELOAD")
341 +
342 +        # Make sure we can open the file
343      try:
344          fp = open(sys.argv[1])
345      except Exception as e:
346 @@ -404,10 +485,20 @@
347  
348          row = []
349          for section in line.split("|"):
350 -            package = create_package(section)
351 +            pld_pkg = PLD_PACKAGE_MAP.get(section, section)
352 +            if not pld_pkg:
353 +                continue
354 +
355 +            package = create_package( pld_pkg )
356              if package is None:
357                  continue
358  
359 +            if package.name in packages:
360 +                existing = packages[package.name]
361 +                if existing.version_conditions == package.version_conditions:
362 +                    row.append( existing )
363 +                    continue
364 +
365              packages[package.name] = package
366              row.append(package)
367  
368 @@ -435,22 +526,28 @@
369      if "COLUMNS" in os.environ:
370          del os.environ["COLUMNS"]
371  
372 -    process = subprocess.Popen(['dpkg', '-l'] + list(packages.keys()),
373 -                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
374 -    installed_pattern = re.compile(r"^\Si\s+([^\s]+)\s+([^\s]+)")
375 +    pkg_names = [name.split(":", 1)[0] for name in packages.keys() if not name.startswith("@")]
376 +    process = subprocess.Popen( ['rpm', '-q'] + pkg_names, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
377      for line in process.stdout:
378          line = line.decode("utf-8").strip()
379 -        match = re.match(installed_pattern, line)
380 +        match = PLD_PKGNAME_RE.match(line)
381          if match is None:
382              continue
383  
384          name = match.group(1)
385          if name not in packages:
386 -            name = get_full_package_name(name)
387 +            if match.group(4):
388 +                arch = PLD_ARCH_MAP[match.group(4)]
389 +                name = "{0}:{1}".format(name, arch)
390 +            else:
391 +                name = getFullPackageName( name )
392 +            if name not in packages:
393 +                continue
394          packages[name].set_installed(match.group(2))
395  
396      # See which ones need to be installed
397 -    needed = []
398 +    consider_installed = pld_config_get("INSTALLED", "").split()
399 +    needed = set()
400      for row in dependencies:
401          if len(row) == 0:
402              continue
403 @@ -461,7 +558,10 @@
404                  satisfied = True
405                  break
406          if not satisfied:
407 -            needed.append(row[0])
408 +            if row[0].name not in consider_installed:
409 +                needed.add( row[0] )
410 +            else:
411 +                print("Considering {0} already installed".format(row[0].name))
412  
413      # If we have anything to install, do it!
414      if len(needed) > 0:
415 @@ -475,7 +575,12 @@
416                  print("Package %s needs to be installed" % package.name,
417                        file=sys.stderr)
418  
419 -        return update_packages(needed)
420 +        if pld_config_enabled("INSTALL_PACKAGES", True):
421 +            print("Installing packages as configured through {0}...".format(PLD_CONFIG_FN))
422 +            return updatePackages( needed )
423 +        else:
424 +            print("\nWARNING: Dependencies missing, but package install disabled through {0}\n".format(PLD_CONFIG_FN))
425 +            return 1
426      else:
427          return 0
428  
This page took 0.114737 seconds and 3 git commands to generate.