diff --git a/aports/device/device-qemu-aarch64/APKBUILD b/aports/device/device-qemu-aarch64/APKBUILD index 9811d2c6..024f89a8 100644 --- a/aports/device/device-qemu-aarch64/APKBUILD +++ b/aports/device/device-qemu-aarch64/APKBUILD @@ -1,14 +1,15 @@ pkgname=device-qemu-aarch64 pkgver=1 -pkgrel=8 +pkgrel=9 pkgdesc="Simulated device in qemu with vexpress soc" url="https://github.com/postmarketOS" arch="noarch" license="MIT" -depends="linux-postmarketos-stable mesa-dri-swrast" +# NOTE: 'pmbootstrap init' allows you to choose the mesa-dri-* package +depends="linux-postmarketos-stable" makedepends="" -subpackages="" -source="deviceinfo interfaces" +subpackages="$pkgname-weston" +source="deviceinfo interfaces weston.ini" options="!check" package() { @@ -18,5 +19,13 @@ package() { "$pkgdir"/etc/network/interfaces } +weston() { + install_if="$pkgname weston" + install -Dm644 "$srcdir"/weston.ini \ + "$subpkgdir"/etc/xdg/weston/weston.ini +} + + sha512sums="8802ad301bffd10d79db938adecf4bbdf8293c8caefe5fce753c56f228a7212330318a0be9853a83442e8971bbc235269796fe66077c501d35a935df1d2ed90c deviceinfo -d510ca304066840aa5e6c4fc71ded1b7e83012c93837fa39e37bdb873b3636230030d56f7aa50c93fc688f563cb4cb96c02ad333bbc45a400c1ebee1792a9dd4 interfaces" +d510ca304066840aa5e6c4fc71ded1b7e83012c93837fa39e37bdb873b3636230030d56f7aa50c93fc688f563cb4cb96c02ad333bbc45a400c1ebee1792a9dd4 interfaces +df0fe900693e5f176076c59f5379e56aaa96c3df16a4120448f15b71f530170730b43e5fe32733c40c118a00ca3581043231a062a8a1eb0a930bfbfbb6c52a47 weston.ini" diff --git a/aports/device/device-qemu-aarch64/weston.ini b/aports/device/device-qemu-aarch64/weston.ini new file mode 100644 index 00000000..97356c2b --- /dev/null +++ b/aports/device/device-qemu-aarch64/weston.ini @@ -0,0 +1,3 @@ +[core] +xwayland=true +backend=drm-backend.so diff --git a/aports/device/device-qemu-vexpress/APKBUILD b/aports/device/device-qemu-vexpress/APKBUILD index 96658e84..efd8622b 100644 --- a/aports/device/device-qemu-vexpress/APKBUILD +++ b/aports/device/device-qemu-vexpress/APKBUILD @@ -1,11 +1,12 @@ pkgname=device-qemu-vexpress pkgver=1 -pkgrel=15 +pkgrel=16 pkgdesc="Simulated device in qemu with vexpress soc" url="https://github.com/postmarketOS" arch="noarch" license="MIT" -depends="linux-postmarketos-stable mesa-dri-swrast" +# NOTE: 'pmbootstrap init' allows you to choose the mesa-dri-* package +depends="linux-postmarketos-lts" makedepends="" subpackages="" source="deviceinfo interfaces" diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index 7e4575c3..c3abffa4 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -46,7 +46,7 @@ work_version = "1" # Only save keys to the config file, which we ask for in 'pmbootstrap init'. config_keys = ["ccache_size", "device", "extra_packages", "jobs", "keymap", - "qemu_mesa_driver", "timestamp_based_rebuild", "timezone", + "qemu_native_mesa_driver", "timestamp_based_rebuild", "timezone", "ui", "user", "work"] # Config file/commandline default values @@ -72,7 +72,7 @@ defaults = { "mirror_alpine": "http://dl-cdn.alpinelinux.org/alpine/", "mirror_postmarketos": "http://postmarketos.brixit.nl", "port_distccd": "33632", - "qemu_mesa_driver": "dri-virtio", + "qemu_native_mesa_driver": "dri-virtio", "timestamp_based_rebuild": True, "timezone": "GMT", "ui": "weston", @@ -383,4 +383,4 @@ aportgen = { # # QEMU # -qemu_mesa_drivers = ["dri-swrast", "dri-virtio"] +qemu_native_mesa_drivers = ["dri-swrast", "dri-virtio"] diff --git a/pmb/config/init.py b/pmb/config/init.py index fec5c91e..c00416b7 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -81,7 +81,7 @@ def ask_for_ui(args): def ask_for_keymaps(args, device): - info = pmb.parse.deviceinfo(args, device=device) + info = pmb.parse.deviceinfo(args, device) if "keymaps" not in info or info["keymaps"].strip() == "": return "" options = info["keymaps"].split(' ') @@ -147,18 +147,23 @@ def ask_for_device(args): return (device, device_exists) -def ask_for_qemu_mesa_driver(args): - drivers = pmb.config.qemu_mesa_drivers - logging.info("Which mesa driver do you prefer for your Qemu device? Only" - " select something other than the default if you are having" - " graphical problems (such as glitches).") +def ask_for_qemu_native_mesa_driver(args, device, arch_native): + # Native Qemu device selected? (e.g. qemu-amd64 on x86_64) + if not pmb.parse.arch.qemu_check_device(device, arch_native): + return None + + drivers = pmb.config.qemu_native_mesa_drivers + logging.info("Which mesa driver do you prefer for your native Qemu device?" + " Only select something other than the default if you are" + " having graphical problems (such as glitches).") while True: ret = pmb.helpers.cli.ask(args, "Mesa driver", drivers, - args.qemu_mesa_driver) + args.qemu_native_mesa_driver) if ret in drivers: return ret logging.fatal("ERROR: Please specify a driver from the list. To change" - " it, see qemu_mesa_drivers in pmb/config/__init__.py.") + " it, see qemu_native_mesa_drivers in" + " pmb/config/__init__.py.") def ask_for_build_options(args, cfg): @@ -205,16 +210,18 @@ def frontend(args): cfg["pmbootstrap"]["work"] = args.work = ask_for_work_path(args) # Device - cfg["pmbootstrap"]["device"], device_exists = ask_for_device(args) + device, device_exists = ask_for_device(args) + cfg["pmbootstrap"]["device"] = device # Qemu mesa driver if cfg["pmbootstrap"]["device"].startswith("qemu-"): - cfg["pmbootstrap"]["qemu_mesa_driver"] = ask_for_qemu_mesa_driver(args) + driver = ask_for_qemu_native_mesa_driver(args, device, args.arch_native) + if driver: + cfg["pmbootstrap"]["qemu_native_mesa_driver"] = driver # Device keymap if device_exists: - cfg["pmbootstrap"]["keymap"] = ask_for_keymaps( - args, device=cfg["pmbootstrap"]["device"]) + cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, device) # Username cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask(args, "Username", None, @@ -243,8 +250,8 @@ def frontend(args): if (device_exists and len(glob.glob(args.work + "/chroot_*")) and pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)): - setattr(args, "deviceinfo", pmb.parse.deviceinfo( - args, device=cfg["pmbootstrap"]["device"])) + setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device)) + # Do not zap any existing packages or cache_http directories pmb.chroot.zap(args, confirm=False) diff --git a/pmb/install/install.py b/pmb/install/install.py index 668ff71c..98b00f06 100644 --- a/pmb/install/install.py +++ b/pmb/install/install.py @@ -308,7 +308,7 @@ def install(args): if args.add: install_packages += args.add.split(",") if args.device.startswith("qemu-"): - install_packages += ["mesa-" + args.qemu_mesa_driver] + install_packages += ["mesa-" + args.qemu_native_mesa_driver] for pkgname in install_packages: pmb.build.package(args, pkgname, args.deviceinfo["arch"]) diff --git a/pmb/parse/arch.py b/pmb/parse/arch.py index bb240249..0bd1db81 100644 --- a/pmb/parse/arch.py +++ b/pmb/parse/arch.py @@ -159,3 +159,16 @@ def qemu_to_pmos_device(arch): raise ValueError("Can not map QEMU value '" + arch + "'" " to the right postmarketOS device") + + +def qemu_check_device(device, arch): + """ + Check whether a device has a specific architecture. + + Examples: + qemu_check_device("qemu-amd64", "x86_64") is True + qemu_check_device("qemu-vexpress", "armel") is True + qemu_check_device("qemu-vexpress", "aarch64") is False + """ + arch_qemu = uname_to_qemu(arch) + return device == qemu_to_pmos_device(arch_qemu) diff --git a/pmb/qemu/run.py b/pmb/qemu/run.py index 12b72716..aca73a13 100644 --- a/pmb/qemu/run.py +++ b/pmb/qemu/run.py @@ -157,12 +157,12 @@ def command_qemu(args, arch, device, img_path, spice_enabled): raise RuntimeError("Architecture {} not supported by this command yet.".format(arch)) # Kernel Virtual Machine (KVM) support - enable_kvm = True + native = True if args.arch: arch1 = pmb.parse.arch.uname_to_qemu(args.arch_native) arch2 = pmb.parse.arch.uname_to_qemu(args.arch) - enable_kvm = (arch1 == arch2) - if enable_kvm and os.path.exists("/dev/kvm"): + native = (arch1 == arch2) + if native and os.path.exists("/dev/kvm"): command += ["-enable-kvm"] else: logging.info("WARNING: Qemu is not using KVM and will run slower!") @@ -174,7 +174,7 @@ def command_qemu(args, arch, device, img_path, spice_enabled): "port=" + args.spice_port + ",addr=127.0.0.1" + ",disable-ticketing"] else: - if args.qemu_mesa_driver == "dri-virtio": + if native and args.qemu_native_mesa_driver == "dri-virtio": command += ["-vga", "virtio"] command += ["-display", args.qemu_display] diff --git a/test/test_questions.py b/test/test_questions.py index 93f207c9..a121177a 100644 --- a/test/test_questions.py +++ b/test/test_questions.py @@ -140,10 +140,11 @@ def test_questions(args, monkeypatch, tmpdir): assert func(args, "nokia-rx51") == "us/rx51_us" assert func(args, "lg-mako") == "" - # Qemu mesa driver - func = pmb.config.init.ask_for_qemu_mesa_driver + # Qemu native mesa driver + func = pmb.config.init.ask_for_qemu_native_mesa_driver answers = ["invalid_driver", "dri-swrast"] - assert func(args) == "dri-swrast" + assert func(args, "qemu-amd64", "x86_64") == "dri-swrast" + assert func(args, "qemu-aarch64", "x86_64") is None # UI answers = ["invalid_UI", "weston"]