mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #41986 from rallytime/bp-41820
Back-port #41820 to 2016.11
This commit is contained in:
commit
bd9090c0bf
4 changed files with 34 additions and 4 deletions
|
@ -2350,8 +2350,9 @@ def del_repo(repo, basedir=None, **kwargs): # pylint: disable=W0613
|
|||
if stanza == repo:
|
||||
continue
|
||||
comments = ''
|
||||
if 'comments' in filerepos[stanza]:
|
||||
comments = '\n'.join(filerepos[stanza]['comments'])
|
||||
if 'comments' in six.iterkeys(filerepos[stanza]):
|
||||
comments = salt.utils.pkg.rpm.combine_comments(
|
||||
filerepos[stanza]['comments'])
|
||||
del filerepos[stanza]['comments']
|
||||
content += '\n[{0}]'.format(stanza)
|
||||
for line in filerepos[stanza]:
|
||||
|
@ -2486,7 +2487,8 @@ def mod_repo(repo, basedir=None, **kwargs):
|
|||
for stanza in six.iterkeys(filerepos):
|
||||
comments = ''
|
||||
if 'comments' in six.iterkeys(filerepos[stanza]):
|
||||
comments = '\n'.join(filerepos[stanza]['comments'])
|
||||
comments = salt.utils.pkg.rpm.combine_comments(
|
||||
filerepos[stanza]['comments'])
|
||||
del filerepos[stanza]['comments']
|
||||
content += '\n[{0}]'.format(stanza)
|
||||
for line in six.iterkeys(filerepos[stanza]):
|
||||
|
|
|
@ -96,6 +96,7 @@ from salt.modules.aptpkg import _strip_uri
|
|||
from salt.state import STATE_INTERNAL_KEYWORDS as _STATE_INTERNAL_KEYWORDS
|
||||
import salt.utils
|
||||
import salt.utils.pkg.deb
|
||||
import salt.utils.pkg.rpm
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
@ -403,6 +404,12 @@ def managed(name, ppa=None, **kwargs):
|
|||
salt.utils.pkg.deb.combine_comments(kwargs['comments'])
|
||||
if pre_comments != post_comments:
|
||||
break
|
||||
elif kwarg == 'comments' and os_family == 'redhat':
|
||||
precomments = salt.utils.pkg.rpm.combine_comments(pre[kwarg])
|
||||
kwargcomments = salt.utils.pkg.rpm.combine_comments(
|
||||
sanitizedkwargs[kwarg])
|
||||
if precomments != kwargcomments:
|
||||
break
|
||||
else:
|
||||
if os_family in ('redhat', 'suse') \
|
||||
and any(isinstance(x, bool) for x in
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Common functions for working with RPM packages
|
||||
Common functions for working with deb packages
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
|
|
|
@ -11,6 +11,10 @@ import logging
|
|||
# Import salt libs
|
||||
from salt._compat import subprocess
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range # pylint: disable=redefined-builtin
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# These arches compiled from the rpmUtils.arch python module source
|
||||
|
@ -100,3 +104,20 @@ def parse_pkginfo(line, osarch=None):
|
|||
version = ':'.join((epoch, version))
|
||||
|
||||
return pkginfo(name, version, arch, repoid)
|
||||
|
||||
|
||||
def combine_comments(comments):
|
||||
'''
|
||||
Given a list of comments, strings, a single comment or a single string,
|
||||
return a single string of text containing all of the comments, prepending
|
||||
the '#' and joining with newlines as necessary.
|
||||
'''
|
||||
if not isinstance(comments, list):
|
||||
comments = [comments]
|
||||
for idx in range(len(comments)):
|
||||
if not isinstance(comments[idx], six.string_types):
|
||||
comments[idx] = str(comments[idx])
|
||||
comments[idx] = comments[idx].strip()
|
||||
if not comments[idx].startswith('#'):
|
||||
comments[idx] = '#' + comments[idx]
|
||||
return '\n'.join(comments)
|
||||
|
|
Loading…
Add table
Reference in a new issue