Commit Graph

1730 Commits

Author SHA1 Message Date
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
Oliver Smith f21c216a26
Cosmetic: use SPDX license header (!1877)
While at it, also remove unnecessary "#!/usr/bin/env python3" in files
that only get imported, and adjust other empty/comment lines in the
beginnings of the files for consistency.

This makes files easier to read, and makes the pmbootstrap codebase more
consistent with the build.postmarketos.org codebase.
2020-02-24 03:11:10 +03:00
Oliver Smith e605a0af32
test/pmb_test: prepare for common test code (!1876)
Replace the "Add topdir to import path" boilerplate lines in each test
file with a simple "import pmb_test". Use the "# noqa" comment if
"pmb_test" is not used further in the test file, so flake8 does not
complain about an unused module.

Make the path to the testdata available as pmb_test.const.testdata, and
use pmb.config.pmb_src to access the topdir in all tests.

This is in preparation for new "pmbootstrap status" related tests, which
will have shared test code in test/pmb_test/. Also, this makes the
pmbootstrap codebase more consistent with the bpo codebase, which has a
similar "import bpo_test" mechanism.
2020-02-24 03:01:04 +03:00
Oliver Smith 4a08b5e066
Prepare 1.15.0 release 2020-02-23 03:40:30 +01:00
Luca Weiss b7e47367e5
aportgen: suggest 'pmbootstrap pull' in error message (!1874) 2020-02-21 16:26:08 +01:00
Minecrell 0e27713512
pmb.parse._apkbuild: Extend APKBUILD parser to work for subpackages (!1866)
At the moment we have a simple subpkgdesc() function that can only
parse "pkgdesc" from subpackages, without support for any variables.
But we have a quite nice variable parser now that can be extended
to work for subpackages.

Simply put this works by:
  - Finding the lines that belong to the subpackage function
  - Stripping indentation (tab)
  - Parsing relevant attributes similar to the apkbuild() function

The "subpackages" in the parsed APKBUILD are replaced by a dict
of subpkgname: {"pkgdesc": "...", "depends": "..."} which are
parsed from the subpackage function (if found).
This makes it possible to get the "depends" of a subpackage.
2020-02-19 14:56:57 +03:00
Minecrell 0dad22a112
pmb.parse._apkbuild: Set "array": False by default (!1866)
This avoids having to set all unused options to False.
2020-02-19 14:56:52 +03:00
Minecrell 5f5050f9a3
pmb.parse._apkbuild: Replace variables immediately after parsing (!1866)
At the moment we parse all attributes, split them, and eventually
join them back together for variable replacement.

Replacing variables immediately after parsing (before splitting)
has several advantages:

  - No need to handle different value types
    (e.g. lists by joining them every time they are accessed)

  - Variables like depends="$depends ..." are handled directly
    by the variable parser

  - APKBUILDs are shell scripts, so we match abuild more closely
    if variables defined later do not affect previous attributes
2020-02-19 14:56:46 +03:00
Minecrell 3aabaf451c
pmb.parse._apkbuild: Set default attribute values before starting to parse (!866)
Theoretically it is possible to reference variables before they are defined.
In the shell, these will simply be evaluated to an empty string.
In preparation of replacing variables immediately after parsing attributes,
these variables will be no longer replaced correctly.

We can simplify the code further, and avoid this problem by initializing
the dict with the default values, replacing them with the real values
from the APKBUILD.

This will also avoid a (somewhat unrelated) error in the bootimg test:

  File "pmb/parse/_apkbuild.py", line 46, in replace_variable
    apkbuild["pkgname"], match.group(0),
  KeyError: 'pkgname'
2020-02-19 14:56:35 +03:00
Luca Weiss 33e3553cdd
aportupgrade command for upgrading APKBUILDs (!1752)
The gist of this action is upgrading the specified aport to the latest
version. There are implementations for both stable packages (which check
via the release-monitoring.org API for new versions) and git packages
(which check the GitLab/GitHub API for new commits on the main branch).

There's also the possibility to pass --all, --all-stable & --all-git to
the action which either loops through all packages, or just stable or
git packages and upgrades them.

The --dry argument is also respected.

Note, that the implementation does update the variables pkgver, pkgrel
and _commit but it doesn't update the checksums because that would slow
down the process a lot, and is potentially undesirable.
2020-02-15 20:24:09 +01:00
Luca Weiss dd72fd44db
pmb.helpers.http: add retrieve & retrieve_json helpers (!1752)
Fetch the content of a URL and returns it as string.
2020-02-15 20:24:09 +01:00
Luca Weiss ddb8ff435c
pmb.helpers.file: add replace_apkbuild helper (!1752)
Replace one key=value line in an APKBUILD and verify it afterwards.
2020-02-15 20:24:04 +01:00
Minecrell 87dd071b32
add "fastboot-bootpart" flasher to flash split images with fastboot (!1871)
asus-me176c has a Fastboot interface that can be used for flashing,
but in postmarketOS we do not use Android boot images for it.
This is because is it not very practical - the boot partition is
quite small and there is a (custom) EFI bootloader that can boot
directly from any other FAT32 partition.

At the moment the installation process is manual:
  1. pmbootstrap install --split to have separated boot (FAT32)
     and rootfs images
  2. pmbootstrap export
  3. Flash boot and rootfs images manually using Fastboot

