Skip to content

Commit

Permalink
community/salt: fix python3.8 incompattibilities
Browse files Browse the repository at this point in the history
Salt is not compattible with Python 3.8 yet[0], so salt-minion is broken on
Alpine Linux since v3.10.

Patch the grain code to be compattible with Python 3.8.

Fixes #10979

[0]: saltstack/salt#55310
  • Loading branch information
Ikke committed Jan 1, 2020
1 parent f65de9c commit 430bfc3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
8 changes: 5 additions & 3 deletions community/salt/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=salt
pkgver=2019.2.0
pkgrel=3
pkgrel=4
pkgdesc="A parallel remote execution system"
url="https://github.com/saltstack/salt"
arch="noarch !s390x"
license="Apache-2.0"
depends="py3-tornado py3-yaml py3-jinja2 py3-markupsafe py3-msgpack py3-crypto py3-zmq
py3-six py3-requests py3-pygit2 py3-dateutil procps"
py3-distro py3-six py3-requests py3-pygit2 py3-dateutil procps"
makedepends="python3-dev py3-libcloud"
subpackages="$pkgname-doc
$pkgname-master $pkgname-master-openrc:master_openrc
Expand All @@ -26,6 +26,7 @@ source="https://pypi.io/packages/source/s/salt/salt-$pkgver.tar.gz
salt-minion.initd
salt-syndic.confd
salt-syndic.initd
fix-grains-dist-detection.patch
"
options="!check" # depends on pytestsalt
builddir="$srcdir/$pkgname-$pkgver"
Expand Down Expand Up @@ -157,4 +158,5 @@ cfbbeb8023a383e7c42d84e3346edfd068c9ec7650c4ddc3caa38534da325a67497e1f06ca02cc1f
0051e13351cef8db81dc075a194bb384723f07d5591b5b4d3f3adf4180afaf7beced470ab79ceca9d1ec0dae62dbd72084eb76af009fc78411a011050a94a2ed salt-minion.confd
31521a7bf9455a805652ebb2c2a258148d654169caed500dbf1fe0c26baf26b330217117fe84a13706ded75a9eedadc0bbd671ede0957ed4d60d1e766fea6b39 salt-minion.initd
bafc6ea10cdafd0aef868feb35aecbe4ae6a7dff0ae42862bded85715ad763eb89e1ed27437866a7e5f2b9f7064e3c2a3fb59814487744ba4227238d95cf3818 salt-syndic.confd
d71133e834685304e0167554035ebbc861252f972bbe981cc71e45b70f15d94a28a02a369463c9a641372919689f96b62a0408b14f824ad986d536e52b1e5ec0 salt-syndic.initd"
d71133e834685304e0167554035ebbc861252f972bbe981cc71e45b70f15d94a28a02a369463c9a641372919689f96b62a0408b14f824ad986d536e52b1e5ec0 salt-syndic.initd
c61280af9db7bb1551c5c80901d455ea074859cc5b6615e5caba694f5a2188e37e0a85ca2491e233861162da534599f9e455dc93a95b7741fbcf9508e7498ae9 fix-grains-dist-detection.patch"
46 changes: 46 additions & 0 deletions community/salt/fix-grains-dist-detection.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
python 3.8 removed linux_distribution support completely and leaves that
functionality to third-party modules, which is provided by 'distro'.

Just completely remove the backwards compatibility and completely rely on that
module.

diff --git a/salt/grains/core.py b/salt/grains/core.py
index f05276c..58edaee 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -22,6 +22,7 @@ import locale
import uuid
from errno import EACCES, EPERM
import datetime
+from distro import linux_distribution

# pylint: disable=import-error
try:
@@ -33,18 +34,6 @@ except ImportError:
__proxyenabled__ = ['*']
__FQDN__ = None

-# Extend the default list of supported distros. This will be used for the
-# /etc/DISTRO-release checking that is part of linux_distribution()
-from platform import _supported_dists
-_supported_dists += ('arch', 'mageia', 'meego', 'vmware', 'bluewhite64',
- 'slamd64', 'ovs', 'system', 'mint', 'oracle', 'void')
-
-# linux_distribution deprecated in py3.7
-try:
- from platform import linux_distribution
-except ImportError:
- from distro import linux_distribution
-
# Import salt libs
import salt.exceptions
import salt.log
@@ -1871,7 +1860,7 @@ def os_data():
)
(osname, osrelease, oscodename) = \
[x.strip('"').strip("'") for x in
- linux_distribution(supported_dists=_supported_dists)]
+ linux_distribution()]
# Try to assign these three names based on the lsb info, they tend to
# be more accurate than what python gets from /etc/DISTRO-release.
# It's worth noting that Ubuntu has patched their Python distribution

0 comments on commit 430bfc3

Please sign in to comment.