Commit Graph

1802 Commits

Author SHA1 Message Date
Alexey Min e6da56d9b0
add "flasher flash_vbmeta" command (!1885)
Flashes device vbmeta partition (can be overriden with
"flash_fastboot_partition_vbmeta" setting in deviceinfo)
with custom vbmeta.img which has verity flag disabled,
so device can boot postmarketOS with no problems.
2020-03-21 20:58:08 +01:00
Daniele Debernardi 45f5ace1c2
pmb.helpers.frontend: fix wrong package name in kconfig check (!1891)
The kconfig check searches the aport with the "linux-" prefix to the
package name passed as argument. This is not working with the full
package name like linux-device-name because it searches a
linux-linux-device-name and fails.
2020-03-21 19:41:08 +01:00
Oliver Smith 2933b57f5d
README.md: mention "pmbootstrap status" (!1882) 2020-03-14 19:15:32 +03:00
Oliver Smith cfd93bc6ea
pmbootstrap status: check if git repo is outdated (!1882)
Use the timestamp of .git/FETCH_HEAD in each git repository, to
determine if too much time has passed since the last fetch/pull.
Modify pmb.helpers.git.clone, so FETCH_HEAD is always created if it does
not exist (because "git clone" would not create it).

Related: #1829
2020-03-14 19:15:32 +03:00
Oliver Smith c8526f2fcb
pmbootstrap status: basic checks for git repos (!1882)
Extend "pmbootstrap status" with checks for all git repositories,
derived from relevant checks in pmb.helpers.git.pull (using shared
code):
* on official branch
* workdir is clean
* tracking proper remote
* up to date

Related: #1829
2020-03-14 19:15:32 +03:00
Oliver Smith 6977f5f3e5
test.test_helpers_git.test_pull: move prep code (!1882)
Create pmb_test.git.prepare_tmpdir() with preparation code, so we can
use it in a "pmbootstrap status" related test without duplication.
2020-03-14 19:15:32 +03:00
Oliver Smith 5ae6f86a1f
pmb.helpers.git.get_branches_official(): new func (!1882)
Add dummy function that only returns ["master"] for now, so we can use it
in the upcoming git checks for "pmbootstrap status". More sophisticated
logic to figure out the branches will be added soon, see project
direction 2020 issue.

Related: #1829
2020-03-14 19:15:32 +03:00
Oliver Smith 1358424703
pmbootstrap status: print checked out git repos (!1882)
Related: #1829
2020-03-14 19:15:31 +03:00
Jami Kettunen 6877532f5d
envkernel.sh: fix sourcing since pma!1063 merge (!1892)
Change pmaports path `aports/device/device-*` to `aports/device/testing/device-*`
to match the directory structure changes after pmaports!1063 got merged.

Without this change sourcing `envkernel.sh` with up-to-date `pmbootstrap` & `aports` would fail with:

  ERROR: Please select a valid device in 'pmbootstrap init'
  See also: <https://postmarketos.org/troubleshooting>
2020-03-14 16:56:27 +01:00
Oliver Smith a659ba5695
Prepare 1.17.0 release 2020-03-14 08:56:50 +01:00
Minecrell 72fdfeb107
pmb: Fail on device ports directly in device/* (!1879)
Device ports should be under the device/testing/* directory for now.
In the future, devices may be moved to device/{main,community} after
certain preconditions are met.
2020-03-14 08:44:53 +01:00
Minecrell fb8de5a553
pmb: Look for device/* files in device/*/... instead (!1879)
In the future, device ports will be located in a subdirectory
below device/... (e.g. device/testing/device-...).
Replace all occurrences of device/* with a glob that checks the
subdirectories instead.

Note: To ensure that this always works properly we should also add some
checks that all devices are indeed located under one of the supported
subdirectories (i.e. testing/community/main).

Change the glob for pmaports to <aports>/**/APKBUILD.
This allows using subdirectories for organization outside of device/
as well.
2020-03-14 08:44:16 +01:00
Minecrell c399ff81a1
test/test_helpers_pmaports: create empty APKBUILDs for fake packages (!1879)
In general, we should not assume that pmbootstrap considers empty
package directories (without APKBUILD in them). With upcoming changes
this is no longer the case, so lets create an empty file for them.
2020-03-14 08:39:13 +01:00
Minecrell 527f5a9512
Update required Python version to 3.6+ (!1879)
We need Python 3.5+ for recursive (**) globs.
While we are at it, we might as well require Python 3.6
so we can use f-strings in the future.
2020-03-14 08:39:13 +01:00
Daniele Debernardi 5f6b8eaf0e
pmb.qemu: set output="tui" to avoid logging the stdout (!1886) 2020-03-14 08:05:57 +01:00
Daniele Debernardi 9718320829
pmb.qemu: drop --flavor option (!1886)
Since we ask for the kernel flavor during init, only the chosen kernel is
installed, hence there's no need to specify a different one.
2020-03-14 08:05:57 +01:00
Daniele Debernardi a76897b4a1
pmb.qemu: set default image size of 4G (!1886) 2020-03-14 08:05:32 +01:00
Minecrell 7bbc507416
pmb.qemu: use -cpu host for KVM, make configurable with --cpu (!1886)
For KVM the code is run pretty much natively on the host CPU, so all
CPU extensions available on the host CPU can be also used inside the VM.
To expose that information to the VM we should pass "-cpu host", so the
VM is aware of which CPU is in use.

