8.13. platformids.dist.netbsd¶
Module NetBSD [doc].
8.13.1. Source¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # -*- coding: utf-8 -*-
"""NetBSD releases.
"""
from __future__ import absolute_import
import sys
import os
import re
import platform
from pythonids import PYV35Plus
from platformids import RTE_BSD, rte2num, num2rte, num2pretty, decode_version_str_to_segments, \
PlatformIDsFileCheck
__author__ = 'Arno-Can Uestuensoez'
__license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
__copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
" @Ingenieurbuero Arno-Can Uestuensoez"
__version__ = '0.1.29'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
RTE_NETBSD = RTE_BSD + 0x00060000 #: NetBSD
RTE_NETBSD60 = RTE_NETBSD + 0x00001800 #: NETBSD-6.0
RTE_NETBSD70 = RTE_NETBSD + 0x00001c00 #: NETBSD-7.0
RTE_NETBSD71 = RTE_NETBSD + 0x00001c20 #: NETBSD-7.1
RTE_NETBSD80 = RTE_NETBSD + 0x00002000 #: NETBSD-8.0
RTE_NETBSD90 = RTE_NETBSD + 0x00002400 #: NETBSD-9.0
RTE_NETBSD100 = RTE_NETBSD + 0x00002800 #: NETBSD-10.0
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
{
'netbsd': RTE_NETBSD,
'netbsd60': RTE_NETBSD60,
'netbsd71': RTE_NETBSD71,
'netbsd70': RTE_NETBSD70,
'netbsd80': RTE_NETBSD80,
'netbsd90': RTE_NETBSD90,
RTE_NETBSD: RTE_NETBSD,
RTE_NETBSD60: RTE_NETBSD60,
RTE_NETBSD70: RTE_NETBSD70,
RTE_NETBSD71: RTE_NETBSD71,
RTE_NETBSD80: RTE_NETBSD80,
RTE_NETBSD90: RTE_NETBSD90,
}
)
#: mapping of the rte numeric representation to the string value
num2rte.update(
{
RTE_NETBSD: 'netbsd',
RTE_NETBSD60: 'netbsd60',
RTE_NETBSD70: 'netbsd70',
RTE_NETBSD71: 'netbsd71',
RTE_NETBSD80: 'netbsd80',
RTE_NETBSD90: 'netbsd90',
}
)
#: mapping of the rte numeric representation to the pretty string value
num2pretty.update(
{
RTE_NETBSD: 'NetBSD',
}
)
dist = ['', '', 'NetBSD', 'NetBSD', '', '']
try:
if sys.platform.lower().startswith('netbsd'):
# FreeBSD - CPython, PyPy, IPython
dist[1] = platform.release()
dist[5] = 'netbsd'
elif os.path.exists('/etc/netbsd-update.conf'):
# FreeBSD - match on Jython
x = os.popen("sysctl kern.ostype kern.osrelease", mode='r')
if x.readline().endswith("NetBSD\n"):
dist[1] = re.sub(r'[^=]*=([0-9.]*).*$', r'\1', x.readline())
dist[5] = 'netbsd'
x.close()
if dist[5] == 'netbsd':
dist[4] = decode_version_str_to_segments(dist[1])
dist[0] = 'netbsd%d' % (dist[4][0], dist[4][1], )
dist[2] = 'NetBSD-%d.%d.%d' %(dist[4][0], dist[4][1], dist[4][2], )
except PlatformIDsFileCheck:
# not on NetBSD platform, so scan will fail
pass
if dist[5] != 'netbsd':
# does not actually match NetBSD
dist = ['netbsd', '0.0.0', 'NetBSD-0.0.0', 'NetBSD', (0, 0, 0,), 'netbsd']
|