Bug 49130 - Migrate base/univention-debug to dh_python2
Migrate base/univention-debug to dh_python2
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: General
UCS 4.4
All Linux
: P5 normal (vote)
: UCS 4.4-0-errata
Assigned To: Philipp Hahn
Florian Best
:
Depends on: 42480 49506
Blocks: 28497
  Show dependency treegraph
 
Reported: 2019-03-28 10:25 CET by Florian Best
Modified: 2019-07-11 12:23 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
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
updater-from-errata107.log (16.46 MB, text/x-log)
2019-05-21 19:32 CEST, Arvid Requate
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2019-03-28 10:25:30 CET
The package base/univention-debug should be migrated to use dh_python instead of python-support.

Migration-Guide: https://hutten.knut.univention.de/mediawiki/index.php/Python_DebHelper_Migration
Comment 1 Florian Best univentionstaff 2019-05-15 09:40:32 CEST
Please consider Jürns WIP branch:
https://git.knut.univention.de/univention/ucs/commit/d7de9a49ce00d24292442ba4cebc5390500b8f11
Comment 2 Philipp Hahn univentionstaff 2019-05-17 17:30:44 CEST
[4.4-0] 8896e4cb61 Bug #49130: univention.debug
[4.4-0] d57be2fe6c Bug #43422 debug.py: logging function decorator
 base/univention-debug-python/debian/changelog      |  1 +
 .../python/univention/debug.py                     | 72 ++++++++++++++++++++--
 .../python/univention/debug2.py                    | 70 +++++++++++++++++++++
 base/univention-debug-python/tests/test_debug.py   | 64 +++++++++++++++++++
 base/univention-debug-python/tests/test_debug2.py  | 64 +++++++++++++++++++
 5 files changed, 266 insertions(+), 5 deletions(-)

[4.4-0] c07ab8006f Bug #46100 debug.py: Unify argument names
 .../python/univention/debug.py                     | 38 +++++++++--
 .../python/univention/debug2.py                    | 76 ++++++++++++----------
 .../python/univention/py_debug.c                   | 24 +++----
 3 files changed, 85 insertions(+), 53 deletions(-)

[4.4-0] f126bcf770 Bug #46100 debug.py: Refactor flushing
 .../python/univention/debug2.py                    | 28 ++++++++++------------
 1 file changed, 13 insertions(+), 15 deletions(-)

[4.4-0] 72013be81a Bug #46100 debug.py: Fix exception handling
 .../python/univention/debug2.py                      | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

[4.4-0] 3870bf230b Bug #46100 debug.py: Remove global declaration
 base/univention-debug-python/python/univention/debug2.py | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

[4.4-0] 3b009c2b82 Bug #46100 debug.py: debug2: add debug2.exit()
 .../python/univention/debug2.py                    | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

[4.4-0] b23a2ffb0e Bug #46100 debug.py: debug2: Adapt output format
 base/univention-debug-python/python/univention/debug2.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

[4.4-0] 04e642e601 Bug #46100 debug.py: debug2: Add missing get_level()
 base/univention-debug-python/python/univention/debug2.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

[4.4-0] 128e2a2ca3 Bug #46100 debug.py: debug2: Store UCR log level
 base/univention-debug-python/python/univention/debug2.py | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

[4.4-0] f651aa251f Bug #46100 debug.py: debug2: Return File form init()
 base/univention-debug-python/python/univention/debug2.py | 6 ++++++
 1 file changed, 6 insertions(+)

[4.4-0] 6077464e06 Bug #46100 debug.py: debug2: Add missing log targets
 base/univention-debug-python/debian/changelog        |  1 +
 .../python/univention/debug2.py                      | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

[4.4-0] a93d10c4a6 Bug #49130 debug.py: py3: Make module Python3 compatible
 .../python/univention/py_debug.c                   | 37 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

[4.4-0] 928fca5b5d Bug #49130 debug.py: py3: Convert to pytest
 base/univention-debug-python/debian/control        |   2 +-
 .../debian/ucslint.overrides                       |   2 +
 .../python/univention/debug2-test.py               |  94 ---------
 base/univention-debug-python/tests/test.out        |   6 -
 base/univention-debug-python/tests/test_compare.py |  19 ++
 base/univention-debug-python/tests/test_debug.py   | 227 ++++++++++++++++++---
 base/univention-debug-python/tests/test_debug2.py  | 212 +++++++++++++++++++
 base/univention-debug-python/tests/test_py         |   6 -
 8 files changed, 437 insertions(+), 131 deletions(-)

