install_packages() makes an assumption that a downloaded package has been extracted

Bug #1659122 reported by Brian Murray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Medium
Brian Murray

Bug Description

From backends/packaging-apt-dpkg.py:

1009 last_written = time.time()
1010 # fetch packages
1011 try:
1012 cache.fetch_archives(fetcher=fetcher)
1013 except apt.cache.FetchFailedException as e:
1014 apport.error('Package download error, try again later: %s', str(e))
1015 sys.exit(1) # transient error
1016
1017 if verbose:
1018 print('Extracting downloaded debs...')
1019 for i in fetcher.items:
1020 if not permanent_rootdir or os.path.getctime(i.destfile) > last_written:

The check "os.path.getctime(i.destfile) > last_written" assumes that i.destfile has been extracted in rootdir if it exists at all. However, its possible we retraced this crash one time without a permanent_rootdir, then switched to using one, in which case i.destfile would be < than last_written but it would not have been extracted in our new rootdir.

Related branches

Changed in apport:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote :

I think checking in pkg_versions for the package and version would resolve this issue.

Revision history for this message
Brian Murray (brian-murray) wrote :

This change fixes it.

=== modified file 'backends/packaging-apt-dpkg.py'
--- backends/packaging-apt-dpkg.py 2017-01-23 18:32:36 +0000
+++ backends/packaging-apt-dpkg.py 2017-01-24 22:34:59 +0000
@@ -1047,9 +1047,11 @@
         if verbose:
             print('Extracting downloaded debs...')
         for i in fetcher.items:
- if not permanent_rootdir or os.path.getctime(i.destfile) > last_written:
- out = subprocess.check_output(['dpkg-deb', '--show', i.destfile]).decode()
- (p, v) = out.strip().split()
+ out = subprocess.check_output(['dpkg-deb', '--show', i.destfile]).decode()
+ (p, v) = out.strip().split()
+ if not permanent_rootdir or p not in pkg_versions or os.path.getctime(i.destfile) > last_written:
+ #out = subprocess.check_output(['dpkg-deb', '--show', i.destfile]).decode()
+ #(p, v) = out.strip().split()
                 # don't extract the same version of the package if it is
                 # already extracted
                 if pkg_versions.get(p) == v:

Changed in apport:
assignee: nobody → Brian Murray (brian-murray)
status: Triaged → In Progress
Changed in apport:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.