pmbootstrap init: only display UIs for device arch (MR 1937)
Hide user interfaces that are not available for the selected device's architecture. Closes #1790
This commit is contained in:
parent
2d2ab1df56
commit
0ff9c5d471
|
@ -105,8 +105,9 @@ def ask_for_channel(args):
|
||||||
" from the list above.")
|
" from the list above.")
|
||||||
|
|
||||||
|
|
||||||
def ask_for_ui(args):
|
def ask_for_ui(args, device):
|
||||||
ui_list = pmb.helpers.ui.list(args)
|
info = pmb.parse.deviceinfo(args, device)
|
||||||
|
ui_list = pmb.helpers.ui.list(args, info["arch"])
|
||||||
logging.info("Available user interfaces (" +
|
logging.info("Available user interfaces (" +
|
||||||
str(len(ui_list) - 1) + "): ")
|
str(len(ui_list) - 1) + "): ")
|
||||||
ui_completion_list = []
|
ui_completion_list = []
|
||||||
|
@ -419,7 +420,7 @@ def frontend(args):
|
||||||
args.user, False,
|
args.user, False,
|
||||||
"[a-z_][a-z0-9_-]*")
|
"[a-z_][a-z0-9_-]*")
|
||||||
# UI and various build options
|
# UI and various build options
|
||||||
ui = ask_for_ui(args)
|
ui = ask_for_ui(args, device)
|
||||||
cfg["pmbootstrap"]["ui"] = ui
|
cfg["pmbootstrap"]["ui"] = ui
|
||||||
cfg["pmbootstrap"]["ui_extras"] = str(ask_for_ui_extras(args, ui))
|
cfg["pmbootstrap"]["ui_extras"] = str(ask_for_ui_extras(args, ui))
|
||||||
ask_for_build_options(args, cfg)
|
ask_for_build_options(args, cfg)
|
||||||
|
|
|
@ -5,15 +5,17 @@ import glob
|
||||||
import pmb.parse
|
import pmb.parse
|
||||||
|
|
||||||
|
|
||||||
def list(args):
|
def list(args, arch):
|
||||||
"""
|
"""
|
||||||
Get all UIs, for which aports are available with their description.
|
Get all UIs, for which aports are available with their description.
|
||||||
|
|
||||||
|
:param arch: device architecture, for which the UIs must be available
|
||||||
:returns: [("none", "No graphical..."), ("weston", "Wayland reference...")]
|
:returns: [("none", "No graphical..."), ("weston", "Wayland reference...")]
|
||||||
"""
|
"""
|
||||||
ret = [("none", "No graphical environment")]
|
ret = [("none", "No graphical environment")]
|
||||||
for path in sorted(glob.glob(args.aports + "/main/postmarketos-ui-*")):
|
for path in sorted(glob.glob(args.aports + "/main/postmarketos-ui-*")):
|
||||||
apkbuild = pmb.parse.apkbuild(args, path + "/APKBUILD")
|
apkbuild = pmb.parse.apkbuild(args, path + "/APKBUILD")
|
||||||
ui = os.path.basename(path).split("-", 2)[2]
|
ui = os.path.basename(path).split("-", 2)[2]
|
||||||
ret.append((ui, apkbuild["pkgdesc"]))
|
if pmb.helpers.package.check_arch(args, apkbuild["pkgname"], arch):
|
||||||
|
ret.append((ui, apkbuild["pkgdesc"]))
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Copyright 2020 Oliver Smith
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pmb_test
|
||||||
|
import pmb_test.const
|
||||||
|
import pmb.helpers.logging
|
||||||
|
import pmb.helpers.ui
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def args(tmpdir, request):
|
||||||
|
import pmb.parse
|
||||||
|
cfg = f"{pmb_test.const.testdata}/channels.cfg"
|
||||||
|
sys.argv = ["pmbootstrap.py", "--config-channels", cfg, "init"]
|
||||||
|
args = pmb.parse.arguments()
|
||||||
|
args.log = args.work + "/log_testsuite.txt"
|
||||||
|
pmb.helpers.logging.init(args)
|
||||||
|
request.addfinalizer(args.logfd.close)
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def test_helpers_ui(args):
|
||||||
|
""" Test the UIs returned by pmb.helpers.ui.list() with a testdata pmaports
|
||||||
|
dir. That test dir has a plasma-mobile UI, which is disabled for armhf,
|
||||||
|
so it must not be returned when querying the UI list for armhf. """
|
||||||
|
args.aports = f"{pmb_test.const.testdata}/helpers_ui/pmaports"
|
||||||
|
func = pmb.helpers.ui.list
|
||||||
|
assert func(args, "armhf") == [("none", "No graphical environment")]
|
||||||
|
assert func(args, "x86_64") == [("none", "No graphical environment"),
|
||||||
|
("plasma-mobile", "cool pkgdesc")]
|
|
@ -216,12 +216,13 @@ def test_questions_keymaps(args, monkeypatch):
|
||||||
|
|
||||||
def test_questions_ui(args, monkeypatch):
|
def test_questions_ui(args, monkeypatch):
|
||||||
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
|
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
|
||||||
|
device = "lg-mako"
|
||||||
|
|
||||||
fake_answers(monkeypatch, ["none"])
|
fake_answers(monkeypatch, ["none"])
|
||||||
assert pmb.config.init.ask_for_ui(args) == "none"
|
assert pmb.config.init.ask_for_ui(args, device) == "none"
|
||||||
|
|
||||||
fake_answers(monkeypatch, ["invalid_UI", "weston"])
|
fake_answers(monkeypatch, ["invalid_UI", "weston"])
|
||||||
assert pmb.config.init.ask_for_ui(args) == "weston"
|
assert pmb.config.init.ask_for_ui(args, device) == "weston"
|
||||||
|
|
||||||
|
|
||||||
def test_questions_ui_extras(args, monkeypatch):
|
def test_questions_ui_extras(args, monkeypatch):
|
||||||
|
|
11
test/testdata/helpers_ui/pmaports/main/postmarketos-ui-plasma-mobile/APKBUILD
vendored
Normal file
11
test/testdata/helpers_ui/pmaports/main/postmarketos-ui-plasma-mobile/APKBUILD
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
pkgname=postmarketos-ui-plasma-mobile
|
||||||
|
pkgver=42
|
||||||
|
pkgrel=0
|
||||||
|
pkgdesc="cool pkgdesc"
|
||||||
|
url="https://postmarketos.org"
|
||||||
|
arch="noarch !armhf"
|
||||||
|
license="GPL-3.0-or-later"
|
||||||
|
|
||||||
|
package() {
|
||||||
|
mkdir "$pkgdir"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
../../pmaports.cfg
|
Loading…
Reference in New Issue