← Back to team overview

apport-hackers team mailing list archive

[Merge] lp:~brian-murray/apport/pkg-is-native into lp:apport


Brian Murray has proposed merging lp:~brian-murray/apport/pkg-is-native into lp:apport.

Requested reviews:
  Apport upstream developers (apport-hackers)
Related bugs:
  Bug #1470572 in Apport: "native-origins.d information causes apport to strip origin information from Package"

For more details, see:

Bug 1470572 describes a situation where origin information is being stripped from Dependencies and Package sections of a bug report. This resolves that by separating out the check for native-origin.d information from is_distro_package. Its possible this isn't the most elegant solution as there is some code duplication, but it seemed the most straight forward and really should be SRU'ed to stable releases of Ubuntu.

The goal of the change is to preserve "[origin: .*]" data so that it can be used by my work to retrace packages from PPAs.  (This is required to determine from which PPA to download a specific package version.)  However, we don't want to prevent submitting reports about packages which have been white listed in native-origin.d.
Your team Apport upstream developers is requested to review the proposed merge of lp:~brian-murray/apport/pkg-is-native into lp:apport.
=== modified file 'apport/ui.py'
--- apport/ui.py	2015-05-20 14:55:08 +0000
+++ apport/ui.py	2015-07-01 19:36:42 +0000
@@ -122,7 +122,8 @@
             if 'CrashDB' not in report and 'APPORT_DISABLE_DISTRO_CHECK' not in os.environ:
                 if 'Package' not in report:
                     report['UnreportableReason'] = _('This package does not seem to be installed correctly')
-                elif not apport.packaging.is_distro_package(report['Package'].split()[0]):
+                elif not apport.packaging.is_distro_package(report['Package'].split()[0]) and  \
+                        not apport.packaging.is_native_origin_package(report['Package'].split()[0]):
                     # TRANS: %s is the name of the operating system
                     report['UnreportableReason'] = _(
                         'This is not an official %s package. Please remove any third party package and try again.') % report['DistroRelease'].split()[0]

=== modified file 'backends/packaging-apt-dpkg.py'
--- backends/packaging-apt-dpkg.py	2015-06-29 13:31:02 +0000
+++ backends/packaging-apt-dpkg.py	2015-07-01 19:36:42 +0000
@@ -182,6 +182,29 @@
             return False
         native_origins = [self.get_os_version()[0]]
+        if pkg.candidate and pkg.candidate.origins:  # might be None
+            for o in pkg.candidate.origins:
+                if o.origin in native_origins:
+                    return True
+        return False
+    def is_native_origin_package(self, package):
+        '''Check if a package is one which has been white listed.
+        Return True for a distro package or a package which came from an
+        origin which is listed in native-origins.d, False if it comes from a
+        third- party source.
+        '''
+        if self.is_distro_package(package):
+            return True
+        pkg = self._apt_pkg(package)
+        # some PPA packages have installed version None, see LP#252734
+        if pkg.installed and pkg.installed.version is None:
+            return False
+        native_origins = []
         for f in glob.glob('/etc/apport/native-origins.d/*'):
                 with open(f) as fd: