sysutils/py-distro: Update to 1.4.0
Changes this release: https://github.com/nir0s/distro/releases/tag/v1.3.0 https://github.com/nir0s/distro/releases/tag/v1.4.0
This commit is contained in:
parent
0bd7705701
commit
1e2e11e366
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=492135
@ -2,7 +2,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= distro
|
||||
PORTVERSION= 1.2.0
|
||||
PORTVERSION= 1.4.0
|
||||
CATEGORIES= sysutils python
|
||||
MASTER_SITES= CHEESESHOP
|
||||
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
||||
@ -15,6 +15,7 @@ LICENSE_FILE= ${WRKSRC}/LICENSE
|
||||
|
||||
USES= python shebangfix
|
||||
USE_PYTHON= autoplist concurrent distutils
|
||||
|
||||
SHEBANG_FILES= query_local_distro.py
|
||||
NO_ARCH= yes
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
TIMESTAMP = 1514689680
|
||||
SHA256 (distro-1.2.0.tar.gz) = d94370e43b676ac44fbe1ab68ca903a6147eaba3a9e8eff85b2c05556a455b76
|
||||
SIZE (distro-1.2.0.tar.gz) = 45893
|
||||
TIMESTAMP = 1549288968
|
||||
SHA256 (distro-1.4.0.tar.gz) = 362dde65d846d23baee4b5c058c8586f219b5a54be1cf5fc6ff55c4578392f57
|
||||
SIZE (distro-1.4.0.tar.gz) = 53719
|
||||
|
@ -1,106 +0,0 @@
|
||||
--- distro.py.orig 2017-12-24 16:29:31 UTC
|
||||
+++ distro.py
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright 2015,2016 Nir Cohen
|
||||
+# Copyright 2015,2016,2017 Nir Cohen
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -932,9 +932,16 @@ class LinuxDistribution(object):
|
||||
cmd = ('lsb_release', '-a')
|
||||
stdout = subprocess.check_output(cmd, stderr=devnull)
|
||||
except OSError: # Command not found
|
||||
- return {}
|
||||
+ try:
|
||||
+ cmd = ('uname', '-rs')
|
||||
+ stdout = subprocess.check_output(cmd, stderr=devnull)
|
||||
+ except OSError:
|
||||
+ return {}
|
||||
content = stdout.decode(sys.getfilesystemencoding()).splitlines()
|
||||
- return self._parse_lsb_release_content(content)
|
||||
+ if cmd[0] == 'lsb_release':
|
||||
+ return self._parse_lsb_release_content(content)
|
||||
+ else:
|
||||
+ return self._parse_uname_content(content)
|
||||
|
||||
@staticmethod
|
||||
def _parse_lsb_release_content(lines):
|
||||
@@ -958,6 +965,18 @@ class LinuxDistribution(object):
|
||||
continue
|
||||
k, v = kv
|
||||
props.update({k.replace(' ', '_').lower(): v.strip()})
|
||||
+ return props
|
||||
+
|
||||
+ @staticmethod
|
||||
+ def _parse_uname_content(lines):
|
||||
+ props = {}
|
||||
+ match = re.search(r'^([^\s]+)\s+([\d\.]+)', lines[0].strip())
|
||||
+ if match:
|
||||
+ name, version = match.groups()
|
||||
+ props['id'] = name.lower()
|
||||
+ props['distributor_id'] = name
|
||||
+ props['release'] = version
|
||||
+ props['description'] = name + ' ' + version
|
||||
return props
|
||||
|
||||
@cached_property
|
||||
--- tests/resources/distros/freebsd111/bin/uname.orig 2017-12-31 03:40:48 UTC
|
||||
+++ tests/resources/distros/freebsd111/bin/uname
|
||||
@@ -0,0 +1,4 @@
|
||||
+#!/bin/bash
|
||||
+
|
||||
+echo "FreeBSD 11.1-RELEASE"
|
||||
+
|
||||
--- tests/resources/distros/netbsd711/bin/uname.orig 2017-12-31 03:40:48 UTC
|
||||
+++ tests/resources/distros/netbsd711/bin/uname
|
||||
@@ -0,0 +1,4 @@
|
||||
+#!/bin/bash
|
||||
+
|
||||
+echo "NetBSD 7.1.1"
|
||||
+
|
||||
--- tests/resources/distros/openbsd62/bin/uname.orig 2017-12-31 03:40:48 UTC
|
||||
+++ tests/resources/distros/openbsd62/bin/uname
|
||||
@@ -0,0 +1,4 @@
|
||||
+#!/bin/bash
|
||||
+
|
||||
+echo "OpenBSD 6.2"
|
||||
+
|
||||
--- tests/test_distro.py.orig 2017-12-24 16:26:25 UTC
|
||||
+++ tests/test_distro.py
|
||||
@@ -450,6 +450,36 @@ class TestLSBRelease(DistroTestCase):
|
||||
# }
|
||||
# self._test_outcome(desired_outcome)
|
||||
|
||||
+ def test_openbsd62_uname(self):
|
||||
+ self._test_outcome({
|
||||
+ 'id': 'openbsd',
|
||||
+ 'name': 'OpenBSD',
|
||||
+ 'version': '6.2',
|
||||
+ 'pretty_name': 'OpenBSD 6.2',
|
||||
+ 'pretty_version': '6.2',
|
||||
+ 'best_version': '6.2'
|
||||
+ })
|
||||
+
|
||||
+ def test_netbsd711_uname(self):
|
||||
+ self._test_outcome({
|
||||
+ 'id': 'netbsd',
|
||||
+ 'name': 'NetBSD',
|
||||
+ 'version': '7.1.1',
|
||||
+ 'pretty_name': 'NetBSD 7.1.1',
|
||||
+ 'pretty_version': '7.1.1',
|
||||
+ 'best_version': '7.1.1'
|
||||
+ })
|
||||
+
|
||||
+ def test_freebsd111_uname(self):
|
||||
+ self._test_outcome({
|
||||
+ 'id': 'freebsd',
|
||||
+ 'name': 'FreeBSD',
|
||||
+ 'version': '11.1',
|
||||
+ 'pretty_name': 'FreeBSD 11.1',
|
||||
+ 'pretty_version': '11.1',
|
||||
+ 'best_version': '11.1'
|
||||
+ })
|
||||
+
|
||||
def test_ubuntu14normal_lsb_release(self):
|
||||
self._setup_for_distro(os.path.join(TESTDISTROS, 'lsb',
|
||||
'ubuntu14_normal'))
|
Loading…
Reference in New Issue
Block a user