mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add normalize_name function
This will pave the way for .x86_64 architectures to be used in pkg states.
This commit is contained in:
parent
a91ec264d7
commit
a516db971f
@ -143,6 +143,28 @@ def _get_repo_options(**kwargs):
|
|||||||
return repo_arg
|
return repo_arg
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_name(name):
|
||||||
|
'''
|
||||||
|
Strips the architecture from the specified package name, if necessary (in
|
||||||
|
other words, if the arch matches the OS arch, or is ``noarch``.
|
||||||
|
|
||||||
|
CLI Example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
salt '*' pkg.normalize_name zsh.x86_64
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
arch = name.rsplit('.', 1)[-1]
|
||||||
|
if arch not in __ARCHES + ('noarch',):
|
||||||
|
return name
|
||||||
|
except ValueError:
|
||||||
|
return name
|
||||||
|
if arch in (__grains__['osarch'], 'noarch'):
|
||||||
|
return name[:-(len(arch) + 1)]
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
def latest_version(*names, **kwargs):
|
def latest_version(*names, **kwargs):
|
||||||
'''
|
'''
|
||||||
Return the latest version of the named package available for upgrade or
|
Return the latest version of the named package available for upgrade or
|
||||||
|
Loading…
Reference in New Issue
Block a user