Thore Bödecker [Fri, 21 Aug 2020 09:46:20 +0000 (11:46 +0200)]
run postinstall nspawn with loopdev if bootable
This enables nspawn blockdev access for the postinstall script when a
bootable image is being created.
(Needed in order to e.g. make changes to bootloader from within the
postinstall script.)
Also this commit deduplicates the code required for setting up these
nspawn parameters and moves it into a separate method, that is being
called from multiple places.
Thore Bödecker [Fri, 21 Aug 2020 09:34:38 +0000 (11:34 +0200)]
fix bootable CentOS 7 efi by using grub2-efi
First of all the `systemd-udev` package does not exist in the CentOS 7
repository and thus will cause the `dnf` step to always fail.
The `bootctl` / `systemd-boot` feature in CentOS 7 is very broken and
does not work.
To create bootable CentOS 7 EFI images, this commit switches to
`grub2-efi`.
Furthermore it will fail early if unified kernel images were not
explicitly disabled via the commandline switch. They are simply not
supported by grub.
There are some quirks when an EFI image is being built on a non-EFI
system, since grub2 will check for existence of `/sys/firmware/efi` and
only create an efi-compatible boot config if that directory exists.
Otherwise it will generate 16bit `linux16` and `initrd16` boot
entries, which are obviously incorrect. This is subsequently fixed
by patching the generated file.
Also the `grub2-efi` setup requires a more ellaborate nspawn setup,
just like `clr-boot-manager`
Thore Bödecker [Fri, 21 Aug 2020 09:24:04 +0000 (11:24 +0200)]
extend mkfs to support adding cmdline args
The `mkfs_<filesystem>()` methods have been renamed to
`mkfs_<filesystem>_cmd()` and just return the cmdline now.
This allows for some easier adjustments within `mkfs_generic()`.
The e2fsprogs packaged within CentOS 7 is very old and does not support
the `metadata_csum` ext4 feature.
This commit explicitly disables this feature upon filesystem creation.
Otherwise all e2fsprogs utilities will not work or misbehave within the
created image. (e.g. `tune2fs -l`)
Additionally this commit explicitly enabled the `64bit` feature for ext4
on supported architectures. Previously this might or might not have been
enabled by default, depending on the e2fsprogs version where mkosi is
running.
Thore Bödecker [Fri, 21 Aug 2020 09:18:29 +0000 (11:18 +0200)]
allow optional override of GPT first-lba header
Usage of this feature is totally optional and the defaults are actually
preferred, which should set the First (usable) Logical Byte Address to
sector 2048, leaving a 1MiB gap before the first partition.
However there might be a reason to override this, e.g. if the created
image is being altered later on by tools which need a different
first-lba value. One example would be the `prl_disk_tool` utility from
the Parallels virtualization suite.
Daan De Meyer [Thu, 20 Aug 2020 20:37:03 +0000 (21:37 +0100)]
Give prepare scripts access to SRCDIR.
There are often project specific files that contain the dependencies
necessary to be installed. Make sure the prepare script has access to
these files so the logic doesn't have to be repeated in the prepare
script itself.
Daan De Meyer [Mon, 17 Aug 2020 17:34:35 +0000 (18:34 +0100)]
CI: Add QEMU boot tests
Adding these gives us a clear idea of which setups should work and which
are broken. This helps with triaging issues since we can immediately see
if a setup is supposed to work or not. It also makes sure setups that do
work keep working in the future.
Currently, only Arch, CentOS and Fedora can boot on all included setups
(nspawn, UEFI + systemd-boot with unified kernel images, UEFI +
systemd-boot and BIOS). Debian, Ubuntu, OpenSUSE and Mageia fail
on UEFI without unified kernel images because their package managers
don't install any boot loader entries that systemd-boot can read.
Photon doesn't work on any of the setups. Clear also has a lot of issues
due to it using its own bootloader and OpenMandriva has QEMU failures.
For now, we disable all these but we hope support by them can be added
by interested contributors in the future.
Daan De Meyer [Sat, 22 Aug 2020 10:04:08 +0000 (11:04 +0100)]
Fix grub installation
If we don't mount /dev/block and /dev/disk into the container, grub will
add root=/dev/loop... to the kernel command line which breaks when
booting the image. If we mount these directories, grub will correctly
use the PARTUUID or UUID instead.
Daan De Meyer [Wed, 19 Aug 2020 20:13:28 +0000 (21:13 +0100)]
Arch: Handle no kernels installed case in kernel-install hook
If a bash glob doesn't match any files, it returns the glob itself which
trips up the current logic. Explicitly check if the file exists to avoid
this.
Daan De Meyer [Sat, 15 Aug 2020 09:35:08 +0000 (10:35 +0100)]
Arch: Make pacman hooks more generic
It's generally good to not depend on specific packages in pacman hooks
since it doesn't take new packages into account. To get around, this we
can simply depend on the /usr/lib/kernel/install.d directory so any
package that installs a file into this directory can plug into the
pacman hook.
One annoyance we can't solve without package specific information in the
pacman hook is packages that themself support hook directories that
other packages can install to. This would require a mechanism in pacman
where packages can contribute triggers to hooks installed by other
packages.
Daan De Meyer [Thu, 13 Aug 2020 19:57:23 +0000 (20:57 +0100)]
Interpret CLI args as nspawn args when verb == "boot"
Normal command line args are ignored by nspawn when --boot is used.
Instead of doing nothing with them, let's allow users to pass nspawn
args via the command line directly when boot is used.
Daan De Meyer [Sat, 8 Aug 2020 19:33:14 +0000 (20:33 +0100)]
Add setup-mkosi Github Action
We want to make it easy to set up mkosi based CI for other Linux
userspace projects on Github. By extracting all the tedious building of
dependencies out into a Github Actions, other projects can start using
mkosi for CI by simply adding 'uses: actions/setup-mkosi' to their
Github Actions workflow.
because the entrypoint console_script does not work properly when called with
sudo when not installed in a virtual environment, since the python binary is
unable to find the mkosi module in its search path.
According to the man page, --source-file-transfer "defaults to
copy-git-cached if a git source tree is detected, otherwise copy-all".
However the existing code only sets it to copy-git-cached if a .git
folder exists and leaves it at None otherwise, meaning a non-Git source
is never transferred.
We build tdnf along with the centos dependencies as it needs libsolv as
well and splitting everything up in separate steps is relatively more
complexity for a little extra run time.
We should look into caching the dependency building so we don't rebuild
the same dependencies each build.