← Back to team overview

ubuntu-packaging-guide-team team mailing list archive

[Bug 1954595] Re: bzr dh-make crash - no attribute 'initialize_on_transport'

 

Test case:

	$ cat <<EOF >test-breezy.py
	#!/usr/bin/env python

	from breezy.bzr import (
	    controldir,
	)

	from breezy import (
	    transport,
	)

	if __name__ == "__main__":
	    print("DefaultFormat: %s" %
		controldir.ControlDirFormat.get_default_format())

	    to_transport = transport.get_transport("test_dir")
	    controldir.ControlDir.create_branch_convenience(
		to_transport.base,
		possible_transports=[to_transport])
	EOF

        $ chmod +x test-breezy.py

Problem:

	$ ./test-breezy.py
	DefaultFormat: None
	Traceback (most recent call last):
	  File "./test-breezy.py", line 17, in <module>
	    possible_transports=[to_transport])
	  File "/usr/lib/python2.7/dist-packages/breezy/controldir.py", line 653, in create_branch_convenience
	    controldir = klass.create(base, format, possible_transports)
	  File "/usr/lib/python2.7/dist-packages/breezy/controldir.py", line 851, in create
	    return format.initialize_on_transport(t)
	AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'

Fix:

        $ sed '2a from breezy.bzr import bzrdir' -i test-breezy.py

	$ ./test-breezy.py
	DefaultFormat: Meta directory format 1

** Description changed:

