Bug 2046638

Summary: diffoscope doesn't work, assumes it's on Debian
Product: [Fedora] Fedora Reporter: Michel Lind <michel>
Component: python-aptAssignee: Neal Gompa <ngompa13>
Status: CLOSED ERRATA QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 35CC: ngompa13, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: python-apt-2.3.0-1.fc34 python-apt-2.3.0-1.fc35 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-01-31 01:11:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michel Lind 2022-01-27 05:53:44 UTC
Description of problem:
On aarch64, diffoscope can't compare two RPM files, it tries to import debian.debian_support and failed.

I tried to simplify the test case and it turns out `diffoscope --help` also failed the same way.

Version-Release number of selected component (if applicable):
diffoscope-193-1.fc35.aarch64

How reproducible:
Always

Steps to Reproduce:
1. dnf install diffoscope (or, on x86_64, mock -r fedora-35-aarch64 --forcearch=aarch64 install diffoscope
2. diffoscope --help


Actual results:
❯ diffoscope --help
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/diffoscope/main.py", line 744, in main
    parsed_args = parser.parse_args(args)
  File "/usr/lib64/python3.10/argparse.py", line 1825, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.10/argparse.py", line 1858, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.10/argparse.py", line 2067, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.10/argparse.py", line 2007, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.10/argparse.py", line 1935, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib64/python3.10/argparse.py", line 1098, in __call__
    parser.print_help()
  File "/usr/lib64/python3.10/argparse.py", line 2555, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/lib64/python3.10/argparse.py", line 2539, in format_help
    return formatter.format_help()
  File "/usr/lib/python3.10/site-packages/diffoscope/main.py", line 493, in format_help
    ComparatorManager().format_descriptions(),
  File "/usr/lib/python3.10/site-packages/diffoscope/comparators/__init__.py", line 127, in __init__
    self.reload()
  File "/usr/lib/python3.10/site-packages/diffoscope/comparators/__init__.py", line 138, in reload
    mod = importlib.import_module(
  File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/diffoscope/comparators/debian.py", line 24, in <module>
    from debian.deb822 import Dsc, Deb822
  File "/usr/lib/python3.10/site-packages/debian/deb822.py", line 283, in <module>
    import debian.debian_support
  File "/usr/lib/python3.10/site-packages/debian/debian_support.py", line 46, in <module>
    apt_pkg.init()
apt_pkg.Error: W:Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory), E:Unable to determine a suitable pa
ckaging system type

Expected results:
should print out the help. also comparing two RPMs should work, as in https://fedoramagazine.org/use-diffoscope-in-packager-workflows/

Additional info:
Tested on a Fedora Linux Workstation 35 VM on a MacBook Pro M1

Comment 1 Zbigniew Jędrzejewski-Szmek 2022-01-27 11:25:55 UTC
This is not architecture-specific. The issue occurs when python3-apt is installed, but not dpkg.

python-apt is somehow confused:

$ python3 -c 'import apt_pkg; apt_pkg.init()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
apt_pkg.Error: W:Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory), E:Unable to determine a suitable packaging system type

The first issue is that it reports "DirectoryExists" when it in fact doesn't.

This causes the import of debian.deb822 fails:

$ python3 -c 'import debian.deb822'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/debian/deb822.py", line 283, in <module>
    import debian.debian_support
  File "/usr/lib/python3.10/site-packages/debian/debian_support.py", line 46, in <module>
    apt_pkg.init()
apt_pkg.Error: W:Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory), E:Unable to determine a suitable packaging system type

I think this would be best to resolve the issue either in python-apt or python-debian.
The import of the module should not fail with an exception.

Comment 2 Fedora Update System 2022-01-27 13:52:59 UTC
FEDORA-2022-5a15b7ab52 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2022-5a15b7ab52

Comment 3 Fedora Update System 2022-01-27 13:53:06 UTC
FEDORA-2022-3f6e44d506 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-3f6e44d506

Comment 4 Michel Lind 2022-01-27 19:58:40 UTC
Yup, just noticed it failed on x86_64 as well, thanks.

Comment 5 Fedora Update System 2022-01-27 22:34:02 UTC
FEDORA-2022-5a15b7ab52 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-5a15b7ab52`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-5a15b7ab52

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2022-01-27 22:51:55 UTC
FEDORA-2022-3f6e44d506 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-3f6e44d506`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-3f6e44d506

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2022-01-31 01:11:52 UTC
FEDORA-2022-5a15b7ab52 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2022-01-31 01:14:47 UTC
FEDORA-2022-3f6e44d506 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.