Skip to content

Instantly share code, notes, and snippets.

@Mailaender
Created February 17, 2013 22:19
Show Gist options
  • Save Mailaender/4973797 to your computer and use it in GitHub Desktop.
Save Mailaender/4973797 to your computer and use it in GitHub Desktop.
diff -upa steam-1.0.0.22/usr/bin/steamdeps.rpmnames steam-1.0.0.22/usr/bin/steamdeps
--- steam-1.0.0.22/usr/bin/steamdeps.rpmnames 2013-02-07 11:07:03.935551942 -0500
+++ steam-1.0.0.22/usr/bin/steamdeps 2013-02-07 11:08:23.219557155 -0500
@@ -280,6 +280,54 @@ def checkConfig( config ):
return True
+###
+def debtorpm( val ):
+ arch32 = ':i386'
+ fixedarch32 = '.i686'
+ arch64 = ':x86_64'
+ fixedarch64 = '.x86_64'
+ myval = val.replace(arch32, fixedarch32)
+ myval = myval.replace(arch64, fixedarch64)
+ myval = myval.replace('libxext6', 'libXext')
+ myval = myval.replace('libnspr4', 'nspr')
+ myval = myval.replace('libcurl3-gnutls', 'libcurl')
+ myval = myval.replace('libogg0', 'libogg')
+ myval = myval.replace('libdbus-1-3', 'dbus-libs')
+ myval = myval.replace('libfreetype6', 'freetype')
+ myval = myval.replace('libgcc1', 'libgcc')
+ myval = myval.replace('libxinerama1', 'libXinerama')
+ myval = myval.replace('libx11-6', 'libX11')
+ myval = myval.replace('libgcrypt11', 'libgcrypt')
+ myval = myval.replace('libstdc++6', 'libstdc++')
+ myval = myval.replace('libc6', 'glibc')
+ myval = myval.replace('libpng12-0', 'libpng12')
+ myval = myval.replace('libxfixes3', 'libXfixes')
+ myval = myval.replace('libgdk-pixbuf2.0-0', 'gdk-pixbuf2')
+ myval = myval.replace('libxrender1', 'libXrender')
+ myval = myval.replace('libglib2.0-0', 'glib2')
+ myval = myval.replace('libvorbisenc2', 'libvorbis')
+ myval = myval.replace('libasound2', 'alsa-lib')
+ myval = myval.replace('libpulse0', 'pulseaudio-libs')
+ myval = myval.replace('libfontconfig1', 'fontconfig')
+ myval = myval.replace('libgl1-mesa-glx', 'mesa-libGL')
+ myval = myval.replace('libpixman-1-0', 'pixman')
+ myval = myval.replace('libnss3', 'nss')
+ myval = myval.replace('libxi6', 'libXi')
+ myval = myval.replace('libvorbis0a', 'libvorbis')
+ myval = myval.replace('libtheora0', 'libtheora')
+ myval = myval.replace('libcups2', 'cups-libs')
+ myval = myval.replace('libudev0', 'systemd-libs')
+ myval = myval.replace('libopenal1', 'openal-soft')
+ myval = myval.replace('libsdl1.2debian', 'SDL')
+ myval = myval.replace('libxrandr2', 'libXrandr')
+ myval = myval.replace('libgtk2.0-0', 'gtk2')
+ myval = myval.replace('libgl1-mesa-dri', 'mesa-dri-drivers')
+ myval = myval.replace('libvorbisfile3', 'libvorbis')
+ myval = myval.replace('zlib1g', 'zlib')
+ myval = myval.replace('libpango1.0-0', 'pango')
+ myval = myval.replace('libcairo2', 'cairo')
+
+ return myval
###
def main( *args ):
@@ -353,20 +401,38 @@ def main( *args ):
del os.environ[ "COLUMNS" ]
if distro == 'fedora' or distro == 'rhel':
- process = subprocess.Popen( ['rpm', '-qf', '"ii\t%{NAME}\t%{VERSION}-%{RELEASE}\t%{SUMMARY}\n"', '-q'] + list( packages.keys() ), stdout=subprocess.PIPE, stderr=subprocess.PIPE )
+ rpmpackages = packages.keys()
+ newlist = []
+ deblist = []
+ for idx, val in enumerate(rpmpackages):
+ myval = debtorpm(val)
+ if myval == 'multiarch-support' or myval == 'jockey-common' or myval == 'python-apt':
+ # these are debianisms that do not exist in our universe
+ # lie and say we have them.
+ packages[myval].setInstalled('100')
+ else:
+ deblist.append(val)
+ newlist.append(myval)
+ process = subprocess.Popen( ['rpm', '-q', '--qf', 'ii %{NAME} %{VERSION}-%{RELEASE} %{SUMMARY}\n'] + newlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
else:
process = subprocess.Popen( ['dpkg', '-l'] + list( packages.keys() ), stdout=subprocess.PIPE, stderr=subprocess.PIPE )
+
installed_pattern = re.compile( r"^ii\s+([^\s]+)\s+([^\s]+)" )
- for line in process.stdout:
+ for idx, line in enumerate(process.stdout):
line = line.decode( "utf-8" ).strip()
match = re.match( installed_pattern, line )
if ( match is None ):
continue
-
name = match.group(1)
- if ( name not in packages ):
- name = getFullPackageName( name )
- packages[ name ].setInstalled( match.group(2) )
+ if distro == 'fedora' or distro == 'rhel':
+ debname = deblist[idx]
+ if ( debname not in packages ):
+ debname = getFullPackageName ( debname )
+ packages [ debname ].setInstalled( match.group(2) )
+ else:
+ if ( name not in packages ):
+ name = getFullPackageName( name )
+ packages[ name ].setInstalled( match.group(2) )
# See which ones need to be installed
needed = []
diff -up steam-1.0.0.22/usr/bin/steamdeps.fedora steam-1.0.0.22/usr/bin/steamdeps
--- steam-1.0.0.22/usr/bin/steamdeps.fedora 2013-01-31 08:37:38.642000679 -0500
+++ steam-1.0.0.22/usr/bin/steamdeps 2013-01-31 09:45:00.336061325 -0500
@@ -14,12 +14,46 @@ import subprocess
import sys
import tempfile
+try:
+ from platform import architecture, uname
+ if sys.version_info[:2] < (2, 6): # Python < 2.6
+ from platform import dist
+ else:
+ from platform import linux_distribution as dist
+except: # "platform" not installed. Python < 2.3
+ sys.exit("Python too old for platform, upgrade!")
+
# This is the set of supported Steam runtime environments
SUPPORTED_STEAM_RUNTIME = [ '1' ]
# This is the set of supported dependency formats
SUPPORTED_STEAM_DEPENDENCY_VERSION = [ '1' ]
+def getDistro():
+ """
+ Try to identify distribution of Linux
+ """
+ global _distro
+ if dist()[0].lower() == 'fedora':
+ _distro = 'fedora'
+ _distro_version = dist()[1]
+ elif dist()[0].lower() == 'redhat':
+ _distro = 'rhel'
+ _distro_version = dist()[1]
+ elif dist()[0].lower() == 'debian':
+ _distro = 'debian'
+ _distro_version = dist()[1]
+ elif dist()[0].lower() == 'ubuntu':
+ _distro = 'ubuntu'
+ _distro_version = dist()[1]
+ elif dist()[0].lower() == 'suse':
+ _distro = 'suse'
+ _distro_version = dist()[1]
+ else:
+ _distro = 'unknown'
+ _distro_version = '1'
+ return _distro
+
###
# Get the current package architecture
# This may be different than the actual architecture for the case of i386
@@ -29,10 +63,15 @@ def getArch():
"""
Get the current architecture
"""
+ distro = getDistro()
+
global _arch
if ( _arch is None ):
- _arch = subprocess.check_output(['dpkg', '--print-architecture']).decode("utf-8").strip()
+ if distro == 'fedora' or distro == 'rhel' or distro == 'suse':
+ _arch = subprocess.check_output(['rpm', '--eval', '%{_arch}']).decode("utf-8").strip()
+ elif distro == 'ubuntu' or distro == 'debian' or distro == 'unknown':
+ _arch = subprocess.check_output(['dpkg', '--print-architecture']).decode("utf-8").strip()
return _arch
@@ -61,12 +100,46 @@ class Package:
self.installed = version
def isAvailable(self):
+ distro = getDistro()
+
if ( self.installed is None ):
return False
for (op, version) in self.versionConditions:
- if ( subprocess.call( ['dpkg', '--compare-versions', self.installed, op, version] ) != 0 ):
- return False
+ if distro == 'fedora' or distro == 'rhel':
+ import rpm
+ comp_result = rpm.labelCompare(('1', self.installed, '1'), ('1', version, '1'))
+ if op == '=':
+ if comp_result == 0:
+ return True
+ else:
+ return False
+ elif op == '>=':
+ if comp_result == 1 or comp_result == 0:
+ return True
+ else:
+ return False
+ elif op == '<=':
+ if comp_result == -1 or comp_result == 0:
+ return True
+ else:
+ return False
+ elif op == '>':
+ if comp_result == 1:
+ return True
+ else:
+ return False
+ elif op == '<':
+ if comp_result == -1:
+ return True
+ else:
+ return False
+ else:
+ # Unknown op, just go with False
+ return False
+ else:
+ if ( subprocess.call( ['dpkg', '--compare-versions', self.installed, op, version] ) != 0 ):
+ return False
return True
@@ -132,6 +205,7 @@ def updatePackages( packages ):
Function to install or update package dependencies
Ideally we would call some sort of system UI that users were familiar with to do this, but nothing that exists yet does what we need.
"""
+ distro = getDistro()
packageList = " ".join( [ package.name for package in packages ] )
@@ -141,7 +215,19 @@ def updatePackages( packages ):
# Create a script to run, in a secure way
(fd, scriptFile) = tempfile.mkstemp()
- script = """#!/bin/sh
+ if distro == 'fedora' or distro == 'redhat':
+ script = """#!/bin/sh
+cat <<__EOF__
+Steam needs to install these additional packages:
+ %s
+__EOF__
+sudo yum install %s
+echo $? >%s
+echo -n "Press return to continue: "
+read line
+""" % ( ", ".join( [ package.name for package in packages ] ), packageList, statusFile )
+ else:
+ script = """#!/bin/sh
cat <<__EOF__
Steam needs to install these additional packages:
%s
@@ -198,6 +284,7 @@ def checkConfig( config ):
###
def main( *args ):
config = {}
+ distro = getDistro()
# Check the command line arguments
if ( len(args) < 1 ):
@@ -265,7 +352,10 @@ def main( *args ):
if ( "COLUMNS" in os.environ ):
del os.environ[ "COLUMNS" ]
- process = subprocess.Popen( ['dpkg', '-l'] + list( packages.keys() ), stdout=subprocess.PIPE, stderr=subprocess.PIPE )
+ if distro == 'fedora' or distro == 'rhel':
+ process = subprocess.Popen( ['rpm', '-qf', '"ii\t%{NAME}\t%{VERSION}-%{RELEASE}\t%{SUMMARY}\n"', '-q'] + list( packages.keys() ), stdout=subprocess.PIPE, stderr=subprocess.PIPE )
+ else:
+ process = subprocess.Popen( ['dpkg', '-l'] + list( packages.keys() ), stdout=subprocess.PIPE, stderr=subprocess.PIPE )
installed_pattern = re.compile( r"^ii\s+([^\s]+)\s+([^\s]+)" )
for line in process.stdout:
line = line.decode( "utf-8" ).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment