Package platformids ::
Package custom ::
Module minix
1
2 """Example for a dynamic added custom platform.
3
4 Here Minix as a new OS type, which actually has a default
5 release version layout, and though could be handled by the
6 default handler.
7
8 """
9 from __future__ import absolute_import
10
11 from platformids import RTE, rte2num, num2rte, num2pretty, \
12 RTE_POSIX, RTE_OSTYPE, RTE_DIST, \
13 custom_ostype, custom_dist, custom_rte_distrel2tuple, \
14 PlatformIDsUnknownError
15
16
17 __author__ = 'Arno-Can Uestuensoez'
18 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
19 __copyright__ = "Copyright (C) 2019 Arno-Can Uestuensoez" \
20 " @Ingenieurbuero Arno-Can Uestuensoez"
21 __version__ = '0.0.1'
22 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
23
24
25 RTE_MINIX = RTE_POSIX + custom_ostype.add_enum()
26 RTE_MINIX3 = RTE_MINIX + custom_dist.add_enum()
27
28
29
30 rte2num.update(
31 {
32 'minix': RTE_MINIX,
33 'minix3': RTE_MINIX3,
34 RTE_MINIX: RTE_MINIX,
35 RTE_MINIX3: RTE_MINIX3,
36 }
37 )
38
39
40
41 num2rte.update(
42 {
43 RTE_MINIX: 'minix',
44 RTE_MINIX3: 'minix3',
45 }
46 )
47
48
49 num2pretty.update(
50 {
51 RTE_MINIX: 'Minix',
52 RTE_MINIX3: 'Minix3',
53 }
54 )
55
56
57
58
59
60
61
62 RTE_MINIX321 = RTE_MINIX + 0x00000641
63 RTE_MINIX330 = RTE_MINIX + 0x00000660
64
65
66
67 rte2num.update(
68 {
69 'minix321': RTE_MINIX321,
70 'minix330': RTE_MINIX330,
71 RTE_MINIX321: RTE_MINIX321,
72 RTE_MINIX330: RTE_MINIX330,
73 }
74 )
75
76
77
78 num2rte.update(
79 {
80 RTE_MINIX321: 'minix321',
81 RTE_MINIX330: 'minix330',
82 }
83 )
84
85
86 num2pretty.update(
87 {
88 RTE_MINIX321: 'Minix-3.2.1',
89 RTE_MINIX330: 'Minix-3.3.0',
90 }
91 )
92
94 """
95 A custom example only - standard encoding is default layout.
96
97 Convert the *Minix* specific *distrel* version layout
98 to a tuple.
99
100 A callback to be used by the function:
101
102 platformids.decode_rte_distrel_to_segments(rte=RTE)
103
104 Decodes the compressed *distrel* from the 32bit integer
105 bitmask *rte* into the corresponding tuple of integer
106 segments.
107
108 Args:
109 rte:
110 The comppressed runtime environment identifier bitmask.
111
112 default := RTE
113
114 Returns:
115 Tuple of Integer values of the encoded segments, either
116 as defined by the default layout, or any known as defined
117 by additional extended and/or custom criteria.
118
119 Raises:
120 pass-through
121
122 Examples:
123 ::
124
125 decode_rte_distrel_to_segments()
126 => (3, 2, 1) # on Minix-3.2.1
127 => (3, 3, 0) # on Minix-3.3.0
128
129 """
130 if rte & RTE_OSTYPE != RTE_MINIX:
131 raise PlatformIDsUnknownError("Not Minix: rte = " + str(rte))
132
133 if rte & RTE_DIST != RTE_MINIX3:
134 raise PlatformIDsUnknownError("Not Minix3: rte = " + str(rte))
135
136 try:
137 _rte = rte2num[rte]
138 except KeyError:
139
140
141 if type(_rte) is int:
142
143 _rte = rte
144
145 else:
146 raise PlatformIDsUnknownError("Unknown Minix3 release rte = " + str(rte))
147
148
149 return (
150 _rte & 0xfc00,
151 _rte & 0x03e0,
152 _rte & 0x001f,
153 )
154
155
156
157 custom_rte_distrel2tuple.update(
158 {
159
160
161 RTE_MINIX3: my_distrel2tuple,
162 }
163 )
164