Univention Bugzilla – Bug 43886
univention-support-info does not work on UCS 4.2
Last modified: 2017-09-15 14:06:40 CEST
This happens on a UCS 4.2 system: root@master421:~# /tmp/univention-support-info Collecting command output: .............................................done. Collecting files: ...........................................................................................................................................................................................done. Searching for changed template files: done. Collecting package lists: Traceback (most recent call last): File "/tmp/univention-support-info", line 1099, in <module> main(options.encrypt) File "/tmp/univention-support-info", line 1057, in main aptPackageList() File "/tmp/univention-support-info", line 533, in aptPackageList packages = [_ for _ in cache if _.isInstalled] AttributeError: 'Package' object has no attribute 'isInstalled' root@master421:~#
CamelCase → .is_installed packages = [_ for _ in cache if _.is_installed]
This is the function in current USI. The first if statement checks for a deprecation attribute in apt. Maybe we do not need this statement anymore? def aptPackageList(): » """List installed packages and their source repository.""" » _sprint('Collecting package lists: ') » cache = apt.Cache() » packagesAll = tempfile.TemporaryFile(prefix='univention-support-info.') » packagesUnknownSource = tempfile.TemporaryFile(prefix='univention-support-info.') » if not hasattr(apt, 'deprecation'): # python apt 0.7.7 in UCS < 3.0 » » packages = [_ for _ in cache if _.isInstalled] » » for pkg in packages: » » » pkg._lookupRecord(True) » » » try: » » » » path = apt_pkg.ParseSection(pkg._records.Record)["Filename"] » » » except KeyError: » » » » print >> packagesUnknownSource, "%s\tUNKNOWN" % (pkg.name,) » » » » continue » » » cand = pkg._depcache.GetCandidateVer(pkg._pkg) » » » for packagefile, _ in cand.FileList: » » » » indexfile = cache._list.FindIndex(packagefile) » » » » if indexfile: » » » » » uri = indexfile.ArchiveURI(path) » » » » » print >> packagesAll, "%s\t%s" % (pkg.name, uri) » else: » » packages = [_ for _ in cache if _.is_installed] » » for pkg in packages: » » » version = pkg.installed.version » » » package = pkg.versions[version] » » » try: » » » » uri = package.uri » » » except StopIteration: » » » » print >> packagesUnknownSource, "%s\tUNKNOWN" % (pkg.name,) » » » » continue » » » print >> packagesAll, "%s\t%s" % (pkg.name, uri) » addFile('info/packages_all', None, packagesAll) » addFile('info/packages_unknown-source', None, packagesUnknownSource) » print 'done.'
The USI script must be compatbile with UCS 4.1 and UCS 4.2 at the same time, right?
of course, as well as in older UCS versions like 4.0 and maybe in a paedml which is still on 3.3 But I thought I could test it like this on a paedml: root@server:~# python Python 2.6.8 (unknown, Jun 14 2016, 08:36:22) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import apt >>> cache = apt.Cache() >>> packages = [_ for _ in cache if _.is_installed] >>> quit
The current version still does not work with UCS 4.2; is this going to be fixed? http://download.univention.de/download/scripts/univention-support-info
I removed the "if not hasattr(apt, 'deprecation'): # python apt 0.7.7 in UCS < 3.0" part from function def aptPackageList(). This will work for UCS versions 3 and higher.
Set status of old resolved issues to closed.