Skip to content

Commit

Permalink
AptTool: add repo key before running apt-add-repository
Browse files Browse the repository at this point in the history
In Ubuntu 20.04 (and maybe earlier), the behavior of

    apt-add-repository 'deb https://example.com/repo example main'

is to add the named repository to apt's sources *and* to update the
package index.  If the new repository's package key is not already in
apt's keyring, this will fail.

It is possible to change this behavior by running apt-add-repository -n,
but adding the key before running apt-add-repository also works, doesn't
require new command-line switches, and should be backwards-compatible
with apt-add-repository versions that might not behave as described
above.
  • Loading branch information
hannahwhy committed Apr 24, 2021
1 parent 5fc3ef1 commit dcb45f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conans/client/tools/system_pm.py
Expand Up @@ -272,11 +272,11 @@ def installed(self, package_name):

class AptTool(BaseTool):
def add_repository(self, repository, repo_key=None):
_run(self._runner, "%sapt-add-repository %s" % (self._sudo_str, repository),
output=self._output)
if repo_key:
_run(self._runner, "wget -qO - %s | %sapt-key add -" % (repo_key, self._sudo_str),
output=self._output)
_run(self._runner, "%sapt-add-repository %s" % (self._sudo_str, repository),
output=self._output)

def update(self):
_run(self._runner, "%sapt-get update" % self._sudo_str, output=self._output)
Expand Down

0 comments on commit dcb45f6

Please sign in to comment.