aboutsummaryrefslogtreecommitdiffstats
path: root/community/salt/0001-alpine-support.patch
diff options
context:
space:
mode:
authorOlivier Mauras <olivier@mauras.ch>2016-09-29 02:55:33 +0200
committerJakub Jirutka <jakub@jirutka.cz>2016-09-29 15:41:39 +0200
commitb2b0e320056bc35721ad8142df7dda40dc5668d8 (patch)
tree119570ffdb31b1ebfb6af0de64a2415370b3ced9 /community/salt/0001-alpine-support.patch
parent3f154a82ded61244afc52692f7846b10d89673f8 (diff)
downloadaports-b2b0e320056bc35721ad8142df7dda40dc5668d8.tar.bz2
aports-b2b0e320056bc35721ad8142df7dda40dc5668d8.tar.xz
community/salt: fix pkg.latest_version to get pkg.latest working state
Diffstat (limited to 'community/salt/0001-alpine-support.patch')
-rw-r--r--community/salt/0001-alpine-support.patch29
1 files changed, 26 insertions, 3 deletions
diff --git a/community/salt/0001-alpine-support.patch b/community/salt/0001-alpine-support.patch
index b403431523..fcd7f2d037 100644
--- a/community/salt/0001-alpine-support.patch
+++ b/community/salt/0001-alpine-support.patch
@@ -2,10 +2,10 @@ Upstream code not yet released
---
diff --git a/salt/modules/apk.py b/salt/modules/apk.py
new file mode 100644
-index 0000000..c7cf312
+index 0000000..a45d1cf
--- /dev/null
+++ b/salt/modules/apk.py
-@@ -0,0 +1,583 @@
+@@ -0,0 +1,606 @@
+# -*- coding: utf-8 -*-
+'''
+Support for apk
@@ -39,7 +39,7 @@ index 0000000..c7cf312
+
+def __virtual__():
+ '''
-+ Confirm this module is on a nilrt based system
++ Confirm this module is running on an Alpine Linux distribution
+ '''
+ if __grains__.get('os_family', False) == 'Alpine':
+ return __virtualname__
@@ -74,6 +74,7 @@ index 0000000..c7cf312
+#def info_installed(*names):
+# return 'Not available'
+
++
+def version(*names, **kwargs):
+ '''
+ Returns a string representing the package version or an empty string if not
@@ -191,11 +192,13 @@ index 0000000..c7cf312
+ ret = {}
+ for name in names:
+ ret[name] = ''
++ pkgs = list_pkgs()
+
+ # Refresh before looking for the latest version available
+ if refresh:
+ refresh_db()
+
++ # Upgrade check
+ cmd = ['apk', 'upgrade', '-s']
+ out = __salt__['cmd.run_stdout'](cmd,
+ output_loglevel='trace',
@@ -210,6 +213,26 @@ index 0000000..c7cf312
+ except ValueError:
+ pass
+
++ # If version is empty, package may not be installed
++ for pkg in ret:
++ if not ret[pkg]:
++ installed = pkgs.get(pkg)
++ cmd = ['apk', 'search', pkg]
++ out = __salt__['cmd.run_stdout'](cmd,
++ output_loglevel='trace',
++ python_shell=False)
++ for line in salt.utils.itertools.split(out, '\n'):
++ try:
++ pkg_version = '-'.join(line.split('-')[-2:])
++ pkg_name = '-'.join(line.split('-')[:-2])
++ if (pkg == pkg_name):
++ if (installed == pkg_version):
++ ret[pkg] = ''
++ else:
++ ret[pkg] = pkg_version
++ except ValueError:
++ pass
++
+ # Return a string if only one package name passed
+ if len(names) == 1:
+ return ret[names[0]]