/usr/share/rhn/up2date_client/up2dateUtils.py is in rhn-client-tools 1.8.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # Client code for Update Agent
# Copyright (c) 1999--2012 Red Hat, Inc. Distributed under GPLv2.
#
# Author: Preston Brown <pbrown@redhat.com>
# Adrian Likins <alikins@redhat.com>
#
"""utility functions for up2date"""
import os
import string
import up2dateErrors
import config
import gettext
from pkgplatform import getPlatform
t = gettext.translation('rhn-client-tools', fallback=True)
_ = t.ugettext
if getPlatform() == 'deb':
import lsb_release
def _getOSVersionAndRelease():
dist_info = lsb_release.get_distro_information()
os_name = dist_info['ID']
os_version = 'n/a'
if 'CODENAME' in dist_info:
os_version = dist_info['CODENAME']
os_release = dist_info['RELEASE']
return os_name, os_version, os_release
else:
import transaction
def _getOSVersionAndRelease():
ts = transaction.initReadOnlyTransaction()
for h in ts.dbMatch('Providename', "redhat-release"):
osVersionRelease = (h['name'], h['version'], h['release'])
return osVersionRelease
else:
for h in ts.dbMatch('Providename', "distribution-release"):
osVersionRelease = (h['name'], h['version'], h['release'])
# zypper requires a exclusive lock on the rpmdb. So we need
# to close it here.
ts.ts.closeDB()
return osVersionRelease
else:
raise up2dateErrors.RpmError(
"Could not determine what version of Red Hat Linux you "\
"are running.\nIf you get this error, try running \n\n"\
"\t\trpm --rebuilddb\n\n")
def getVersion():
'''
Returns the version of redhat-release rpm
'''
cfg = config.initUp2dateConfig()
if cfg["versionOverride"]:
return str(cfg["versionOverride"])
os_release, version, release = _getOSVersionAndRelease()
return version
def getOSRelease():
'''
Returns the name of the redhat-release rpm
'''
os_release, version, release = _getOSVersionAndRelease()
return os_release
def getRelease():
'''
Returns the release of the redhat-release rpm
'''
os_release, version, release = _getOSVersionAndRelease()
return release
def getArch():
if os.access("/etc/rpm/platform", os.R_OK):
fd = open("/etc/rpm/platform", "r")
platform = string.strip(fd.read())
#bz 216225
#handle some replacements..
replace = {"ia32e-redhat-linux": "x86_64-redhat-linux"}
if replace.has_key(platform):
platform = replace[platform]
return platform
arch = os.uname()[4]
if getPlatform() == 'deb':
# On debian we only support i386
if arch in ['i486', 'i586', 'i686']:
arch = 'i386'
if arch == 'x86_64':
arch = 'amd64'
arch += '-debian-linux'
return arch
def version():
# substituted to the real version by the Makefile at installation time.
return "1.8.9"
|