For CPU emulation, QEMU uses a rather minimal CPU on x86_64 by default.
It does not have support for SSE3/4 etc, which may be required for some
applications to work properly (e.g. Android in Anbox). Add a --cpu flag
to make the emulated CPU configurable. Useful values are for example
--cpu max to emulate all implemented CPU features.
2020-03-14 08:05:32 +01:00
Minecrell 76dcf8aa0b
pmb.qemu: add --no-kvm to disable KVM even when available (!1886)
To test QEMU's CPU emulation it is useful to have a switch to disable
KVM, even when it is available (and potentially working fine).

Add --no-kvm for that purpose.
2020-03-14 08:05:32 +01:00
Minecrell 903491f518
test/test_qemu_running_processes: use Alpine virt kernel (!1886)
The QEMU device ports no longer make use of the linux-postmarketos-
stable/mainline kernels, causing the test to fail with

  RuntimeError: Selected kernel (stable) is not configured for device qemu-amd64.
  Please run 'pmbootstrap init' to select a valid kernel.

Let's configure the test to use the "virt" kernel.
2020-03-14 08:05:32 +01:00
Minecrell 345425ef48
test/test_qemu_running_processes: make timeout actually work (!1886)
Just counting the number of tries does not prevent the QEMU tests
from running long periods of time. In some situations, the ssh command
will keep trying to reach the destination almost indefinitely.

To make the 5 minutes timeout work correctly we need to:
  - Add an appropriate ConnectTimeout to the ssh command
  - Don't sleep for another second if ssh already took several seconds
  - Check the elapsed time instead of setting a fixed amount of tries
2020-03-14 08:05:32 +01:00
Minecrell b4678f0882
pmb.qemu: make video resolution configurable + consistent (!1886)
For some reason, the SDL display backend changes the video resolution
to 1024x768, while the GTK display keeps it at 640x480.
This is annoying, because at the moment we can only set one display
resolution for a device in postmarketOS (e.g. for the splash screen).

At the moment, the resolution for the splash screen is set to 640x480,
which therefore shows up too small with the default SDL display.

