Add support for architectures for APT pkgrepo.managed states

This commit is contained in:
Erik Johnson 2018-12-19 12:56:43 -06:00
parent 13de0b8f18
commit 67ae5a59a7
No known key found for this signature in database
GPG Key ID: 5E5583C437808F3F
2 changed files with 33 additions and 10 deletions

View File

@ -1582,7 +1582,7 @@ def _split_repo_str(repo):
Return APT source entry as a tuple.
'''
split = sourceslist.SourceEntry(repo)
return split.type, split.uri, split.dist, split.comps
return split.type, split.architectures, split.uri, split.dist, split.comps
def _consolidate_repo_sources(sources):
@ -1771,7 +1771,7 @@ def get_repo(repo, **kwargs):
if repos:
try:
repo_type, repo_uri, repo_dist, repo_comps = _split_repo_str(repo)
repo_type, repo_architectures, repo_uri, repo_dist, repo_comps = _split_repo_str(repo)
if ppa_auth:
uri_match = re.search('(http[s]?://)(.+)', repo_uri)
if uri_match:
@ -1844,7 +1844,11 @@ def del_repo(repo, **kwargs):
if repos:
deleted_from = dict()
try:
repo_type, repo_uri, repo_dist, repo_comps = _split_repo_str(repo)
repo_type, \
repo_architectures, \
repo_uri, \
repo_dist, \
repo_comps = _split_repo_str(repo)
except SyntaxError:
raise SaltInvocationError(
'Error: repo \'{0}\' not a well formatted definition'
@ -1852,8 +1856,10 @@ def del_repo(repo, **kwargs):
)
for source in repos:
if (source.type == repo_type and source.uri == repo_uri and
source.dist == repo_dist):
if (source.type == repo_type
and source.architectures == repo_architectures
and source.uri == repo_uri
and source.dist == repo_dist):
s_comps = set(source.comps)
r_comps = set(repo_comps)
@ -2319,7 +2325,11 @@ def mod_repo(repo, saltenv='base', **kwargs):
repos = [s for s in sources if not s.invalid]
mod_source = None
try:
repo_type, repo_uri, repo_dist, repo_comps = _split_repo_str(repo)
repo_type, \
repo_architectures, \
repo_uri, \
repo_dist, \
repo_comps = _split_repo_str(repo)
except SyntaxError:
raise SyntaxError(
'Error: repo \'{0}\' not a well formatted definition'.format(repo)
@ -2387,6 +2397,8 @@ def mod_repo(repo, saltenv='base', **kwargs):
if 'architectures' in kwargs:
kwargs['architectures'] = kwargs['architectures'].split(',')
else:
kwargs['architectures'] = repo_architectures
if 'disabled' in kwargs:
kwargs['disabled'] = salt.utils.data.is_true(kwargs['disabled'])
@ -2408,6 +2420,8 @@ def mod_repo(repo, saltenv='base', **kwargs):
mod_source = source
if not source.comps:
mod_source = source
if kwargs['architectures'] != source.architectures:
mod_source = source
if mod_source:
break

View File

@ -457,6 +457,9 @@ def managed(name, ppa=None, **kwargs):
sanitizedkwargs[kwarg])
if precomments != kwargcomments:
break
elif kwarg == 'architectures' and sanitizedkwargs[kwarg]:
if set(sanitizedkwargs[kwarg]) != set(pre[kwarg]):
break
else:
if __grains__['os_family'] in ('RedHat', 'Suse') \
and any(isinstance(x, bool) for x in
@ -476,11 +479,18 @@ def managed(name, ppa=None, **kwargs):
if __opts__['test']:
ret['comment'] = (
'Package repo \'{0}\' will be configured. This may cause pkg '
'Package repo \'{0}\' would be configured. This may cause pkg '
'states to behave differently than stated if this action is '
'repeated without test=True, due to the differences in the '
'configured repositories.'.format(name)
)
if pre:
for kwarg in sanitizedkwargs:
if sanitizedkwargs.get(kwarg) != pre.get(kwarg):
ret['changes'][kwarg] = {'new': sanitizedkwargs.get(kwarg),
'old': pre.get(kwarg)}
else:
ret['changes']['repo'] = name
return ret
# empty file before configure
@ -509,9 +519,8 @@ def managed(name, ppa=None, **kwargs):
if pre:
for kwarg in sanitizedkwargs:
if post.get(kwarg) != pre.get(kwarg):
change = {'new': post[kwarg],
'old': pre.get(kwarg)}
ret['changes'][kwarg] = change
ret['changes'][kwarg] = {'new': post.get(kwarg),
'old': pre.get(kwarg)}
else:
ret['changes'] = {'repo': repo}