Package: dkms
Version: 2.2.0.3-1.2
Followup-For: Bug #707008
Tags: patch

Am Mo, 06. Mai 2013 um 22:03:53 +0200 schrieb Matthias Liertzer:
> while updating the system to the newest version of linux-headers in unstable
> (linux-headers-3.8-1-amd64), dkms failed to run the package hooks for dkms. 
> The
> script in /usr/share/apport/package-hooks/dkms_packages.py failed because it
> imports the python module apport, which is, however, not installed on the
> machine. Installing python-apport and applying the following patch

I don't think it is wise to depend on a package which only exists in
experimental. Besides this, there is no need for dkms to depend on
python-apport as it only executes the package hook if apport is
installed. As apport pulls in the apport python module, everything
should be working as expected: Without installing apport everything is
working and people using apport should cope with the experimental nature
of… um… experimental. :)

However, /usr/sbin/dkms calls the hook if a build problem occurs (and
apport is installed) by executing it with python, which by default is a
symlink to python2. But apport pulls in the apport module for Python3.
And here we go. dkms will fail if it calls its apport-hook as Python2
doesn't know about Python3 modules.

There are several options:
 * Use the attached patches to fix dkms to call python3 explicitly and
   port the hook to Python3 (thanks to 2to3). The latter maybe need a
   bit more grooming as I didn't test it.
 * apport could at least suggest or recommend python-apport
 * Let dkms only suggest python-apport. This should be OK as suggestions
   won't be installed by default. So nobody is forced to install
   a) software from experimental or 
   b) apport, even if it wouldn't be experimental.

Dirk
--- /usr/sbin/dkms_a	2011-12-07 19:23:58.000000000 +0100
+++ /usr/sbin/dkms_b	2014-07-31 09:35:28.319051875 +0200
@@ -2997,8 +2997,8 @@
 report_build_problem()
 {
     #If apport is on the system, files a build problem
-    if [ -x /usr/share/apport/apport ] && which python>/dev/null; then
-	python /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
+    if [ -x /usr/share/apport/apport ] && which python3>/dev/null; then
+	python3 /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
     fi
     die "$@"
 }
--- /usr/share/apport/package-hooks/dkms_packages.py	(original)
+++ /usr/share/apport/package-hooks/dkms_packages.py	(refactored)
@@ -36,12 +36,12 @@
 options=optparser.parse_args()[0]
 
 if not options.module or not options.version:
-    print >> sys.stderr, 'ERROR (dkms apport): both -m and -v are required'
+    print('ERROR (dkms apport): both -m and -v are required', file=sys.stderr)
     sys.exit(2)
 
 package=packaging.get_file_package('/usr/src/' + options.module + '-' + options.version)
 if package is None:
-    print >> sys.stderr, 'ERROR (dkms apport): binary package for %s: %s not found' % (options.module,options.version)
+    print('ERROR (dkms apport): binary package for %s: %s not found' % (options.module,options.version), file=sys.stderr)
     sys.exit(1)
 
 if options.kernel:
@@ -50,9 +50,9 @@
 
     try:
         apport.packaging.is_distro_package(kernel_package)
-    except ValueError, e:
+    except ValueError as e:
         if e == 'package does not exist':
-            print >> sys.stderr, 'ERROR (dkms apport): kernel package %s is not supported' % (kernel_package)
+            print('ERROR (dkms apport): kernel package %s is not supported' % (kernel_package), file=sys.stderr)
             sys.exit(1)
 
 make_log=os.path.join('/var','lib','dkms',options.module,options.version,'build','make.log')
@@ -62,7 +62,7 @@
 try:
     report['SourcePackage'] = apport.packaging.get_source(package)
 except ValueError:
-    print >> sys.stderr, 'ERROR (dkms apport): unable to determine source package for %s' % package
+    print('ERROR (dkms apport): unable to determine source package for %s' % package, file=sys.stderr)
     sys.exit(3)
 try:
     version = packaging.get_version(package)
@@ -81,7 +81,7 @@
 if 'DKMSBuildLog' in report:
     this_year = str(datetime.today().year)
     if 'Segmentation fault' in report['DKMSBuildLog']:
-        print >> sys.stderr, 'ERROR (dkms apport): There was a segmentation fault when trying to build the module'
+        print('ERROR (dkms apport): There was a segmentation fault when trying to build the module', file=sys.stderr)
         sys.exit(1)
     dupe_sig = ''
     for line in report['DKMSBuildLog'].split('\n'):

Reply via email to