Package platformids ::
Package embed ::
Module armbian
1
2 """Armbian releases.
3
4 The *Armbian* Linux is implemented as a module
5 based on custom numbering scheme due to the specific value ranges,
6 which are required for this distribution only.
7
8 The *Armbian* distribution represents a *shrinked multi-role PC-Platform* as an
9 embedded system with integrated low-level HW interfaces for a wide range of *ARM*
10 based boards.
11 """
12 from __future__ import absolute_import
13
14
15 from pythonids import PYV35Plus
16 from platformids import RTE, rte2num, num2rte, num2pretty, custom_rte_distrel2tuple, custom_dist, \
17 decode_version_str_to_segments, \
18 PlatformIDsUnknownError, \
19 RTE_LINUX, RTE_DIST, \
20 DSKORG_ID, DSKORG_RELEASE, DSKORG_VERSION, PlatformIDsFileCheck
21
22
23 __author__ = 'Arno-Can Uestuensoez'
24 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
25 __copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
26 " @Ingenieurbuero Arno-Can Uestuensoez"
27 __version__ = '0.1.1'
28 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
29
30
31
32
33
34 RTE_ARMBIAN = RTE_LINUX + custom_dist.add_enum()
35
36
37
38 rte2num.update(
39 {
40 'armbian': RTE_ARMBIAN,
41 RTE_ARMBIAN: RTE_ARMBIAN,
42 }
43 )
44
45
46
47 num2rte.update(
48 {
49 RTE_ARMBIAN: 'armbian',
50 }
51 )
52
53 num2pretty.update(
54 {
55 RTE_ARMBIAN: 'Armbian',
56 }
57 )
58
59
60
61
62
63
64
65
66
67 RTE_ARMBIAN5 = RTE_ARMBIAN + 0x00002800
68 RTE_ARMBIAN550 = RTE_ARMBIAN5 + 0x00000190
69
70
71
72 rte2num.update(
73 {
74 'armbian5': RTE_ARMBIAN5,
75 'armbian550': RTE_ARMBIAN550,
76 'Armbian-stretch': RTE_ARMBIAN550,
77 RTE_ARMBIAN5: RTE_ARMBIAN5,
78 RTE_ARMBIAN550: RTE_ARMBIAN550,
79 }
80 )
81
82
83
84 num2rte.update(
85 {
86 RTE_ARMBIAN5: 'armbian5',
87 RTE_ARMBIAN550: 'armbian550',
88 }
89 )
90
91
92 num2pretty.update(
93 {
94 RTE_ARMBIAN5: 'Armbian-stretch',
95 }
96 )
97
98
99
100
101 dist = ['', '', 'Armbian-', 'Armbian', '', '']
102
103 try:
104
105 with open("/etc/os-release", 'r') as f:
106 for l in f:
107 if l.startswith('ID='):
108
109 dist[0] = dist[5] = DSKORG_ID.sub(r'\1', l)
110
111 elif l.startswith('VERSION='):
112
113 _pretty = DSKORG_RELEASE.split(l)[2]
114
115
116
117
118 with open("/etc/armbian-release", 'r') as f:
119
120 for l in f:
121 if l.startswith('VERSION='):
122 dist[1] = DSKORG_VERSION.sub(r'\1', l)
123 dist[4] = decode_version_str_to_segments(dist[1])
124 dist[0] += '%d%d' % (dist[4][0], dist[4][1],)
125 dist[2] += dist[1]
126
127
128 except PlatformIDsFileCheck:
129
130 pass
131
132
133 if dist[0] != 'armbian':
134
135 dist = ['armbian', '0.0.0', 'Armbian-0.0.0', 'Armbian', (0, 0, 0,), 'armbian']
136
137
139 """Callback for special version layout of Armbian, see manuals.
140
141 A callback to be used by the function:
142
143 platformids.decode_rte_distrel_to_segments(rte=RTE)
144
145 Decodes the compressed *distrel* from the 32bit integer
146 bitmask *rte* into the corresponding tuple of integer
147 segments.
148
149 Args:
150 **rte**:
151 The comppressed runtime environment identifier bitmask.
152
153 default := RTE
154
155 Returns:
156 Tuple of Integer values of the encoded segments, either
157 as defined by the default layout, or any known as defined
158 by additional extended and/or custom criteria.
159
160 Raises:
161 pass-through
162
163 Examples:
164 ::
165
166 decode_rte_distrel_to_segments()
167 => (5, 50, 0) # on Armbian-5.50
168
169 """
170 if rte & RTE_DIST != RTE_ARMBIAN:
171 raise PlatformIDsUnknownError("Not Armbian: rte = " + str(rte))
172
173 try:
174
175 _rte = rte2num[rte]
176
177 except KeyError:
178
179
180 if type(rte) is int:
181
182 _rte = rte
183
184 else:
185 raise PlatformIDsUnknownError("Unknown Armbian release rte = " + str(rte))
186
187
188 return (
189 (_rte & 0xf800) >> 11,
190 (_rte & 0x07f8) >> 3,
191 _rte & 0x0003,
192 )
193
194
195
196 custom_rte_distrel2tuple.update(
197 {
198 RTE_ARMBIAN: my_distrel2tuple,
199 }
200 )
201