mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
aptpkg: Accept **kwargs instead of a dict for pkg.expand_repo_def
This commit is contained in:
parent
6212e9aa56
commit
709d80bb1b
1 changed files with 13 additions and 9 deletions
|
@ -1734,23 +1734,27 @@ def _strip_uri(repo):
|
|||
return ' '.join(splits)
|
||||
|
||||
|
||||
def expand_repo_def(repokwargs):
|
||||
def expand_repo_def(**kwargs):
|
||||
'''
|
||||
Take a repository definition and expand it to the full pkg repository dict
|
||||
that can be used for comparison. This is a helper function to make
|
||||
the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states.
|
||||
|
||||
There is no use to calling this function via the CLI.
|
||||
This is designed to be called from pkgrepo states and will have little use
|
||||
being called on the CLI.
|
||||
'''
|
||||
if 'repo' not in kwargs:
|
||||
raise SaltInvocationError('missing \'repo\' argument')
|
||||
|
||||
_check_apt()
|
||||
|
||||
sanitized = {}
|
||||
repo = _strip_uri(repokwargs['repo'])
|
||||
repo = _strip_uri(kwargs['repo'])
|
||||
if repo.startswith('ppa:') and __grains__['os'] == 'Ubuntu':
|
||||
dist = __grains__['lsb_distrib_codename']
|
||||
owner_name, ppa_name = repo[4:].split('/', 1)
|
||||
if 'ppa_auth' in repokwargs:
|
||||
auth_info = '{0}@'.format(repokwargs['ppa_auth'])
|
||||
if 'ppa_auth' in kwargs:
|
||||
auth_info = '{0}@'.format(kwargs['ppa_auth'])
|
||||
repo = LP_PVT_SRC_FORMAT.format(auth_info, owner_name, ppa_name,
|
||||
dist)
|
||||
else:
|
||||
|
@ -1762,15 +1766,15 @@ def expand_repo_def(repokwargs):
|
|||
else:
|
||||
repo = LP_SRC_FORMAT.format(owner_name, ppa_name, dist)
|
||||
|
||||
if 'file' not in repokwargs:
|
||||
if 'file' not in kwargs:
|
||||
filename = '/etc/apt/sources.list.d/{0}-{1}-{2}.list'
|
||||
repokwargs['file'] = filename.format(owner_name, ppa_name,
|
||||
kwargs['file'] = filename.format(owner_name, ppa_name,
|
||||
dist)
|
||||
|
||||
source_entry = sourceslist.SourceEntry(repo)
|
||||
for kwarg in _MODIFY_OK:
|
||||
if kwarg in repokwargs:
|
||||
setattr(source_entry, kwarg, repokwargs[kwarg])
|
||||
if kwarg in kwargs:
|
||||
setattr(source_entry, kwarg, kwargs[kwarg])
|
||||
|
||||
sanitized['file'] = source_entry.file
|
||||
sanitized['comps'] = getattr(source_entry, 'comps', [])
|
||||
|
|
Loading…
Add table
Reference in a new issue