[4.4-0] 09caf7b2db Bug #49130 debug.py: py3: Convert to new object model
 base/univention-debug-python/python/univention/debug.py  | 7 ++++---
 base/univention-debug-python/python/univention/debug2.py | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

[4.4-0] 3c195fc6ec Bug #49130 debug.py: py3: from __future__ import print_function
 base/univention-debug-python/debian/control              | 2 ++
 base/univention-debug-python/python/univention/debug2.py | 7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

[4.4-0] 0dbf6d85e0 Bug #49130 debug.py: Simplify returning None
 .../python/univention/py_debug.c                    | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

[4.4-0] 4b6a5cdaac Bug #49130 debug.py: Use METH_NOARGS
 base/univention-debug-python/python/univention/py_debug.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

[4.4-0] 1db2fce824 Bug #49130 debug.c: Do not close stdout / stderr
 base/univention-debug/lib/debug.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

[4.4-0] 97012bdfcf Bug #49130 debug.c: Check valid arguments
 base/univention-debug/lib/debug.c | 62 +++++++++++++++++++++++++++++----------
 1 file changed, 47 insertions(+), 15 deletions(-)

[4.4-0] 8476f02454 Bug #49130 debug.c: Make debug levels/categories constant
 base/univention-debug/lib/debug.c | 60 +++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

[4.4-0] d5bf923d87 Bug #49130 debug.c: Extract logging code
 base/univention-debug/lib/debug.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

[4.4-0] 12f775c47b Bug #49130 debug.c: Statically allocate level array
 base/univention-debug/lib/debug.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

[4.4-0] fc13215b2c Bug #49130 debug.c: Fix compiler warning
 base/univention-debug/lib/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[4.4-0] bdd0cf6523 Bug #49130 debug: Split Python binding into separate package
 base/univention-debug-python/debian/changelog      |  5 +++
 base/univention-debug-python/debian/compat         |  1 +
 base/univention-debug-python/debian/control        | 47 ++++++++++++++++++++++
 base/univention-debug-python/debian/copyright      | 29 +++++++++++++
 .../debian/rules}                                  | 21 +++++-----
 .../debian/ucslint.overrides                       |  3 ++
 .../python/univention/__init__.py                  |  1 +
 .../python/univention}/debug.py                    |  0
 .../python/univention}/debug2-test.py              |  0
 .../python/univention}/debug2.py                   |  0
 .../python/univention}/py_debug.c                  |  0
 .../setup.py}                                      | 32 ++++++++++-----
 base/univention-debug-python/tests/test.out        |  6 +++
 .../tests/test_debug.py                            |  0
 .../tests/test_py                                  |  4 +-
 base/univention-debug/configure.in                 |  4 +-
 base/univention-debug/debian/changelog             |  6 +++
 base/univention-debug/debian/control               | 34 ++++------------
 .../debian/python-univention-debug.install         |  1 -
 base/univention-debug/debian/rules                 | 16 ++------
 base/univention-debug/debian/ucslint.overrides     |  4 --
 base/univention-debug/tests/Makefile.am            |  4 --
 22 files changed, 143 insertions(+), 75 deletions(-)

Package: univention-debug
Version: 11.0.0-2A~4.4.0.201905171721
Branch: ucs_4.4-0
Scope: errata4.4-0

...
Comment 3 Philipp Hahn univentionstaff 2019-05-20 13:56:22 CEST
[4.4-0] 517e02987f Bug #46100 debug.py: Fix namespace dependency
 base/univention-debug-python/.gitignore     | 9 +++++++++
 base/univention-debug-python/debian/control | 3 +--
 base/univention-debug-python/debian/rules   | 5 +++++
 3 files changed, 15 insertions(+), 2 deletions(-)

[4.4-0] 44e5c53459 Bug #46100 debug.py: Fix source package name
 base/univention-debug-python/debian/changelog | 2 +-
 base/univention-debug-python/debian/control   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

[4.4-0] 3f1c202f65 Bug #46100 debug.py: Fix encoding issues
 base/univention-debug-python/tests/test_debug.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[4.4-0] c00872a104 Bug #46100 debug.py: Fix encoding issues 2
 base/univention-debug-python/debian/rules | 1 +
 1 file changed, 1 insertion(+)

Package: univention-debug-python
Version: 1.0.0-1A~4.4.0.201905201332
Branch: ucs_4.4-0
Scope: errata4.4-0

