8.39. platformids.embed.armbian

Module Armbian [doc].

8.39.1. Module

Armbian releases.

The Armbian Linux is implemented as a module based on custom numbering scheme due to the specific value ranges, which are required for this distribution only.

The Armbian distribution represents a shrinked multi-role PC-Platform as an embedded system with integrated low-level HW interfaces for a wide range of ARM based boards.

8.39.2. Data

8.39.2.1. RTE_ARMBIAN

Registration of the dist value:

RTE_ARMBIAN        = RTE_LINUX   + custom_dist.add_enum()

8.39.2.2. rte2num

Mapping of the rte string and numeric representation to the numeric value.

8.39.2.3. num2rte

Mapping of the rte numeric representation to the string value.

8.39.2.4. num2pretty

Mapping of the rte numeric representation to the pretty string value.

8.39.2.5. custom_rte_distrel2tuple

Registered callbacks for special handling of custom layout.

custom_rte_distrel2tuple.update(
    {
        RTE_ARMBIAN: my_distrel2tuple,  #: the callback to be registered
    }
)

8.39.3. Functions

8.39.3.1. my_distrel2tuple

platformids.embed.armbian.my_distrel2tuple(rte=276917248)[source]

Callback for special version layout of Armbian, see manuals.

A callback to be used by the function:

platformids.decode_rte_distrel_to_segments(rte=RTE)

Decodes the compressed distrel from the 32bit integer bitmask rte into the corresponding tuple of integer segments.

Parameters

**rte**

The comppressed runtime environment identifier bitmask.

default := RTE

Returns

Tuple of Integer values of the encoded segments, either as defined by the default layout, or any known as defined by additional extended and/or custom criteria.

Raises

pass-through

Examples

decode_rte_distrel_to_segments()
=>  (5, 50, 0)    # on Armbian-5.50

8.39.4. 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# -*- coding: utf-8 -*-
"""Armbian releases.

The *Armbian* Linux is implemented as a module 
based on custom numbering scheme due to the specific value ranges, 
which are required for this distribution only.

The *Armbian* distribution represents a *shrinked multi-role PC-Platform* as an
embedded system with integrated low-level HW interfaces for a wide range of *ARM*
based boards. 
"""
from __future__ import absolute_import

# from platformids import _debug, _verbose
from pythonids import PYV35Plus
from platformids import RTE, rte2num, num2rte, num2pretty, custom_rte_distrel2tuple, custom_dist, \
    decode_version_str_to_segments, \
    PlatformIDsUnknownError, \
    RTE_LINUX, RTE_DIST, \
    DSKORG_ID, DSKORG_RELEASE, DSKORG_VERSION, 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.1'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"


#
# *** special modifications ***
#
RTE_ARMBIAN = RTE_LINUX          + custom_dist.add_enum()    #: Armbian - re-grouped version sub-ranges 

    
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'armbian':   RTE_ARMBIAN,
        RTE_ARMBIAN: RTE_ARMBIAN,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_ARMBIAN:        'armbian',
    }
)

num2pretty.update(
    {
        RTE_ARMBIAN:         'Armbian',
    }
)


#-----------------------------------------------#
#                                               #
# optional constants for convenience            #
#                                               #
#-----------------------------------------------#


RTE_ARMBIAN5 = RTE_ARMBIAN          + 0x00002800 #: ARMBIAN - stretch
RTE_ARMBIAN550 = RTE_ARMBIAN5       + 0x00000190 #: ARMBIAN - stretch

    
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'armbian5':          RTE_ARMBIAN5,
        'armbian550':        RTE_ARMBIAN550,
        'Armbian-stretch':   RTE_ARMBIAN550,
        RTE_ARMBIAN5:        RTE_ARMBIAN5,
        RTE_ARMBIAN550:      RTE_ARMBIAN550,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_ARMBIAN5:        'armbian5',
        RTE_ARMBIAN550:      'armbian550',
    }
)


num2pretty.update(
    {
        RTE_ARMBIAN5:        'Armbian-stretch',
    }
)



# armbian
dist = ['', '', 'Armbian-', 'Armbian', '', '']

try:

    with open("/etc/os-release", 'r') as f:
        for l in f:
            if l.startswith('ID='):
                # id
                dist[0] = dist[5] = DSKORG_ID.sub(r'\1', l)

            elif l.startswith('VERSION='):
                # actual pretty name
                _pretty = DSKORG_RELEASE.split(l)[2]  # for now a reminder only 

    #
    # scan dist + distrel
    #
    with open("/etc/armbian-release", 'r') as f:
        # has it's own numbering
        for l in f:
            if l.startswith('VERSION='):
                dist[1] = DSKORG_VERSION.sub(r'\1', l)
                dist[4] = decode_version_str_to_segments(dist[1])
                dist[0] += '%d%d' % (dist[4][0], dist[4][1],)
                dist[2] += dist[1]
    

except PlatformIDsFileCheck:
    # not on armbian platform, so scan will fail
    pass


if dist[0] != 'armbian':
    # not actually armbian
    dist = ['armbian', '0.0.0', 'Armbian-0.0.0', 'Armbian', (0, 0, 0,), 'armbian']


def my_distrel2tuple(rte=RTE):
    """Callback for special version layout of Armbian, see manuals. 
    
    A callback to be used by the function:
    
       platformids.decode_rte_distrel_to_segments(rte=RTE)
    
    Decodes the compressed *distrel* from the 32bit integer
    bitmask *rte* into the corresponding tuple of integer
    segments.

   Args:
       **rte**:
           The comppressed runtime environment identifier bitmask.
            
           default := RTE

   Returns:
       Tuple of Integer values of the encoded segments, either
       as defined by the default layout, or any known as defined
       by additional extended and/or custom criteria.
    
   Raises:
       pass-through

   Examples:
     ::

        decode_rte_distrel_to_segments()     
        =>  (5, 50, 0)    # on Armbian-5.50

    """
    if rte & RTE_DIST != RTE_ARMBIAN:
        raise PlatformIDsUnknownError("Not Armbian:  rte = " + str(rte))
        
    try:
        # handle string input
        _rte = rte2num[rte]
        
    except KeyError:
        # non-registered release
        
        if type(rte) is int:
            # can split basically any number, let's see...
            _rte = rte

        else:
            raise PlatformIDsUnknownError("Unknown Armbian release rte = " + str(rte))

    # represents the Armbian layout
    return (
        (_rte & 0xf800) >> 11, 
        (_rte & 0x07f8) >> 3, 
        _rte & 0x0003, 
        )


#: registered callbacks for special handling of custom layout
custom_rte_distrel2tuple.update(
    {
        RTE_ARMBIAN: my_distrel2tuple,  #: the callback to be registered
    }
)

8.39.5. Download

armbian.py