Skip to content

Commit

Permalink
Fix interactive install to honor no-*gpgcheck from commandline
Browse files Browse the repository at this point in the history
When originally implementing the per-source gpgcheck flags in
answerfile[1], the full code was moved to an anwerfile-only location,
breaking the original interactive-install implementation (and then
following code review[2] the working code for interactive install
disappeared further from the patch series).

This moves the Repository flag-setting to `add_repos()` common code,
while leaving the flag computation to the caller, since only the
answerfile case has to do any non-trivial logic.

- [1] 06b7007
- [2] #2 (comment)

Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Mar 6, 2023
1 parent 22c5b0b commit 9c07411
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def handleRepos(repos, ans):
main_repositories = []
update_repositories = []

def add_repos(main_repositories, update_repositories, repos):
def add_repos(main_repositories, update_repositories, repos, repo_gpgcheck, gpgcheck):
"""Add repositories to the appropriate list, ensuring no duplicates,
that the main repository is at the beginning, and that the order of the
rest is maintained."""
Expand All @@ -390,28 +390,28 @@ def add_repos(main_repositories, update_repositories, repos):
else:
repo_list.append(repo)

if repo_list is main_repositories: # i.e., if repo is a "main repository"
repo.setRepoGpgCheck(repo_gpgcheck)
repo.setGpgCheck(gpgcheck)

default_repo_gpgcheck = answers.get('repo-gpgcheck', True)
default_gpgcheck = answers.get('gpgcheck', True)
# A list of sources coming from the answerfile
if 'sources' in answers_pristine:
for i in answers_pristine['sources']:
repos = repository.repositoriesFromDefinition(i['media'], i['address'])
add_repos(main_repositories, update_repositories, repos)
repo_gpgcheck = (answers.get('repo-gpgcheck', True) if i['repo_gpgcheck'] is None
else i['repo_gpgcheck'])
gpgcheck = (answers.get('gpgcheck', True) if i['gpgcheck'] is None
else i['gpgcheck'])
for repo in repos:
if repo in main_repositories:
repo.setRepoGpgCheck(repo_gpgcheck)
repo.setGpgCheck(gpgcheck)
repo_gpgcheck = default_repo_gpgcheck if i['repo_gpgcheck'] is None else i['repo_gpgcheck']
gpgcheck = default_gpgcheck if i['gpgcheck'] is None else i['gpgcheck']
add_repos(main_repositories, update_repositories, repos, repo_gpgcheck, gpgcheck)

# A single source coming from an interactive install
if 'source-media' in answers_pristine and 'source-address' in answers_pristine:
repos = repository.repositoriesFromDefinition(answers_pristine['source-media'], answers_pristine['source-address'])
add_repos(main_repositories, update_repositories, repos)
add_repos(main_repositories, update_repositories, repos, default_repo_gpgcheck, default_gpgcheck)

for media, address in answers_pristine['extra-repos']:
repos = repository.repositoriesFromDefinition(media, address)
add_repos(main_repositories, update_repositories, repos)
add_repos(main_repositories, update_repositories, repos, default_repo_gpgcheck, default_gpgcheck)

if not main_repositories or main_repositories[0].identifier() != MAIN_REPOSITORY_NAME:
raise RuntimeError("No main repository found")
Expand Down

0 comments on commit 9c07411

Please sign in to comment.