Merge lp:~benji/landscape-client/create-empty-apt-keyring-for-trusty into lp:~landscape/landscape-client/trunk

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: 772
Merged at revision: 772
Proposed branch: lp:~benji/landscape-client/create-empty-apt-keyring-for-trusty
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 50 lines (+13/-2)
2 files modified
landscape/package/facade.py (+5/-2)
landscape/package/tests/test_facade.py (+8/-0)
To merge this branch: bzr merge lp:~benji/landscape-client/create-empty-apt-keyring-for-trusty
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Björn Tillenius (community) Approve
Review via email: mp+223114@code.launchpad.net

Commit message

Bug 1326078 was caused by apt on trusty requiring a keyring file (even if
empty) exist in its directory structure. Since we create a fake directory
structure for it to operate on, we need to create a keyring too.

Description of the change

Bug 1326078 was caused by apt on trusty requiring a keyring file (even if
empty) exist in its directory structure. Since we create a fake directory
structure for it to operate on, we need to create a keyring too.

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good to me, +1

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1!

Small nitpick inline.

review: Approve
Revision history for this message
Benji York (benji) :
772. By Benji York

use touch_file instead of create_file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/package/facade.py'
2--- landscape/package/facade.py 2013-09-23 09:44:45 +0000
3+++ landscape/package/facade.py 2014-06-16 12:07:56 +0000
4@@ -22,7 +22,7 @@
5 from apt.progress.text import AcquireProgress
6 from apt.progress.base import InstallProgress
7
8-from landscape.lib.fs import append_file, create_file, read_file
9+from landscape.lib.fs import append_file, create_file, read_file, touch_file
10 from landscape.constants import UBUNTU_PATH
11 from landscape.package.skeleton import build_skeleton_apt
12
13@@ -143,7 +143,7 @@
14 self.refetch_package_index = False
15
16 def _ensure_dir_structure(self):
17- self._ensure_sub_dir("etc/apt")
18+ apt_dir = self._ensure_sub_dir("etc/apt")
19 self._ensure_sub_dir("etc/apt/sources.list.d")
20 self._ensure_sub_dir("var/cache/apt/archives/partial")
21 self._ensure_sub_dir("var/lib/apt/lists/partial")
22@@ -155,6 +155,9 @@
23 self._dpkg_status = os.path.join(dpkg_dir, "status")
24 if not os.path.exists(self._dpkg_status):
25 create_file(self._dpkg_status, "")
26+ # Apt will fail if it does not have a keyring. It does not care if
27+ # the keyring is empty.
28+ touch_file(os.path.join(apt_dir, "trusted.gpg"))
29
30 def _ensure_sub_dir(self, sub_dir):
31 """Ensure that a dir in the Apt root exists."""
32
33=== modified file 'landscape/package/tests/test_facade.py'
34--- landscape/package/tests/test_facade.py 2013-09-27 14:01:32 +0000
35+++ landscape/package/tests/test_facade.py 2014-06-16 12:07:56 +0000
36@@ -2573,6 +2573,14 @@
37 self.assertEqual(
38 apt_pkg.SELSTATE_DEINSTALL, foo.package._pkg.selected_state)
39
40+ def test_creation_of_key_ring(self):
41+ """
42+ Apt on Trusty requires a keyring exist in its directory structure, so
43+ we create an empty file to appease it.
44+ """
45+ keyring_path = os.path.join(self.facade._root, "etc/apt/trusted.gpg")
46+ self.assertTrue(os.path.exists(keyring_path))
47+
48 if not hasattr(Package, "shortname"):
49 # The 'shortname' attribute was added when multi-arch support
50 # was added to python-apt. So if it's not there, it means that

Subscribers

People subscribed via source and target branches

to all changes: