Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AptTool: add repo key before running apt-add-repository (#8857) #8861

Merged

Conversation

hannahwhy
Copy link
Contributor

@hannahwhy hannahwhy commented Apr 24, 2021

Changelog: Bugfix: AptTool: add repo key before running apt-add-repository.
Docs: omit

Closes #8857

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.

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@CLAassistant
Copy link

CLAassistant commented Apr 24, 2021

CLA assistant check
All committers have signed the CLA.

@hannahwhy
Copy link
Contributor Author

hannahwhy commented Apr 24, 2021

As described in #8857, this proposed change will have AptTool running an extra index update, which does waste some time. However:

  1. The approach here doesn't change the interface expected from apt-add-repository.
  2. Two index updates already occur under Ubuntu 20.04 without this change.

The version of apt-add-repository in Ubuntu 20.04 has a -n, --no-update option that skips the index update. If we use that, then the order of operations in AptTool can remain the way they are. However, I have yet not confirmed that -n and/or --no-update exist in all versions of apt-add-repository, not only in Debian and Ubuntu but also other Debian derivatives.

@hannahwhy
Copy link
Contributor Author

Looks like I'm running afoul of some expected command sequences in the test suite. I'll check those in a little while.

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.
@hannahwhy hannahwhy force-pushed the bugfix/apttool-import-key-first branch from dcb45f6 to 73533a8 Compare April 25, 2021 02:13
@hannahwhy hannahwhy marked this pull request as ready for review April 25, 2021 08:54
@memsharded memsharded requested review from SSE4 and lasote April 26, 2021 07:56
@memsharded
Copy link
Member

Note for the reviewers:

  • The disadvantage of this solution is that it will run an "update" twice, second might be redundant, and it might be less efficient. This doesn't happen for all cases (only when adding repository and providing key), but better to be sure impact is reasonable.

Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the added time is reasonably low and probably we don't have a "safer" way to do it without breaking. For me, it could be merged.

@memsharded memsharded added this to the 1.37 milestone May 4, 2021
@memsharded memsharded merged commit c2ad720 into conan-io:develop May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] AptTool's use of apt-add-repository may update the apt index before the repository's key is added
4 participants