It seems like the display resolution can be only changed in the guest
directly. Linux has a video= kernel parameter that can be used to
implement this. (See: https://www.kernel.org/doc/html/latest/fb/modedb.html)

Let's set 1024x768 by default, but make it configurable through --video.
2020-03-14 08:05:32 +01:00
Minecrell f602df0140
pmb.qemu: add --tablet option for QEMU tablet input device (!1886)
The QEMU 'tablet' input device reports absolute positions instead
of relative mouse pointer movements. This can be used to automatically
grab/release the mouse pointer when entering/leaving the QEMU window,
instead of having to release it with CTRL + ALT + G manually.

This is quite convenient and should be the default option normally,
but at least on my PC the mouse pointer is reported with some vertical
offset for some reason (you can't reach the top and it extends below
the QEMU window...). Let's add it as an optional --tablet option for now.
2020-03-14 08:05:32 +01:00
Minecrell 240e10816d
pmb.qemu: use consistent hardware for all architectures (!1886)
To ensure consistent behavior for QEMU on all architectures,
it is helpful to try to use the same hardware elements where possible.

A few examples of current inconsistent behavior:
  - x86_64 uses a SCSI disk, while aarch64 uses virtio-blk
  - x86_64 uses e1000 network, while aarch64 uses virtio-net-device
  - x86_64 uses PS/2 mouse, while aarch64 uses usb-mouse
  - only x86_64 prints serial output to console

At least the virtio components are usually independent of the selected
architecture, so we can use them for both architectures.

This commit makes most of the hardware configuration shared:
  - Redirect serial output to stdio
  - virtio-blk for the disk image
  - virtio-gpu-pci (this was already implicit for both architectures)
  - virtio-net-pci for the network interface
  - virtio-mouse-pci/virtio-keyboard-pci as input devices
  - intel-hda for audio

We also set -nodefaults to avoid setting up unneeded devices
especially for x86_64.
2020-03-14 08:05:32 +01:00
Minecrell 81b3aade07
pmb.qemu: drop telnet port forwarding (!1886)
Now that we try to use the IP assigned by QEMU via DHCP,
the debug-shell is no longer working via telnet.
This is because the VM does not have any IP assigned when it is running.

We would need to start a DHCP client from the initfs to make it work.
busybox provides both udhcpc (client) and udhcpd (server) so this is
not a big problem. But the question is: Is it worth it?

The debug-shell will be only used for debugging, and NetworkManager
handles starting a proper DHCP client once the rootfs is mounted.
Meanwhile the debug-shell can be also accessed via serial output/input,
(available in the pmbootstrap stdout/stdin). So overall it does not
seem worth the effort. Let's just recommend using serial instead.
2020-03-14 08:05:32 +01:00
Minecrell 79a8d04835
pmb.qemu: do not try to change default IP range (!1886)
The current network setup has weird side effects.
Normally, QEMU would automatically make the guest set up necessary
IP routes through its integrated DHCP server.
When running QEMU through pmbootstrap they are missing.

First, we change the DHCP range in a way that could potentially
conflict with default IPs used for QEMU's own services:
QEMU has the default gateway at <network>.2, and DNS at <network>.3.
We set the DHCP range to start at <network>.1, and will therefore
potentially give out one of these addresses (QEMU's default starts at
<network>.15).
See: https://wiki.qemu.org/Documentation/Networking#User_Networking_.28SLIRP.29

In practice this does not cause immediate problems because there is
just one guest in the network, and it will get <network>.1, which is
not used by QEMU.

More problematic is that we start a DHCP server from postmarketOS
at the same time (normally used for the USB network) and there are
actually two DHCP servers running at the same time.

QEMU's user networking is local to the process, therefore it is not
possible to access the QEMU guest through its IP from the host.
That's why we have the port forwardings so you can access SSH at
localhost:2222 for example.

In practice the network interface in the QEMU guest is only used to
access the Internet. For that, we don't care which IP address we get,
we just want to get a working setup (IP + routes + DNS) automatically
through DHCP.

To make this work nicely we just need to stop trying to fit QEMU's
network setup into our usual setup for USB networking. When we remove
the custom DHCP option, and avoid starting a DHCP server from postmarketOS
(deviceinfo_disable_dhcpd) everything is suddenly working fine. :)
2020-03-14 08:05:32 +01:00
Minecrell c7455f7a21
pmb.qemu: drop vexpress (armv7) support (!1886)
device-qemu-vexpress appears to be completely broken at the moment.
I was not able to make it show anything, get a log or even just get
any indication that it is actually doing something.

In general, it does also not fit well to the other QEMU ports.
The vexpress machine type in QEMU seems to be quite limited,
e.g. it has no PCIe bus and therefore it is impossible to configure it
with virtio-gpu. (Unlike already configured for x86_64 and aarch64).

I had some success with a setup similar to aarch64 with -M virt,highmem=off
but was unable to make it work in the end:

  - Alpine's virt kernel was missing some options preventing boot completely
  - Alpine's lts kernel was missing PCI support for virtio-gpu
  - Even after adding the options the VM usually freezed after boot

Overall it does not quite seem worth the effort at the moment,
compared to how well x86_64 and aarch64 are working.

In any case, vexpress is too different (and broken) to continue maintaining it.
2020-03-14 08:05:32 +01:00
Minecrell f536fd9cb9
pmb.qemu: use current device instead of requiring --arch (!1886)
When using pmbootstrap, you usually select the device you want to work
on using 'pmbootstrap init', generate the rootfs and can then run more
commands in the context of the device.

The same needs to be done before using QEMU (to generate the rootfs).
But for some reason 'pmbootstrap qemu' requires setting the --arch
parameter when running QEMU for a foreign architecture, even when the
device is still selected in pmbootstrap.

Even more confusing is that setting "--arch arm" always selects
device-qemu-vexpress, but this is not immediately clear from the name.

