Skip to content

Commit

Permalink
Implement keyserver parameter option
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Nov 10, 2023
1 parent b60a0f2 commit 3eb34cf
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions plugins/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Actions related to adding/modifying apt repositories for ignition.
Usage:
gzdev repository (ACTION) [<repo-name>] [<repo-type>] [--project=<project_name>] [--force-linux-distro=<distro>]
gzdev repository (ACTION) [<repo-name>] [<repo-type>] [--project=<project_name>] [--force-linux-distro=<distro>] [--keyserver=<keyserver>]
gzdev repository list
gzdev repository (-h | --help)
gzdev repository --version
Expand Down Expand Up @@ -127,22 +127,22 @@ def get_sources_list_file_path(repo_name, repo_type):
return directory + '/' + filename


def install_key(key):
def install_key(key, keyserver):
_check_call(['apt-key', 'adv',
'--keyserver', 'keyserver.ubuntu.com',
'--keyserver', keyserver,
'--recv-keys', key])


def run_apt_update():
_check_call(['apt-get', 'update'])


def install_repos(project_list, config, linux_distro):
def install_repos(project_list, config, linux_distro, keyserver):
for p in project_list:
install_repo(p['name'], p['type'], config, linux_distro)
install_repo(p['name'], p['type'], config, linux_distro, keyserver)


def install_repo(repo_name, repo_type, config, linux_distro):
def install_repo(repo_name, repo_type, config, linux_distro, keyserver):
url = get_repo_url(repo_name, repo_type, config)
key = get_repo_key(repo_name, config)
# if not linux_distro provided, try to guess it
Expand All @@ -155,7 +155,7 @@ def install_repo(repo_name, repo_type, config, linux_distro):
warn('gzdev file with the repositoy already exists in the system\n[' + full_path + ']')
return

install_key(key)
install_key(key, keyserver)

try:
f = open(full_path, 'w')
Expand All @@ -181,28 +181,30 @@ def normalize_args(args):
linux_distro = force_linux_distro
else:
linux_distro = None
keyserver = args['--keyserver'] if args['--keyserver'] else \
'keyserver.ubuntu.com'

return action, repo_name, repo_type, project, linux_distro
return action, repo_name, repo_type, project, linux_distro, keyserver


def validate_input(args, config):
action, repo_name, repo_type, project, force_linux_distro = args
action, repo_name, repo_type, project, force_linux_distro, keyserver = args

if (action == 'enable' or action == 'disable' or action == 'list'):
True
pass
else:
error('Unknown action: ' + action)


def process_input(args, config):
action, repo_name, repo_type, project, linux_distro = args
action, repo_name, repo_type, project, linux_distro, keyserver = args

if (action == 'enable'):
if project:
project_list = load_project(project, config)
install_repos(project_list, config, linux_distro)
install_repos(project_list, config, linux_distro, keyserver)
else:
install_repo(repo_name, repo_type, config, linux_distro)
install_repo(repo_name, repo_type, config, linux_distro, keyserver)
elif (action == 'disable'):
disable_repo(repo_name)

Expand Down

0 comments on commit 3eb34cf

Please sign in to comment.