diff options
author | Marius Gedminas <marius@gedmin.as> | 2017-01-27 17:31:07 +0200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-02-07 18:46:02 -0800 |
commit | 23016041c07c19080f9ba757fbd255ae70ad1e39 (patch) | |
tree | fd04125223862139d041cedacc5ad54cc89b1128 | |
parent | 97969fc587e16ca92c9444a57122ca61f85e60a6 (diff) | |
download | ansible-modules-core-23016041c07c19080f9ba757fbd255ae70ad1e39.tar.gz |
apt_repository: check for enabled repositories correctly
Fixes #20754.
Details: UbuntuSourcesList.add_source() had a quick check for PPAs being
already present in the source lists. The check was looking for the PPAs
URL to be present in self.repo_urls, which should contain all valid and
enabled repositories.
The enabled check in repo_urls was incorrect. It was checking the tuple's
2nd item (which means "valid") and ignoring the 3rd item (which means
"enabled").
self.files contains tuples (line_number, valid, enabled, source_line,
comment_text). Ideally it would be using named tuples instead of
indexing, to avoid bugs like that, but Python 2.4 didn't have named
tuples, so we can't do that (yet).
(cherry picked from 577d0e43ba339788989ecdf9a9da97477596ec6d)
-rw-r--r-- | packaging/os/apt_repository.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/packaging/os/apt_repository.py b/packaging/os/apt_repository.py index eae62280..a2f4c690 100644 --- a/packaging/os/apt_repository.py +++ b/packaging/os/apt_repository.py @@ -433,10 +433,11 @@ class UbuntuSourcesList(SourcesList): _repositories = [] for parsed_repos in self.files.values(): for parsed_repo in parsed_repos: - enabled = parsed_repo[1] + valid = parsed_repo[1] + enabled = parsed_repo[2] source_line = parsed_repo[3] - if not enabled: + if not valid or not enabled: continue if source_line.startswith('ppa:'): |