Let's make this a lot more intuitive by making sure there is a QEMU
device selected when running 'pmbootstrap qemu'. We can then use the
device information to infer the architecture automatically.
2020-03-14 08:05:32 +01:00
Minecrell 32dca18eb6
pmb.qemu: simplify --display by introducing --no-gl (!1886)
At the moment, the --display argument is a bit complicated to use.
A common use would be to switch between the UIs (sdl, gtk, none)
or to enable the software rasterizer. Split the two use cases
to separate arguments to make it more intuitive.
2020-03-14 08:05:32 +01:00
Minecrell d1f5753c89
pmb.qemu: always use virtio-gpu (!1886)
So far we tried to configure virtio-gpu using "-vga virtio" only
when the target architecture matches the host architecture.
But that's actually not what it depends on.

virtio-gpu and virgl can be also used when emulating a foreign
architecture. In fact, we already force usage of virtio-gpu for
aarch64 through "-device virtio-gpu-pci".

However, the "-vga virtio" parameter does not exist on aarch64,
no matter if we run QEMU natively on aarch64 or emulate it on x86_64.

(Apparently, -vga is mainly about legacy VGA framebuffer stuff that
we don't necessarily need. This is quite visible since the display
stays uninitialized on aarch64 until the kernel driver loads,
whereas on x86_64 it is initialized by the BIOS...)

In other words, "-vga virtio" belongs to the parameters specific to x86_64.

Now that we have removed the setup question for the Mesa driver to use
(since it was ineffective), it would still be nice to have some way to
choose if you want to use virtio-gpu/virgl or not.

But actually virtio-gpu can be also used with swrast, without virgl.
This happens automatically when QEMU is started without GL support.
We already have a --display parameter for this, so it is possible to
force swrast by using "--display sdl" (instead of the default sdl,gl=on).

Overall this allows simplifying the QEMU package setup because there is
only a single GPU driver in use (virtio-gpu) instead of the 3 we had before
(virtio, qxl, bochs).
2020-03-14 08:05:32 +01:00
Minecrell 320b2faa4c
pmb.qemu: remove QEMU mesa driver setup question (!1886)
mesa-dri-swrast and mesa-dri-virtio are both provided by mesa-dri-gallium
now, so this option does not have much use anymore. With both selections,
exactly the same packages are installed.
2020-03-14 08:05:32 +01:00
Minecrell cb1f68817f
pmb.qemu: drop spice support (!1886)
The SPICE UI option tends to be broken (see #1836), and even when it is
working, it is not working particularly well. QXL requires special handling
in our QEMU packages, when now virtio-gpu (virgl) is working quite well overall.

Apparently it is possible to use virgl with SPICE; but only when using
a Unix socket instead of a TCP port. That again is a bit complicated
because we run QEMU outside the chroot and the SPICE client within.

Overall it does no longer seem to be worth the effort.
The default QEMU UI is working just fine (for the purposes of testing
postmarketOS at least).
2020-03-14 08:05:32 +01:00
Oliver Smith 7c4db04b9d
test_crossdirect: s/armhf/armv7 (!1888)
Work around old rust version in Alpine's armhf repository (builder
currently stuck?) compared to other arches. Armv7 is fine, so switch to
that and avoid this error:

error[E0514]: found crate `std` compiled by an incompatible version of rustc
2020-03-14 01:07:02 +01:00
Minecrell 0997a46b3a
pmb: replace deviceinfo_date with deviceinfo_year, add to wizard (!1888)
See: https://gitlab.com/postmarketOS/pmaports/issues/447
2020-03-14 00:33:22 +01:00
Minecrell 2159a083ef
pmb.parse.deviceinfo: deprecate dev_keyboard (!1888)
This property was never actually used. Let's remove it.
2020-03-14 00:33:22 +01:00
Minecrell 7ae04c5698
pmb.aportgen: remove touchscreen properties by default (!1888)
In most cases it is no longer necessary to set them.
directfb will now try to detect the touchscreen automatically.
2020-03-14 00:33:22 +01:00
Minecrell 7915e94275
pmb.config: remove deviceinfo_nonfree (!1888)
See: https://gitlab.com/postmarketOS/pmaports/-/issues/438
2020-03-14 00:33:22 +01:00
Oliver Smith f1cfd029d6
pmb/helpers/pmaports: fix finding subpackages (!1890)
Fix finding subpackages in pmaports, if no binary repo exists (-mp "" makes
pmbootstrap not use a binary packages mirror for pmOS packages). Discovered
with failing "test_depends_SLOW_40s" in bpo.

