From owner-svn-ports-all@freebsd.org Sun Dec 31 03:46:11 2017 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E85DE87058; Sun, 31 Dec 2017 03:46:11 +0000 (UTC) (envelope-from woodsb02@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 28B8B7EE2E; Sun, 31 Dec 2017 03:46:11 +0000 (UTC) (envelope-from woodsb02@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV3kA54003851; Sun, 31 Dec 2017 03:46:10 GMT (envelope-from woodsb02@FreeBSD.org) Received: (from woodsb02@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV3k9GR003844; Sun, 31 Dec 2017 03:46:09 GMT (envelope-from woodsb02@FreeBSD.org) Message-Id: <201712310346.vBV3k9GR003844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: woodsb02 set sender to woodsb02@FreeBSD.org using -f From: Ben Woods Date: Sun, 31 Dec 2017 03:46:09 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r457667 - in head/sysutils: . py-distro py-distro/files X-SVN-Group: ports-head X-SVN-Commit-Author: woodsb02 X-SVN-Commit-Paths: in head/sysutils: . py-distro py-distro/files X-SVN-Commit-Revision: 457667 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 03:46:11 -0000 Author: woodsb02 Date: Sun Dec 31 03:46:09 2017 New Revision: 457667 URL: https://svnweb.freebsd.org/changeset/ports/457667 Log: Add new port sysutils/py-distro distro (for: Linux Distribution) provides information about the Linux distribution it runs on, such as a reliable machine-readable ID, or version information. It is a renewed alternative implementation for Python's original platform.linux_distribution function, but it also provides much more functionality which isn't necessarily Python bound like a command-line interface. WWW: https://github.com/nir0s/distro Added: head/sysutils/py-distro/ head/sysutils/py-distro/Makefile (contents, props changed) head/sysutils/py-distro/distinfo (contents, props changed) head/sysutils/py-distro/files/ head/sysutils/py-distro/files/patch-pr207-bsdsupport (contents, props changed) head/sysutils/py-distro/pkg-descr (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Sun Dec 31 03:15:44 2017 (r457666) +++ head/sysutils/Makefile Sun Dec 31 03:46:09 2017 (r457667) @@ -891,6 +891,7 @@ SUBDIR += py-crontab SUBDIR += py-diffoscope SUBDIR += py-dirsync + SUBDIR += py-distro SUBDIR += py-dlipower SUBDIR += py-docker SUBDIR += py-drmaa Added: head/sysutils/py-distro/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/py-distro/Makefile Sun Dec 31 03:46:09 2017 (r457667) @@ -0,0 +1,21 @@ +# Created by: Ben Woods +# $FreeBSD$ + +PORTNAME= distro +PORTVERSION= 1.2.0 +CATEGORIES= sysutils python +MASTER_SITES= CHEESESHOP +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= woodsb02@FreeBSD.org +COMMENT= Linux OS platform information API + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= python:2.7+ shebangfix +USE_PYTHON= autoplist concurrent distutils +SHEBANG_FILES= query_local_distro.py +NO_ARCH= yes + +.include Added: head/sysutils/py-distro/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/py-distro/distinfo Sun Dec 31 03:46:09 2017 (r457667) @@ -0,0 +1,3 @@ +TIMESTAMP = 1514689680 +SHA256 (distro-1.2.0.tar.gz) = d94370e43b676ac44fbe1ab68ca903a6147eaba3a9e8eff85b2c05556a455b76 +SIZE (distro-1.2.0.tar.gz) = 45893 Added: head/sysutils/py-distro/files/patch-pr207-bsdsupport ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/py-distro/files/patch-pr207-bsdsupport Sun Dec 31 03:46:09 2017 (r457667) @@ -0,0 +1,106 @@ +--- 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')) Added: head/sysutils/py-distro/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/py-distro/pkg-descr Sun Dec 31 03:46:09 2017 (r457667) @@ -0,0 +1,10 @@ +distro (for: Linux Distribution) provides information about the Linux +distribution it runs on, such as a reliable machine-readable ID, or version +information. + +It is a renewed alternative implementation for Python's original +platform.linux_distribution function, but it also provides much more +functionality which isn't necessarily Python bound like a command-line +interface. + +WWW: https://github.com/nir0s/distro