curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #01394
[Merge] ~mwhudson/curtin:lp-1912801 into curtin:master
Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:lp-1912801 into curtin:master.
Commit message:
apt_config: put added gpg in correct place in filesystem
LP: #1912801
Requested reviews:
curtin developers (curtin-dev)
For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/396878
--
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:lp-1912801 into curtin:master.
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
index ff906be..ad56322 100644
--- a/curtin/commands/apt_config.py
+++ b/curtin/commands/apt_config.py
@@ -343,7 +343,7 @@ def apply_preserve_sources_list(target):
raise
-def add_apt_key_raw(filename, key, target=None):
+def add_apt_key_raw(filename, key, target):
"""
actual adding of a key as defined in key argument
to the system
@@ -355,7 +355,9 @@ def add_apt_key_raw(filename, key, target=None):
else:
target_keyfile_ext = '.gpg'
omode = 'wb'
- target_keyfile = paths.target_path(target, filename + target_keyfile_ext)
+ target_keyfile = paths.target_path(
+ target, os.path.join(
+ "/etc/apt/trusted.gpg.d", filename + target_keyfile_ext))
util.write_file(target_keyfile, key, mode=0o644, omode=omode)
LOG.debug("Adding key to '%s':\n'%s'", target_keyfile, key)
diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
index f8aac5a..5ca461e 100644
--- a/tests/unittests/test_apt_source.py
+++ b/tests/unittests/test_apt_source.py
@@ -1094,4 +1094,26 @@ class TestDebconfSelections(CiTestCase):
apt_config.dpkg_reconfigure(['pkgfoo', 'pkgbar'])
m_subp.assert_not_called()
+ @mock.patch("curtin.commands.apt_config.util.write_file")
+ def test_add_apt_key_raw_asc(self, m_write_file):
+ fname = self.random_string()
+ apt_config.add_apt_key_raw(fname, EXPECTEDKEY, '/target')
+ expected_call = mock.call(
+ '/target/etc/apt/trusted.gpg.d/{}.asc'.format(fname),
+ EXPECTEDKEY,
+ mode=0o644,
+ omode='w')
+ m_write_file.assert_has_calls([expected_call])
+
+ @mock.patch("curtin.commands.apt_config.util.write_file")
+ def test_add_apt_key_raw_bin(self, m_write_file):
+ fname = self.random_string()
+ apt_config.add_apt_key_raw(fname, EXPECTED_BINKEY, '/target')
+ expected_call = mock.call(
+ '/target/etc/apt/trusted.gpg.d/{}.gpg'.format(fname),
+ EXPECTED_BINKEY,
+ mode=0o644,
+ omode='wb')
+ m_write_file.assert_has_calls([expected_call])
+
# vi: ts=4 expandtab syntax=python
Follow ups