+ [Impact]
+ 
+  * The `bzr dh-make` step in the Ubuntu Packaging Guide [1] 
+    fails in Focal.
+  
+  * The alterantive `brz dh-make` (BReeZy instead of BaZaaR) 
+    fails in Focal and Bionic.
+  
+ [Test Plan]
+ 
+  * Prepare:
+    $ sudo apt-get install dh-make bzr-builddeb brz-debian
+    $ bzr whoami "Your Name <name@xxxxxxxxxxx>"
+    $ wget -O hello-2.10.tar.gz "http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz";
+    
+  * Test bazaar:
+    $ bzr dh-make hello 2.10 hello-2.10.tar.gz
+    
+  * Test breezy:
+    $ brz dh-make hello 2.10 hello-2.10.tar.gz
+ 
+  * On success, remove the generated dir/file for next tests.
+    $ rm -rf hello hello_2.10.orig.tar.gz
+ 
+ [Where problems could occur]
+ 
+  * The changes are restricted to the `dh-make` command 
+    in bazaar/breezy, which is broken, so it should not
+    make things worse.
+    
+    But, theoretically, `bzr/brz dh-make` is the impact
+    surface for other issues/regressions from previous/
+    working releases.
+ 
+ [Links]
+ 
+  * [1] https://packaging.ubuntu.com/html/packaging-new-
+ software.html#starting-a-package
+ 
+ [Other Info]
+ 
+  * Bionic is not affected in `bzr`, but just in `brz`,
+    due to being from 2 source packages: `bzr-builddeb`
+    and `breezy-debian`.
+    
+  * Focal is affected in both `bzr/brz` per transition
+    from `bzr-builddeb` to `breezy-debian` (1 src pkg).
+ 
+  * Impish+ are not "affected" as `dh-make` was dropped
+    by debian-breezy upstream.
+     
+  * The root cause of the regression is a dropped python
+   `import` in breezy-debian following changes in breezy.
+    
+    The `bzrdir` import sets ControlDir's default format:
+    `controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()`
+       
+    Once debian-breezy.git's dh_make.py:_get_tree() moved
+    from BzrDir. to ControlDir.create_branch_convenience()
+    and dropped the bzrlib import, that is not set anymore.
+    
+    Now, create_branch_convenience() calls create(), calls
+    initialize_on_transport() on the default format (None).
+ 
+ 	commit 08fcab340a2cd4f6bf0f5aec65c304a88023a4f8
+ 	Author: Jelmer Vernooij <jelmer@xxxxxxxxx>
+ 	Date:   Sat Jun 17 14:10:12 2017 +0000
+ 
+             Update for breezy, drop support for older versions of bazaar
+ and for debian_bundle.
+ 
+ 	...
+ 	diff --git a/dh_make.py b/dh_make.py
+ 	...
+ 	 from ... import (
+ 	-    bzrdir,
+ 	+    controldir,
+ 	...
+ 	@@ -34,22 +34,22 @@ def _get_tree(package_name):
+ 	...
+ 	-            create_branch = bzrdir.BzrDir.create_branch_convenience
+ 	...
+ 	+            create_branch = controldir.ControlDir.create_branch_convenience
+ 	...
+ 
+    Synthetic test cases for this are provided in bug comments.
+ 
+ [Original Bug Description]
+ 
  I am following official Ubuntu Packaging Guide:
  https://packaging.ubuntu.com/html/packaging-new-software.html
  
  When I come to the following part, the command crashes:
  
  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  (trackback bellow)
  
  My system:
  
  Description:	Ubuntu 20.04.3 LTS
  Release:	20.04
  dh-make:
-   Installed: 2.201903
-   Candidate: 2.201903
-   Version table:
-  *** 2.201903 500
-         500 http://cz.archive.ubuntu.com/ubuntu focal/main amd64 Packages
-         500 http://cz.archive.ubuntu.com/ubuntu focal/main i386 Packages
-         100 /var/lib/dpkg/status
- 
+   Installed: 2.201903
+   Candidate: 2.201903
+   Version table:
+  *** 2.201903 500
+         500 http://cz.archive.ubuntu.com/ubuntu focal/main amd64 Packages
+         500 http://cz.archive.ubuntu.com/ubuntu focal/main i386 Packages
+         100 /var/lib/dpkg/status
  
  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  
  Traceback (most recent call last):
-   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 26, in _get_tree
-     tree = workingtree.WorkingTree.open(".")
-   File "/usr/lib/python3/dist-packages/breezy/workingtree.py", line 201, in open
-     control = controldir.ControlDir.open(path, _unsupported=_unsupported)
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 706, in open
-     return klass.open_from_transport(t, probers=probers,
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
-     transport, format = _mod_transport.do_catching_redirections(
-   File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
-     return action(transport)
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
-     return transport, ControlDirFormat.find_format(transport,
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
-     raise errors.NotBranchError(path=transport.base)
+   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 26, in _get_tree
+     tree = workingtree.WorkingTree.open(".")
+   File "/usr/lib/python3/dist-packages/breezy/workingtree.py", line 201, in open
+     control = controldir.ControlDir.open(path, _unsupported=_unsupported)
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 706, in open
+     return klass.open_from_transport(t, probers=probers,
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
+     transport, format = _mod_transport.do_catching_redirections(
+   File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
+     return action(transport)
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
+     return transport, ControlDirFormat.find_format(transport,
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
+     raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/".
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
-   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 37, in _get_tree
-     a_controldir = controldir.ControlDir.open_from_transport(
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
-     transport, format = _mod_transport.do_catching_redirections(
-   File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
-     return action(transport)
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
-     return transport, ControlDirFormat.find_format(transport,
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
-     raise errors.NotBranchError(path=transport.base)
+   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 37, in _get_tree
+     a_controldir = controldir.ControlDir.open_from_transport(
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
+     transport, format = _mod_transport.do_catching_redirections(
+   File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
+     return action(transport)
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
+     return transport, ControlDirFormat.find_format(transport,
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
+     raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/hello/".
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
-   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1016, in exception_to_return_code
-     return the_callable(*args, **kwargs)
-   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1202, in run_bzr
-     ret = run(*run_argv)
-   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 759, in run_argv_aliases
-     return self.run(**all_cmd_args)
-   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 784, in run
-     return self._operation.run_simple(*args, **kwargs)
-   File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 136, in run_simple
-     return _do_with_cleanups(
-   File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 166, in _do_with_cleanups
-     result = func(*args, **kwargs)
-   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/cmds.py", line 1385, in run
-     tree = dh_make.import_upstream(
-   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 83, in import_upstream
-     tree = _get_tree(package_name)
-   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 42, in _get_tree
-     branch = create_branch(to_transport.base,
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 660, in create_branch_convenience
-     controldir = klass.create(base, format, possible_transports)
-   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 859, in create
-     return format.initialize_on_transport(t)
+   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1016, in exception_to_return_code
+     return the_callable(*args, **kwargs)
+   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1202, in run_bzr
+     ret = run(*run_argv)
+   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 759, in run_argv_aliases
+     return self.run(**all_cmd_args)
+   File "/usr/lib/python3/dist-packages/breezy/commands.py", line 784, in run
+     return self._operation.run_simple(*args, **kwargs)
+   File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 136, in run_simple
+     return _do_with_cleanups(
+   File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 166, in _do_with_cleanups
+     result = func(*args, **kwargs)
+   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/cmds.py", line 1385, in run
+     tree = dh_make.import_upstream(
+   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 83, in import_upstream
+     tree = _get_tree(package_name)
+   File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 42, in _get_tree
+     branch = create_branch(to_transport.base,
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 660, in create_branch_convenience
+     controldir = klass.create(base, format, possible_transports)
+   File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 859, in create
+     return format.initialize_on_transport(t)
  AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  
  You can report this problem to Bazaar's developers by running
-     apport-bug /var/crash/brz.1000.2021-12-12T15:32.crash
+     apport-bug /var/crash/brz.1000.2021-12-12T15:32.crash
  if a bug-reporting window does not automatically appear.

** Description changed:

  [Impact]
  
-  * The `bzr dh-make` step in the Ubuntu Packaging Guide [1] 
-    fails in Focal.
-  
-  * The alterantive `brz dh-make` (BReeZy instead of BaZaaR) 
-    fails in Focal and Bionic.
-  
+  * The `bzr dh-make` step in the Ubuntu Packaging Guide [1]
+    fails in Focal.
+ 
+  * The alterantive `brz dh-make` (BReeZy instead of BaZaaR)
+    fails in Focal and Bionic.
+ 
  [Test Plan]
  
-  * Prepare:
-    $ sudo apt-get install dh-make bzr-builddeb brz-debian
-    $ bzr whoami "Your Name <name@xxxxxxxxxxx>"
-    $ wget -O hello-2.10.tar.gz "http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz";
-    
-  * Test bazaar:
-    $ bzr dh-make hello 2.10 hello-2.10.tar.gz
-    
-  * Test breezy:
-    $ brz dh-make hello 2.10 hello-2.10.tar.gz
+  * Prepare:
+    $ sudo apt-get install dh-make bzr-builddeb brz-debian
+    $ bzr whoami "Your Name <name@xxxxxxxxxxx>"
+    $ wget -O hello-2.10.tar.gz "http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz";
  
-  * On success, remove the generated dir/file for next tests.
-    $ rm -rf hello hello_2.10.orig.tar.gz
+  * Test bazaar:
+    $ bzr dh-make hello 2.10 hello-2.10.tar.gz
+ 
+  * Test breezy:
+    $ brz dh-make hello 2.10 hello-2.10.tar.gz
+ 
+  * On success, remove the generated dir/file for next tests.
+    $ rm -rf hello hello_2.10.orig.tar.gz
  
  [Where problems could occur]
  
-  * The changes are restricted to the `dh-make` command 
-    in bazaar/breezy, which is broken, so it should not
-    make things worse.
-    
-    But, theoretically, `bzr/brz dh-make` is the impact
-    surface for other issues/regressions from previous/
-    working releases.
+  * The changes are restricted to the `dh-make` command
+    in bazaar/breezy, which is broken, so it should not
+    make things worse.
+ 
+    But, theoretically, `bzr/brz dh-make` is the impact
+    surface for other issues/regressions from previous/
+    working releases.
  
  [Links]
  
-  * [1] https://packaging.ubuntu.com/html/packaging-new-
+  * [1] https://packaging.ubuntu.com/html/packaging-new-
  software.html#starting-a-package
  
  [Other Info]
  
-  * Bionic is not affected in `bzr`, but just in `brz`,
-    due to being from 2 source packages: `bzr-builddeb`
-    and `breezy-debian`.
-    
-  * Focal is affected in both `bzr/brz` per transition
-    from `bzr-builddeb` to `breezy-debian` (1 src pkg).
+  * Bionic is not affected in `bzr`, but just in `brz`,
+    due to being from 2 source packages: `bzr-builddeb`
+    and `breezy-debian`.
  
-  * Impish+ are not "affected" as `dh-make` was dropped
-    by debian-breezy upstream.
-     
-  * The root cause of the regression is a dropped python
-   `import` in breezy-debian following changes in breezy.
-    
-    The `bzrdir` import sets ControlDir's default format:
-    `controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()`
-       
-    Once debian-breezy.git's dh_make.py:_get_tree() moved
-    from BzrDir. to ControlDir.create_branch_convenience()
-    and dropped the bzrlib import, that is not set anymore.
-    
-    Now, create_branch_convenience() calls create(), calls
-    initialize_on_transport() on the default format (None).
+  * Focal is affected in both `bzr/brz` per transition
+    from `bzr-builddeb` to `breezy-debian` (1 src pkg).
  
- 	commit 08fcab340a2cd4f6bf0f5aec65c304a88023a4f8
- 	Author: Jelmer Vernooij <jelmer@xxxxxxxxx>
- 	Date:   Sat Jun 17 14:10:12 2017 +0000
+  * Impish+ are not "affected" as `dh-make` was dropped
+    by debian-breezy upstream.
  
-             Update for breezy, drop support for older versions of bazaar
- and for debian_bundle.
+  * The root cause of the regression is a dropped python
+   `import` in breezy-debian following changes in breezy.
  
- 	...
- 	diff --git a/dh_make.py b/dh_make.py
- 	...
- 	 from ... import (
- 	-    bzrdir,
- 	+    controldir,
- 	...
- 	@@ -34,22 +34,22 @@ def _get_tree(package_name):
- 	...
- 	-            create_branch = bzrdir.BzrDir.create_branch_convenience
- 	...
- 	+            create_branch = controldir.ControlDir.create_branch_convenience
- 	...
+    The `bzrdir` import sets ControlDir's default format:
+    `controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()`
  
-    Synthetic test cases for this are provided in bug comments.
+    Once debian-breezy.git's dh_make.py:_get_tree() moved
+    from BzrDir. to ControlDir.create_branch_convenience()
+    and dropped the bzrlib import, that is not set anymore.
+ 
+    Now, create_branch_convenience() calls create(), calls
+    initialize_on_transport() on the default format (None).
+ 
+  commit 08fcab340a2cd4f6bf0f5aec65c304a88023a4f8
+  Author: Jelmer Vernooij <jelmer@xxxxxxxxx>
+  Date:   Sat Jun 17 14:10:12 2017 +0000
+ 
+      Update for breezy, drop support for older versions of bazaar and
+ for debian_bundle.
+ 
+  ...
+  diff --git a/dh_make.py b/dh_make.py
+  ...
+   from ... import (
+  -    bzrdir,
+  +    controldir,
+  ...
+  @@ -34,22 +34,22 @@ def _get_tree(package_name):
+  ...
+  -            create_branch = bzrdir.BzrDir.create_branch_convenience
+  ...
+  +            create_branch = controldir.ControlDir.create_branch_convenience
+  ...
+ 
+  * Synthetic test cases for this are provided in comment #1.
  
  [Original Bug Description]
  
  I am following official Ubuntu Packaging Guide:
  https://packaging.ubuntu.com/html/packaging-new-software.html
  
  When I come to the following part, the command crashes:
  
  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  (trackback bellow)
  
  My system:
  
  Description:	Ubuntu 20.04.3 LTS
  Release:	20.04
  dh-make:
    Installed: 2.201903
    Candidate: 2.201903
    Version table:
   *** 2.201903 500
          500 http://cz.archive.ubuntu.com/ubuntu focal/main amd64 Packages
          500 http://cz.archive.ubuntu.com/ubuntu focal/main i386 Packages
          100 /var/lib/dpkg/status
  
  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 26, in _get_tree
      tree = workingtree.WorkingTree.open(".")
    File "/usr/lib/python3/dist-packages/breezy/workingtree.py", line 201, in open
      control = controldir.ControlDir.open(path, _unsupported=_unsupported)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 706, in open
      return klass.open_from_transport(t, probers=probers,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
      transport, format = _mod_transport.do_catching_redirections(
    File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
      return action(transport)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
      return transport, ControlDirFormat.find_format(transport,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
      raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/".
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 37, in _get_tree
      a_controldir = controldir.ControlDir.open_from_transport(
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
      transport, format = _mod_transport.do_catching_redirections(
    File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
      return action(transport)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
      return transport, ControlDirFormat.find_format(transport,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
      raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/hello/".
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1016, in exception_to_return_code
      return the_callable(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1202, in run_bzr
      ret = run(*run_argv)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 759, in run_argv_aliases
      return self.run(**all_cmd_args)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 784, in run
      return self._operation.run_simple(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 136, in run_simple
      return _do_with_cleanups(
    File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 166, in _do_with_cleanups
      result = func(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/cmds.py", line 1385, in run
      tree = dh_make.import_upstream(
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 83, in import_upstream
      tree = _get_tree(package_name)
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 42, in _get_tree
      branch = create_branch(to_transport.base,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 660, in create_branch_convenience
      controldir = klass.create(base, format, possible_transports)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 859, in create
      return format.initialize_on_transport(t)
  AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  
  You can report this problem to Bazaar's developers by running
      apport-bug /var/crash/brz.1000.2021-12-12T15:32.crash
  if a bug-reporting window does not automatically appear.

-- 
You received this bug notification because you are a member of Ubuntu
Packaging Guide Team, which is subscribed to Ubuntu Packaging Guide.
https://bugs.launchpad.net/bugs/1954595

Title:
  bzr dh-make crash - no attribute 'initialize_on_transport'

Status in Ubuntu Packaging Guide:
  Confirmed
Status in breezy-debian package in Ubuntu:
  Invalid
Status in breezy-debian source package in Bionic:
  Confirmed
Status in breezy-debian source package in Focal:
  Confirmed

Bug description:
  [Impact]

   * The `bzr dh-make` step in the Ubuntu Packaging Guide [1]
     fails in Focal.

   * The alternative `brz dh-make` (BReeZy instead of BaZaaR)
     fails in Focal and Bionic.

   * The `dh-make` subcommand is not available in Impish/later.
     The Guide should be updated and ideally use another tool.

  [Test Plan]

   * Prepare:
     $ sudo apt-get install dh-make bzr-builddeb brz-debian
     $ bzr whoami "Your Name <name@xxxxxxxxxxx>"
     $ wget -O hello-2.10.tar.gz "http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz";

   * Test bazaar:
     $ bzr dh-make hello 2.10 hello-2.10.tar.gz

   * Test breezy:
     $ brz dh-make hello 2.10 hello-2.10.tar.gz

   * On success, remove the generated dir/file for next tests.
     $ rm -rf hello hello_2.10.orig.tar.gz

  [Where problems could occur]

   * The changes are restricted to the `dh-make` command
     in bazaar/breezy, which is broken, so it should not
     make things worse.

     But, theoretically, `bzr/brz dh-make` is the impact
     surface for other issues/regressions from previous/
     working releases.

  [Links]

   * [1] https://packaging.ubuntu.com/html/packaging-new-
  software.html#starting-a-package

  [Other Info]

   * Bionic is not affected in `bzr`, but just in `brz`,
     due to being from 2 source packages: `bzr-builddeb`
     and `breezy-debian`.

   * Focal is affected in both `bzr/brz` per transition
     from `bzr-builddeb` to `breezy-debian` (1 src pkg).

   * Impish+ are not "affected" as `dh-make` was dropped
     by debian-breezy upstream.

   * The root cause of the regression is a dropped python
    `import` in breezy-debian following changes in breezy.

     The `bzrdir` import sets ControlDir's default format:
     `controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()`

     Once debian-breezy.git's dh_make.py:_get_tree() moved
     from BzrDir. to ControlDir.create_branch_convenience()
     and dropped the bzrlib import, that is not set anymore.

     Now, create_branch_convenience() calls create(), calls
     initialize_on_transport() on the default format (None).

   commit 08fcab340a2cd4f6bf0f5aec65c304a88023a4f8
   Author: Jelmer Vernooij <jelmer@xxxxxxxxx>
   Date:   Sat Jun 17 14:10:12 2017 +0000

       Update for breezy, drop support for older versions of bazaar and
  for debian_bundle.

   ...
   diff --git a/dh_make.py b/dh_make.py
   ...
    from ... import (
   -    bzrdir,
   +    controldir,
   ...
   @@ -34,22 +34,22 @@ def _get_tree(package_name):
   ...
   -            create_branch = bzrdir.BzrDir.create_branch_convenience
   ...
   +            create_branch = controldir.ControlDir.create_branch_convenience
   ...

   * Synthetic test cases for this are provided in comment #1.

  [Original Bug Description]

  I am following official Ubuntu Packaging Guide:
  https://packaging.ubuntu.com/html/packaging-new-software.html

  When I come to the following part, the command crashes:

  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'
  (trackback bellow)

  My system:

  Description:	Ubuntu 20.04.3 LTS
  Release:	20.04
  dh-make:
    Installed: 2.201903
    Candidate: 2.201903
    Version table:
   *** 2.201903 500
          500 http://cz.archive.ubuntu.com/ubuntu focal/main amd64 Packages
          500 http://cz.archive.ubuntu.com/ubuntu focal/main i386 Packages
          100 /var/lib/dpkg/status

  $ bzr dh-make hello 2.10 hello-2.10.tar.gz
  brz: ERROR: AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 26, in _get_tree
      tree = workingtree.WorkingTree.open(".")
    File "/usr/lib/python3/dist-packages/breezy/workingtree.py", line 201, in open
      control = controldir.ControlDir.open(path, _unsupported=_unsupported)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 706, in open
      return klass.open_from_transport(t, probers=probers,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
      transport, format = _mod_transport.do_catching_redirections(
    File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
      return action(transport)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
      return transport, ControlDirFormat.find_format(transport,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
      raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/".

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 37, in _get_tree
      a_controldir = controldir.ControlDir.open_from_transport(
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 736, in open_from_transport
      transport, format = _mod_transport.do_catching_redirections(
    File "/usr/lib/python3/dist-packages/breezy/transport/__init__.py", line 1613, in do_catching_redirections
      return action(transport)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 724, in find_format
      return transport, ControlDirFormat.find_format(transport,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 1166, in find_format
      raise errors.NotBranchError(path=transport.base)
  breezy.errors.NotBranchError: Not a branch: "/home/jkalina/packaging/hello/".

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1016, in exception_to_return_code
      return the_callable(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 1202, in run_bzr
      ret = run(*run_argv)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 759, in run_argv_aliases
      return self.run(**all_cmd_args)
    File "/usr/lib/python3/dist-packages/breezy/commands.py", line 784, in run
      return self._operation.run_simple(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 136, in run_simple
      return _do_with_cleanups(
    File "/usr/lib/python3/dist-packages/breezy/cleanup.py", line 166, in _do_with_cleanups
      result = func(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/cmds.py", line 1385, in run
      tree = dh_make.import_upstream(
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 83, in import_upstream
      tree = _get_tree(package_name)
    File "/usr/lib/python3/dist-packages/breezy/plugins/debian/dh_make.py", line 42, in _get_tree
      branch = create_branch(to_transport.base,
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 660, in create_branch_convenience
      controldir = klass.create(base, format, possible_transports)
    File "/usr/lib/python3/dist-packages/breezy/controldir.py", line 859, in create
      return format.initialize_on_transport(t)
  AttributeError: 'NoneType' object has no attribute 'initialize_on_transport'

  You can report this problem to Bazaar's developers by running
      apport-bug /var/crash/brz.1000.2021-12-12T15:32.crash
  if a bug-reporting window does not automatically appear.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-packaging-guide/+bug/1954595/+subscriptions