/usr/share/rhn/up2date_client/debUtils.py is in rhn-client-tools 1.8.26-4.
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 | # Client code for Update Agent
# Copyright (c) 2011--2012 Red Hat, Inc. Distributed under GPLv2.
#
# Author: Simon Lukasik
# Lukas Durfina
#
import os
import apt
import gettext
t = gettext.translation('rhn-client-tools', fallback=True)
_ = t.ugettext
# FIXME: After Debian bug 187019 is resolved
def verifyPackages(packages):
cache = apt.Cache()
missing_packages = []
for package in packages:
pkg = cache[package[0]]
if pkg == None or not pkg.is_installed:
missing_packages.append(package)
return [], missing_packages
def parseVRE(version):
epoch = ''
release = '0'
if version.find(':') != -1:
epoch, version = version.split(':')
if version.find('-') != -1:
tmp = version.split('-')
version = '-'.join(tmp[:-1])
release = tmp[-1]
return version, release, epoch
def installTime(pkg_name, arch=None):
paths = ['/var/lib/dpkg/info/%s.list' % (pkg_name,)]
if arch:
paths.append('/var/lib/dpkg/info/%s:%s.list' % (pkg_name, arch))
for path in paths:
if os.path.isfile(path):
return os.path.getmtime(path)
return None
#FIXME: Using Apt cache might not be an ultimate solution.
# It could be better to parse /var/lib/dpkg/status manually.
# Apt cache might not contain all the packages.
def getInstalledPackageList(msgCallback = None, progressCallback = None,
getArch=None, getInfo = None):
""" Return list of packages. Package is dict with following keys:
name, epoch, version, release and optionaly arch.
"""
if msgCallback != None:
msgCallback(_("Getting list of packages installed on the system"))
cache = apt.Cache()
total = 0
for pkg in cache:
if pkg.installed != None:
total += 1
count = 0
pkg_list = []
for pkg in cache:
if pkg.installed == None:
continue
version, release, epoch = parseVRE(pkg.installed.version)
package = {
'name': pkg.name,
'epoch': epoch,
'version': version,
'release': release,
'arch': pkg.installed.architecture + '-deb',
'installtime': installTime(pkg.name, pkg.installed.architecture)
}
pkg_list.append(package)
if progressCallback != None:
progressCallback(count, total)
count = count + 1
pkg_list.sort()
return pkg_list
def setDebugVerbosity():
pass
|