Bug#908072: diffoscope: `bin/diffoscope --list-debian-substvars` output depends on installed packages

Chris Lamb lamby at debian.org
Thu Sep 6 11:57:37 BST 2018


Hi Mattia,

> In particular, it seems "gnupg" and "rpm2cpio" are not printed if they
> are not installed.

This is due to:

 * The @tool_required decorator adds all tool names that were passed to
   it to a global variable at module import time (NB. not execution
   time; decorators are executed at import time)

 * Our substvar generation then loops over this global variable.

 * Therefore if a module is is never fully imported then the  
   @tool_required will not be encountered.

The following is from diffoscope/comparators/rpm.py. As the "import
rpm" will fail if python3-rpm is not installed, the @tool_required will
not be imported.

  […]

  import rpm

  […]

  class RpmContainer(Archive):
      @tool_required('rpm2cpio')
      def extract(self, member_name, dest_dir):
          […]

Ideas? Hard-code the additions of gnupg or rpm2cpio in
ListDebianSubstvarsAction? Perhaps it would be cleaner to add some
explicit call in the RPM comparator, for example:

    - import rpm
    + try:
    +    import rpm
    + except ImportError:
    +    tool_required.all.add('rpm2cpio') # lol hack
    + raise

… but this is not terribly nice in itself.


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-



More information about the Reproducible-builds mailing list