The "fastboot-bootpart" flasher implements that process in a more
convenient way. When a device uses the "fastboot-bootpart" flasher:

  - We generate --split images on "pmbootstrap install" by default.
    (This can be disabled using --no-split instead.)

  - pmbootstrap flasher flash_kernel flashes the raw boot partition
    (not an Android boot image) using Fastboot, just like the rootfs.

There are some limitations that could be improved in the future:

  - "fastboot-bootpart" is not offered in the device wizard.
    I think it is special enough that no-one will be starting with it,
    and the difference to normal "fastboot" might be confusing.

  - Support "pmbootstrap flasher boot". asus-me176c does not support
    "fastboot boot" properly, but theoretically we could still generate
    Android boot images to use when booting an image directly.

  - At the moment the boot partition image is not regenerated when
    using "pmbootstrap flasher flash_kernel" (unlike when using Android
    boot images). "pmbootstrap install" needs to be run manually first.
2020-02-10 00:05:00 +03:00
Minecrell ba1e39f48e
pmb.config: Fix formatting for flash methods (!1871)
For some reason, the formatting for the flash method definitions
is really messed up. Let's fix it!
2020-02-10 00:04:59 +03:00
Clayton Craft fbdc68c3b6
ci: Update docker image to python 3.7, use generic python3
The python3 version in docker image may not be the same in the qemu
test runner VM image, so a more generic 'python3' is used when creating
the venv.
2020-02-08 16:07:31 -08:00
Minecrell 6540c25a9b
envkernel.sh: add dependencies for x86_64 (!1870)
x86_64 kernels require some additional dependencies to build properly.

At this point, the list is getting quite long. Ideally we should only
install the build dependencies that are necessary for a particular
kernel package. Add a FIXME to document this for the future.
2020-02-07 19:20:40 +03:00
Minecrell 569c8ff5b0
envkernel.sh: fix x86_64 (arch == host_arch) (!1870)
Attempting to use envkernel.sh on x86_64 fails at the moment:

$ . ~/pmos/pmbootstrap/helpers/envkernel.sh
Initializing Alpine chroot (details: 'pmbootstrap log')
ERROR: unsatisfiable constraints:
  binutils-x86_64 (missing):
    required by: world[binutils-x86_64]
  gcc-x86_64 (missing):
    required by: world[gcc-x86_64]

We do not need to install a cross compiler if the device arch is
equal to the host architecture. Check if we need a cross compiler
earlier, and avoid installing it if not necessary.

Also rename "is_cc" to "need_cross_compiler". "is_cc" is confusingly
named since "cc" can refer to the compiler symlink ("C compiler")
or "cross compiler".
2020-02-07 19:20:01 +03:00
Oliver Smith fbbcc1c26f
pmb.parse.arguments: common func for packages arg (!1872)
Create add_packages_add() function, so we don't need to write the three
lines for adding the "packages" argument to an action with proper
autocompletion.
2020-02-06 16:29:31 +03:00
Danct12 a021d1924c
pmb.helpers.lint: add simple linting (!1855)
Run linting, just like in pmaports.git CI checks. Start with
apkbuild-lint, eventually this should run all checks.

Related: #1869
2020-02-06 13:45:21 +01:00
Oliver Smith 2f01c91c1a
pmbootstrap -s: remove option (!1868)
Remove in favor of similar, but more visible "--no-install" option for
"pmbootstrap flasher" and "pmbootstrap export".

It seems that the option wasn't really used by anybody, so let's just
remove it without a deprication period. If dear reader thinks otherwise
after this is merged, and is not happy with "--no-install", please state
your reasoning in a new issue, so we can discuss it.

Related: !1863
2020-02-06 12:33:21 +01:00
Minecrell 630310ebfb
pmb.aportgen.linux: Fix linting issues in generated APKBUILDs (!1869)
Avoid generating an APKBUILD with the following linting issues:
  - unnecesary usage of braces: ${_flavor}
  - unnecesary usage of braces: ${arch}
  - unnecesary usage of braces: ${_commit}
  - unnecesary usage of braces: ${_repository}
2020-02-02 06:49:12 +03:00
Minecrell d3fede3262
pmb.qemu.run.install_depends: Fix Mesa Gallium DRI depends (!1867)
Commit 43520967 ("pmb.qemu.run.install_depends: adjust to mesa pkgs (!1865)")
replaced mesa-dri-swrast, mesa-dri-virtio and mesa-dri-vmwgfx with
mesa-va-gallium. But the Gallium DRI drivers are actually provided by
mesa-dri-gallium. mesa-va-gallium contains libva drivers for hardware
video acceleration.

Fortunately this did not break anything because mesa-dri-gallium
was still installed as dependency of mesa-dri-ati/intel/nouveau.

QEMU does not make use of libva, so lets just replace mesa-va-gallium
with mesa-dri-gallium. While we are at it, stop depending on the
deprecated mesa-dri-ati/intel/nouveau packages. Those are only kept
for compatibility reasons and install more dependencies than necessary.
2020-01-31 04:10:50 +01:00
Minecrell 60217d0818
pmb.flasher/export: Add --no-install option to skip kernel/initfs update (!1863)
At the moment, pmbootstrap updates the kernel and the initfs whenever
using the flasher or export. This is useful, but sometimes you just want
to boot exactly the same kernel several times. In that case, having to wait
several seconds for the (redundant) update to complete is quite annoying.

Add a --no-install option that allows skipping the kernel/initfs update.
2020-01-31 01:35:26 +01:00