Skip to content

Commit

Permalink
apt repo: allow insecure repos
Browse files Browse the repository at this point in the history
In Xenial this was the default behavior, which explains why Snapcraft
works. However, in Zesty this behavior changed, causing breakage when
using external repositories (e.g. ROS). Instead of relying on defaults,
ensure the behavior is consistent across releases.

This is not a long-term fix. We should add a way to ack repository keys.

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
  • Loading branch information
kyrofa committed Oct 12, 2017
1 parent 3418912 commit ae2d59b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions snapcraft/internal/repo/_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def _setup_apt(self, cache_dir):
# Do not install recommends
apt.apt_pkg.config.set('Apt::Install-Recommends', 'False')

# Don't verify repository keys. FIXME: We should have a way to simply
# ack keys for extra repositories. We're only setting this here because
# in Xenial it defaulted to True, but in Zesty that has changed to
# False, and we want consistent behavior. This is, however, not a
# long-term solution.
apt.apt_pkg.config.set('Acquire::AllowInsecureRepositories', 'True')

# Methods and solvers dir for when in the SNAP
if common.is_snap():
snap_dir = os.getenv('SNAP')
Expand Down
2 changes: 2 additions & 0 deletions snapcraft/tests/repo/test_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_get_package(self, mock_apt_pkg):

mock_apt_pkg.assert_has_calls([
call.config.set('Apt::Install-Recommends', 'False'),
call.config.set('Acquire::AllowInsecureRepositories', 'True'),
call.config.find_file('Dir::Etc::Trusted'),
call.config.set('Dir::Etc::Trusted', ANY),
call.config.find_file('Dir::Etc::TrustedParts'),
Expand Down Expand Up @@ -115,6 +116,7 @@ def test_get_multiarch_package(self, mock_apt_pkg):

mock_apt_pkg.assert_has_calls([
call.config.set('Apt::Install-Recommends', 'False'),
call.config.set('Acquire::AllowInsecureRepositories', 'True'),
call.config.find_file('Dir::Etc::Trusted'),
call.config.set('Dir::Etc::Trusted', ANY),
call.config.find_file('Dir::Etc::TrustedParts'),
Expand Down

0 comments on commit ae2d59b

Please sign in to comment.