[4.4-0] f78f7c4d55 Bug #49130: univention-debug 11.0.0-2A~4.4.0.201905171721 Bug #49130: univention-debug-python 1.0.0-1A~4.4.0.201905201308
 doc/errata/staging/univention-debug-python.yaml | 13 +++++++++++++
 doc/errata/staging/univention-debug.yaml        | 11 +++++++++++
 doc/errata/staging/univention-python.yaml       |  2 +-
 3 files changed, 25 insertions(+), 1 deletion(-)

QA: To simplify handling the new Python build using "pybuild" supporting Python3 the Python bindings has been split from the C implementation into the new source package "univention-debug-python".
QA: See unit tests "tests/test_debug*.py"
Comment 4 Florian Best univentionstaff 2019-05-20 17:39:56 CEST
# apt-cache policy python-univention-debug
python-univention-debug:
  Installiert:           10.0.0-3A~4.3.0.201712211325
  Installationskandidat: 10.0.0-3A~4.3.0.201712211325
  Versionstabelle:
 *** 10.0.0-3A~4.3.0.201712211325 500
        500 http://univention-repository.knut.univention.de/4.3/maintained 4.3-0/amd64/ Packages
        100 /var/lib/dpkg/status
     9.0.0-2A~4.2.0.201702011605 500
        500 http://univention-repository.knut.univention.de/4.2/maintained 4.2-0/amd64/ Packages
     8.0.1-1.94.201511032313 500
        500 http://univention-repository.knut.univention.de/4.1/maintained 4.1-0/amd64/ Packages
     7.0.1-6.90.201412151337 500
        500 http://univention-repository.knut.univention.de/4.0/maintained 4.0-1/amd64/ Packages
     7.0.1-5.87.201407150951 500
        500 http://univention-repository.knut.univention.de/4.0/maintained 4.0-0/amd64/ Packages
     1.0.0-1A~4.4.0.201905201332 500
        500 http://omar.knut.univention.de/build2 ucs_4.4-0-errata4.4-0/amd64/ Packages


→ Version 1.0.0-1 is smaller than 10.0.0-3.
Comment 5 Florian Best univentionstaff 2019-05-20 18:24:36 CEST
Regression:
>>> ud.debug(99, ud.LDAP, 'test')
→ prints nothing anymore

We are using this feature for sensitive information in:
ucs/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py
  1263 »   »   univention.debug.debug(univention.debug.ADMIN, 99, 'Create dn=%r;\naddlist=%r;' % (self.dn, al))
