Bug 43886 - univention-support-info does not work on UCS 4.2
univention-support-info does not work on UCS 4.2
Status: CLOSED FIXED
Product: USI
Classification: Unclassified
Component: univention-support-info
unspecified
Other Linux
: P1 critical
: ---
Assigned To: USI maintainer
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-16 06:30 CET by Stefan Gohmann
Modified: 2017-09-15 14:06 CEST (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2017-03-16 06:30:01 CET
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:~#
Comment 1 Philipp Hahn univentionstaff 2017-03-16 12:24:38 CET
CamelCase → .is_installed

packages = [_ for _ in cache if _.is_installed]
Comment 2 Christina Scheinig univentionstaff 2017-03-17 16:02:29 CET
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.'
Comment 3 Florian Best univentionstaff 2017-03-17 16:18:21 CET
The USI script must be compatbile with UCS 4.1 and UCS 4.2 at the same time, right?
Comment 4 Christina Scheinig univentionstaff 2017-03-17 16:23:18 CET
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
Comment 5 Erik Damrose univentionstaff 2017-03-30 13:57:50 CEST
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
Comment 6 Christina Scheinig univentionstaff 2017-04-03 11:04:20 CEST
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.
Comment 7 Stefan Gohmann univentionstaff 2017-09-15 14:06:40 CEST
Set status of old resolved issues to closed.