Verified Commit 18c6ce08 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

Add support for boards package lists filter

This is filter for both package lists as well its options to skip them
if they are not compatible with current board. This is primarily
intended to support hardware specific extension in package lists.

No change is required outside of updater-supervisor as package lists are
just skipped and considered as not defined (not existing).
parent ff3302c7
......@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Support for package lists filter based on board
- New dependency is now distro
## [1.3.0] - 2020-04-09
### Added
- options for pkglists
......
......@@ -41,6 +41,7 @@ setup(
]
},
install_requires=[
"distro",
"pyuci @ git+https://gitlab.labs.nic.cz/turris/pyuci.git",
],
)
import distro
# These are all board
BOARDS = (
"mox",
"omnia",
"turris1x"
)
# turrishw mapping to updater names
BOARD_MAP = {
"Turris Mox": "mox",
"Turris Omnia": "omnia",
"Turris 1.x": "turris1x",
}
__board = None
def board():
"""Returns board name as expected by updater components of current board host.
"""
global __board
if __board is None:
__board = BOARD_MAP.get(distro.os_release_attr("openwrt_device_product"), "unknown")
return __board
......@@ -29,6 +29,7 @@ import typing
from euci import EUci
from .const import PKGLISTS_FILE, PKGLISTS_LABELS_FILE
from .exceptions import UpdaterNoSuchListError, UpdaterNoSuchListOptionError
from . import _board
__PKGLIST_ENTRIES_LABELS = typing.Dict[str, str]
__PKGLIST_ENTRIES_OPTIONS = typing.Dict[str, typing.Union[str, bool, __PKGLIST_ENTRIES_LABELS]]
......@@ -69,6 +70,7 @@ def __options(pkglist_name, trans, uci, known_labels, options):
"url": option.get('url'),
"labels": __labels(known_labels, trans, option.get('labels', {})),
} for name, option in options.items()
if _board.board() in option.get('boards', _board.BOARDS)
}
......@@ -122,6 +124,7 @@ def pkglists(lang=None) -> typing.Dict[str, __PKGLIST_ENTRIES]:
"options": __options(name, trans, uci, known_labels, lst.get('options', {})),
"labels": __labels(known_labels, trans, lst.get('labels', {})),
} for name, lst in known_lists.items()
if _board.board() in lst.get('boards', _board.BOARDS)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment