diff -Nru mdadm-3.3/debian/changelog mdadm-3.3/debian/changelog --- mdadm-3.3/debian/changelog 2015-06-16 02:48:09.000000000 -0700 +++ mdadm-3.3/debian/changelog 2016-05-18 16:20:55.000000000 -0700 @@ -1,3 +1,10 @@ +mdadm (3.3-2ubuntu2.1) wily; urgency=medium + + * debian/source_mdadm.py: fix bytes versus strings mismatch that + caused the apport hook to fail (LP: #1583279) + + -- Steve Beattie Wed, 18 May 2016 16:18:51 -0700 + mdadm (3.3-2ubuntu2) wily; urgency=medium * debian/dmraid2mdadm.cfg: Only append to GRUB_CMDLINE_LINUX_DEFAULT one diff -Nru mdadm-3.3/debian/source_mdadm.py mdadm-3.3/debian/source_mdadm.py --- mdadm-3.3/debian/source_mdadm.py 2014-07-16 08:02:56.000000000 -0700 +++ mdadm-3.3/debian/source_mdadm.py 2016-05-18 16:18:42.000000000 -0700 @@ -1,17 +1,18 @@ '''apport package hook for mdadm -(c) 2009-2012 Canonical Ltd. +(c) 2009-2016 Canonical Ltd. Author: Steve Beattie Based on the ideas in debian's /usr/share/bug/mdadm/script ''' from apport.hookutils import * -from os import path +import os import re import glob import gzip import subprocess +import sys def get_initrd_files(pattern): '''Extract listing of files from the current initrd which match a regex. @@ -21,13 +22,16 @@ (_, _, release, _, _) = os.uname() try: fd = gzip.GzipFile('/boot/initrd.img-' + release, 'rb') + # universal_newlines needs to be False here as we're passing + # binary data from gzip into cpio, which means we'll need to + # decode the bytes into strings later when reading the output cpio = subprocess.Popen(['cpio', '-t'], close_fds=True, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=True) + universal_newlines=False) except OSError as e: return 'Error: ' + str(e) - out = cpio.communicate(fd.read())[0] + out = cpio.communicate(fd.read())[0].decode(sys.stdout.encoding, errors='replace') if cpio.returncode != 0: return 'Error: command %s failed with exit code %i %' % ( 'cpio', cpio.returncode, out)