forked from openwrt/asu
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file allows to modify package changes based on release, target and version. At some point it could become a YAML file but works for now. Signed-off-by: Paul Spooren <[email protected]>
- Loading branch information
Showing
3 changed files
with
111 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
|
||
log = logging.getLogger("rq.worker") | ||
|
||
|
||
def appy_package_changes(req): | ||
""" | ||
Apply package changes to the request | ||
Args: | ||
req (dict): The image request | ||
log (logging.Logger): The logger to use | ||
""" | ||
|
||
def _add_if_missing(package): | ||
if package not in req["packages"]: | ||
req["packages"].append(package) | ||
log.debug(f"Added {package} to packages") | ||
|
||
# 23.05 specific changes | ||
if req["version"].startswith("23.05"): | ||
# mediatek/mt7622 specific changes | ||
if req["target"] == "mediatek/mt7622": | ||
_add_if_missing("kmod-mt7622-firmware") | ||
log.debug("Added kmod-mt7622-firmware to packages") | ||
|
||
# ath79/generic specific changes | ||
elif req["target"] == "ath79/generic": | ||
if req["profile"] in { | ||
"buffalo_wzr-hp-g300nh-s", | ||
"dlink_dir-825-b1", | ||
"netgear_wndr3700", | ||
"netgear_wndr3700-v2", | ||
"netgear_wndr3800", | ||
"netgear_wndr3800ch", | ||
"netgear_wndrmac-v1", | ||
"netgear_wndrmac-v2", | ||
"trendnet_tew-673gru", | ||
}: | ||
_add_if_missing("kmod-switch-rtl8366s") | ||
log.debug("Added kmod-switch-rtl8366s to packages") | ||
|
||
elif req["profile"] == "buffalo_wzr-hp-g300nh-rb": | ||
_add_if_missing("kmod-switch-rtl8366rb") | ||
log.debug("Added kmod-switch-rtl8366rb to packages") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
|
||
from asu.package_changes import appy_package_changes | ||
|
||
|
||
def test_apply_package_changes_adds_kmod_switch_rtl8366s(): | ||
req = { | ||
"version": "23.05", | ||
"target": "ath79/generic", | ||
"profile": "buffalo_wzr-hp-g300nh-s", | ||
"packages": ["kmod-ath9k-htc"], | ||
} | ||
appy_package_changes(req) | ||
|
||
assert "kmod-switch-rtl8366s" in req["packages"] | ||
|
||
|
||
def test_apply_package_changes_does_not_add_duplicate_packages(): | ||
req = { | ||
"version": "23.05", | ||
"target": "ath79/generic", | ||
"profile": "buffalo_wzr-hp-g300nh-s", | ||
"packages": ["kmod-ath9k-htc", "kmod-switch-rtl8366s"], | ||
} | ||
appy_package_changes(req) | ||
|
||
assert req["packages"] == ["kmod-ath9k-htc", "kmod-switch-rtl8366s"] | ||
|
||
|
||
def test_apply_package_changes_does_not_modify_input_dict(): | ||
req = { | ||
"version": "23.05", | ||
"target": "ath79/generic", | ||
"profile": "buffalo_wzr-hp-g300nh-s", | ||
"packages": ["kmod-ath9k-htc"], | ||
} | ||
original_req = req.copy() | ||
appy_package_changes(req) | ||
|
||
assert req == original_req | ||
|
||
|
||
def test_apply_package_changes_release(): | ||
req = { | ||
"version": "21.02.0-rc1", | ||
"target": "ath79/generic", | ||
"profile": "buffalo_wzr-hp-g300nh-s", | ||
"packages": ["kmod-ath9k-htc"], | ||
} | ||
appy_package_changes(req) | ||
|
||
original_req = req.copy() | ||
appy_package_changes(req) | ||
|
||
def test_apply_package_changes_mediatek(): | ||
req = { | ||
"version": "23.05", | ||
"target": "mediatek/mt7622", | ||
"profile": "foobar", | ||
"packages": ["ubus"], | ||
} | ||
appy_package_changes(req) | ||
|
||
assert "kmod-mt7622-firmware" in req["packages"] |