$ pmbootstrap -v -mp "" repo_missing --built --arch x86_64
[18:40:51] Calculate packages that need to be built (all packages, x86_64)
[18:40:56] ERROR: Package 'musl-dev-aarch64': Could not find aport, and could not find this package in any APKINDEX!
2020-03-09 18:49:59 +01:00
Luca Weiss 8edb136729
pmb.build._package: fix erroneous if condition (!1889)
This caused rust to be always installed into the native chroot even when
it wasn't required.
2020-03-08 19:22:12 +01:00
Oliver Smith a653ba9273
Prepare 1.16.0 release 2020-03-01 11:19:51 +01:00
KuroLevin b05c0e78c7
Increase the size of boot partition. (!1884)
Give enough space to do atomic replacement of boot files, as is now done
with:
ed3eeeeebb
2020-03-01 11:06:42 +01:00
Minecrell f565d6e153
pmb.aportgen.linux: cleanup makedepends (!1880)
Newer kernels require "bison" and "flex", so to easy porting we should
add them to generated APKBUILDs by default. While we are it, clean up
the default set of dependencies a bit:

  - installkernel is only needed when using "make zinstall", which
    we are not using in downstream_package (it requires special kernel
    configuration, so it's not really suitable for downstream...)

  - most kernels seem to compile fine without gmp-dev and elfutils-dev,
    so they should only be added when needed

  - the kernel has its own headers, why do we need linux-headers?
    (probably copied from Alpine, but anyway...)

  - add openssl-dev since it is needed for building/signing kernel modules

Useful reference: https://www.kernel.org/doc/html/latest/process/changes.html
Although it mentions much more than what is really needed...
2020-03-01 10:27:15 +01:00
Minecrell b0a664dc0e
pmb.aportgen.linux: build qcdt in package() (!1880)
Building the QCDT image in build() complicates use of envkernel.sh
- in that case, make is done independently of the APKBUILD, and only
the package() function is run to assemble the kernel package.

Building it entirely in package() allows using envkernel.sh without
having to set up some "post make script" (see
https://wiki.postmarketos.org/wiki/Compiling_kernels_with_envkernel.sh#Post_make_scripts).

package() might actually fit better in general, since QCDT is only
a special "package" format for (multiple) DTB files at the end :)
2020-03-01 10:27:15 +01:00
Minecrell 21b4e04c77
pmb.aportgen.linux: remove HOSTCC for latest GCC (!1880)
Setting HOSTCC is not necessary when using latest GCC
(since it defaults to "gcc"). Setting it only causes annoying
linter warnings. Let's remove it!
2020-03-01 10:27:15 +01:00
Luca Weiss ec6d40dfcc
pmb.aportgen.linux: use downstreakernel_package helper (!1880) 2020-03-01 10:27:00 +01:00
Alexey Min 383a58594d
pmb.config: provide tab completion for almost every question of "init" (!1875)
Add tab completion options for: vendor, codename, kernel, ui package,
keymap, qemu mesa driver
2020-03-01 00:44:19 +03:00
Alexey Min 7e61e62044
pmb.helpers.cli: add tab completion option for ask() helper (!1875)
Add a helper class that provides readline-based tab completion and an
extra optional argument "completion_choices" with possible completion
targets.

While at this, also improve paramters documentation for ask() func.
2020-02-26 01:20:18 +03:00
Oliver Smith 804743e65a
pmbootstrap status: print config overview (!1878)
Add an overview of the most important config options, which the user has
chosen in "pmbootstrap init".

Related: #1829
2020-02-24 18:18:54 +01:00
Oliver Smith 1724ed4665
pmbootstrap status: show if chroots are outdated (!1878)
Add new "pmbootstrap status" command, which does a quick health check
for the work dir. As first health check, verify that the chroots are not
too old. Replace the reminder text at the end of "pmbootstrap init" to
tell users to run "pmbootstrap status" instead of "pmbootstrap zap" once
a day before working with pmbootstrap.

Related: #1829
2020-02-24 18:18:53 +01:00
Oliver Smith 17673c5bf1
pmb.config.workdir: save/check chroot init date (!1878)
Whenever initializing new chroots, save the date in $WORK/workdir.cfg.
Add pmb.config.workdir.chroots_outdated() to check if it's time to zap
the chroots or not (since we don't update them automatically). Mark them
as outdated after two days.

This will be the first check in "pmbootstrap status" (future patches).
Related: #1829
2020-02-24 18:18:38 +01:00