apport-hackers team mailing list archive
-
apport-hackers team
-
Mailing list archive
-
Message #00153
[Merge] lp:~brian-murray/apport/use-more-contents.gz into lp:apport
Brian Murray has proposed merging lp:~brian-murray/apport/use-more-contents.gz into lp:apport.
Requested reviews:
Apport upstream developers (apport-hackers)
Related bugs:
Bug #1271258 in Apport: "apport-retrace fails with crash files with libraries not from the release pocket"
https://bugs.launchpad.net/apport/+bug/1271258
For more details, see:
https://code.launchpad.net/~brian-murray/apport/use-more-contents.gz/+merge/202566
Bug 1271258 has details regarding this change.
--
https://code.launchpad.net/~brian-murray/apport/use-more-contents.gz/+merge/202566
Your team Apport upstream developers is requested to review the proposed merge of lp:~brian-murray/apport/use-more-contents.gz into lp:apport.
=== modified file 'backends/packaging-apt-dpkg.py'
--- backends/packaging-apt-dpkg.py 2013-11-18 07:08:25 +0000
+++ backends/packaging-apt-dpkg.py 2014-01-21 22:47:21 +0000
@@ -836,44 +836,55 @@
release = self.get_distro_codename()
else:
release = self._distro_release_to_codename(release)
-
- map = os.path.join(dir, '%s-Contents-%s.gz' % (release, arch))
-
- # check if map exists and is younger than a day; if not, we need to
- # refresh it
- try:
- st = os.stat(map)
- age = int(time.time() - st.st_mtime)
- except OSError:
- age = None
-
- if age is None or age >= 86400:
- url = '%s/dists/%s/Contents-%s.gz' % (self._get_mirror(), release, arch)
-
- src = urlopen(url)
- with open(map, 'wb') as f:
- while True:
- data = src.read(1000000)
- if not data:
- break
- f.write(data)
- src.close()
- assert os.path.exists(map)
-
- if file.startswith('/'):
- file = file[1:]
-
- # zgrep is magnitudes faster than a 'gzip.open/split() loop'
- package = None
- zgrep = subprocess.Popen(['zgrep', '-m1', '^%s[[:space:]]' % file, map],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out = zgrep.communicate()[0].decode('UTF-8')
- # we do not check the return code, since zgrep -m1 often errors out
- # with 'stdout: broken pipe'
- if out:
- package = out.split()[1].split(',')[0].split('/')[-1]
-
- return package
+ not_found = False
+ for pocket in ['updates', 'security', 'proposed', '']:
+ if pocket == '':
+ map = os.path.join(dir, '%s-Contents-%s.gz' % (release, arch))
+ else:
+ map = os.path.join(dir, '%s-%s-Contents-%s.gz' % (release, pocket, arch))
+
+ # check if map exists and is younger than a day; if not, we need to
+ # refresh it
+ try:
+ st = os.stat(map)
+ age = int(time.time() - st.st_mtime)
+ except OSError:
+ age = None
+
+ if age is None or age >= 86400:
+ if pocket == '':
+ url = '%s/dists/%s/Contents-%s.gz' % (self._get_mirror(), release, arch)
+ else:
+ url = '%s/dists/%s-%s/Contents-%s.gz' % (self._get_mirror(), release, pocket, arch)
+
+ src = urlopen(url)
+ with open(map, 'wb') as f:
+ while True:
+ data = src.read(1000000)
+ if not data:
+ break
+ f.write(data)
+ src.close()
+ assert os.path.exists(map)
+
+ if file.startswith('/'):
+ file = file[1:]
+
+ # zgrep is magnitudes faster than a 'gzip.open/split() loop'
+ package = None
+ zgrep = subprocess.Popen(['zgrep', '-m1', '^%s[[:space:]]' % file, map],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out = zgrep.communicate()[0].decode('UTF-8')
+ # we do not check the return code, since zgrep -m1 often errors out
+ # with 'stdout: broken pipe'
+ if out:
+ package = out.split()[1].split(',')[0].split('/')[-1]
+ if not package:
+ not_found = True
+ else:
+ return package
+ if not_found:
+ return None
@classmethod
def _build_apt_sandbox(klass, apt_root, apt_sources):
Follow ups