Comment 6 Florian Best univentionstaff 2019-05-20 18:29:32 CEST
two spaces in "logging  library"
base/univention-debug-python/debian/control
Comment 7 Philipp Hahn univentionstaff 2019-05-21 09:00:45 CEST
(In reply to Florian Best from comment #5)
> Regression:
No:
>> ud.debug(99, ud.LDAP, 'test')
            ^^  ^^^^^^^swapped
>> univention.debug.debug(univention.debug.ADMIN, 99, '...')
                          ^^^^^^^category^^^^^^^  ^^level

# python -c 'import univention.debug as ud;ud.init("stdout",0,0);ud.set_level(ud.MAIN,99);ud.debug(ud.MAIN,99,"works")'
> 21.05.19 08:59:52.206  DEBUG_INIT
> 21.05.19 08:59:52.206  MAIN        ( 99      ) : works


(In reply to Florian Best from comment #6)
> two spaces in "logging  library"
> base/univention-debug-python/debian/control

fixed:

[4.4-0] a69a2614ce Bug #49130 debug.py: Split Python binding into separate package                                                   
 base/univention-debug-python/debian/changelog | 6 ++++++                                                                            
 base/univention-debug-python/debian/control   | 4 ++--                                                                              
 2 files changed, 8 insertions(+), 2 deletions(-)                                                                                    
                                                                                                                                     

(In reply to Florian Best from comment #4)
> # apt-cache policy python-univention-debug
...
> → Version 1.0.0-1 is smaller than 10.0.0-3.

Thanks, fixed:

[4.4-0] fb70af211a Bug #49130 debug: Fix cleanup mechanism                                                                           
 base/univention-debug/debian/changelog |  6 ++++++                                                                                  
 base/univention-debug/debian/clean     | 15 +++++++++++++++                                                                         
 base/univention-debug/debian/rules     |  4 +---                                                                                    
 3 files changed, 22 insertions(+), 3 deletions(-)                                                                                   

Package: univention-debug
Version: 11.0.0-3A~4.4.0.201905210819
Branch: ucs_4.4-0
Scope: errata4.4-0

Package: univention-debug-python
Version: 11.0.0-2A~4.4.0.201905210851
Branch: ucs_4.4-0
Scope: errata4.4-0

[4.4-0] 7321b390a1 Bug #49130: univention-debug[-python]
 doc/errata/staging/univention-debug-python.yaml | 2 +-
 doc/errata/staging/univention-debug.yaml        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Comment 8 Florian Best univentionstaff 2019-05-21 15:56:41 CEST
# python3 -c 'import univention.debug as ud;ud.init("stdout",0,0);'
14.05.19 02:40:13.392  DEBUG_INIT
Traceback (most recent call last):
  File "<string>", line 1, in <module>
OSError: [Errno 29] Illegal seek
Comment 9 Arvid Requate univentionstaff 2019-05-21 18:49:35 CEST
The package update from errata4.4-0 (unrelease) fails currently:


Die folgenden NEUEN Pakete werden installiert:
  python-univention-namespace
[...]
Vorbereitung zum Entpacken von .../32-univention-samba4_8.0.0-24A~4.4.0.201905211223_amd64.deb ...
Traceback (most recent call last):
  File "/usr/sbin/univention-config-registry", line 45, in <module>
    import univention.config_registry as ub
ImportError: No module named config_registry
[...]
univention-errata-level (4.4.0-109) wird eingerichtet ...
Traceback (most recent call last):
  File "/usr/sbin/ucr", line 45, in <module>
    import univention.config_registry as ub
ImportError: No module named config_registry
Comment 10 Florian Best univentionstaff 2019-05-21 18:50:48 CEST
(In reply to Arvid Requate from comment #9)
> The package update from errata4.4-0 (unrelease) fails currently:
> 
> 
> Die folgenden NEUEN Pakete werden installiert:
>   python-univention-namespace
> [...]
> Vorbereitung zum Entpacken von
> .../32-univention-samba4_8.0.0-24A~4.4.0.201905211223_amd64.deb ...
> Traceback (most recent call last):
>   File "/usr/sbin/univention-config-registry", line 45, in <module>
>     import univention.config_registry as ub
> ImportError: No module named config_registry
> [...]
> univention-errata-level (4.4.0-109) wird eingerichtet ...
> Traceback (most recent call last):
>   File "/usr/sbin/ucr", line 45, in <module>
>     import univention.config_registry as ub
> ImportError: No module named config_registry

This is Bug #49506.
Comment 11 Arvid Requate univentionstaff 2019-05-21 19:32:13 CEST
Created attachment 10039 [details]
updater-from-errata107.log

The attached log file shows the univention-upgrade from errata 107 to unreleased errata4.4-0. Strangely the update works when i first update to errata109 and then to unreleased errata4.4-0.

The update from errata107 also works when I run "univention-install python-univention-namespace" before running univention-upgrade. Maybe some dependency issue? Some interference with Bug 49129?
Comment 12 Arvid Requate univentionstaff 2019-05-21 19:48:11 CEST
Ah, Felix already reported this at Bug 49506 Comment 2.
Comment 13 Philipp Hahn univentionstaff 2019-05-22 11:59:07 CEST
(In reply to Florian Best from comment #8)
> # python3 -c 'import univention.debug as ud;ud.init("stdout",0,0);'
> 14.05.19 02:40:13.392  DEBUG_INIT
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> OSError: [Errno 29] Illegal seek

Bug #22552 changed univention_debug_init() to return the file descriptor of the opened file. The Python bind converts it to a Python File() object.
With Python3 there is an unfortunate API change: Modules/_io/fileio.c is used with implements "append mode" itself by always performing a lseek() before write()ing, but STDOUT and STDERR are not seekable.

[4.4-0] 1baccbaad7 Bug #49130 debug.py: Fix PyFile_FromFd() with Python3
 base/univention-debug-python/debian/changelog      |  6 ++++
 .../python/univention/py_debug.c                   |  3 +-
 base/univention-debug-python/tests/test_debug.py   | 33 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

Package: univention-debug-python
Version: 11.0.0-3A~4.4.0.201905221148
Branch: ucs_4.4-0
Scope: errata4.4-0

[4.4-0] 451bb59817 Bug #49130: univention-debug-python 11.0.0-3A~4.4.0.201905221148
 doc/errata/staging/univention-debug-python.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 14 Florian Best univentionstaff 2019-05-24 12:19:30 CEST
OK: looks fine
OK: YAML