Merge ~mwhudson/curtin:lp-1912801 into curtin:master

Proposed by Michael Hudson-Doyle
Status: Rejected
Rejected by: Michael Hudson-Doyle
Proposed branch: ~mwhudson/curtin:lp-1912801
Merge into: curtin:master
Diff against target: 55 lines (+26/-2)
2 files modified
curtin/commands/apt_config.py (+4/-2)
tests/unittests/test_apt_source.py (+22/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+396878@code.launchpad.net

Commit message

apt_config: put added gpg in correct place in filesystem

LP: #1912801

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

The failures are that pylint flakiness.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Unmerged commits

e38cfaf... by Michael Hudson-Doyle

apt_config: put added gpg in correct place in filesystem

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
2index ff906be..ad56322 100644
3--- a/curtin/commands/apt_config.py
4+++ b/curtin/commands/apt_config.py
5@@ -343,7 +343,7 @@ def apply_preserve_sources_list(target):
6 raise
7
8
9-def add_apt_key_raw(filename, key, target=None):
10+def add_apt_key_raw(filename, key, target):
11 """
12 actual adding of a key as defined in key argument
13 to the system
14@@ -355,7 +355,9 @@ def add_apt_key_raw(filename, key, target=None):
15 else:
16 target_keyfile_ext = '.gpg'
17 omode = 'wb'
18- target_keyfile = paths.target_path(target, filename + target_keyfile_ext)
19+ target_keyfile = paths.target_path(
20+ target, os.path.join(
21+ "/etc/apt/trusted.gpg.d", filename + target_keyfile_ext))
22 util.write_file(target_keyfile, key, mode=0o644, omode=omode)
23 LOG.debug("Adding key to '%s':\n'%s'", target_keyfile, key)
24
25diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
26index f8aac5a..5ca461e 100644
27--- a/tests/unittests/test_apt_source.py
28+++ b/tests/unittests/test_apt_source.py
29@@ -1094,4 +1094,26 @@ class TestDebconfSelections(CiTestCase):
30 apt_config.dpkg_reconfigure(['pkgfoo', 'pkgbar'])
31 m_subp.assert_not_called()
32
33+ @mock.patch("curtin.commands.apt_config.util.write_file")
34+ def test_add_apt_key_raw_asc(self, m_write_file):
35+ fname = self.random_string()
36+ apt_config.add_apt_key_raw(fname, EXPECTEDKEY, '/target')
37+ expected_call = mock.call(
38+ '/target/etc/apt/trusted.gpg.d/{}.asc'.format(fname),
39+ EXPECTEDKEY,
40+ mode=0o644,
41+ omode='w')
42+ m_write_file.assert_has_calls([expected_call])
43+
44+ @mock.patch("curtin.commands.apt_config.util.write_file")
45+ def test_add_apt_key_raw_bin(self, m_write_file):
46+ fname = self.random_string()
47+ apt_config.add_apt_key_raw(fname, EXPECTED_BINKEY, '/target')
48+ expected_call = mock.call(
49+ '/target/etc/apt/trusted.gpg.d/{}.gpg'.format(fname),
50+ EXPECTED_BINKEY,
51+ mode=0o644,
52+ omode='wb')
53+ m_write_file.assert_has_calls([expected_call])
54+
55 # vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches