Daan De Meyer [Wed, 11 May 2022 11:54:24 +0000 (13:54 +0200)]
Install util-linux explicitly on Fedora
In Fedora 36, by default only util-linux-core is pulled in which
is missing /bin/login which is required by /sbin/agetty to function
properly. Let's pull it in explicitly until the bug is resolved.
Daan De Meyer [Thu, 5 May 2022 09:23:29 +0000 (11:23 +0200)]
Add nspawn version check to check_native()
From systemd-nspawn v250 onwards, it's possible to run build scripts
on non-native architectures (as long as binfmt.d is configured correctly)
so update the native check to consider that.
Right now mkosi.skeleton cannot be used for dpkg-based distributions, since
debootstrap will not work on a non-empty target. This adds a parameter to
install_skeleton_trees to hack around this for Debian and Ubuntu, so that the
call before install_distribution is skipped and we only add skeletons before
invoking apt again after doing the initial debootstrap.
py3.11: fix Enum formatting to work with python3.11-a7
Something strange is happening with .__repr__() access in python3.11:
>>> mkosi.backend.ManifestFormat.mro()
[<enum 'ManifestFormat'>, <class 'mkosi.backend.Parseable'>, <enum 'Enum'>, <class 'object'>]
>>> mkosi.backend.ManifestFormat.changelog.__repr__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.11/enum.py", line 1194, in __repr__
return "<%s.%s: %s>" % (self.__class__.__name__, self._name_, v_repr(self._value_))
^^^^^^^^^^^^^^^^^^^^
File "/home/zbyszek/src/mkosi/mkosi/backend.py", line 95, in __repr__
return cast(str, getattr(self, "name"))
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'name'
Enum somehow subverts normal lookup and makes its own __repr__ function be
used, even though Parseable is listed first in MRO. This seems to be related to
PEP 663, which was rejected, and the changes reverted for -a4 [1], but then the revert
was reverted [2].
Let's just sidestep MRO with a method redefinition:
>>> mkosi.backend.ManifestFormat.changelog.__repr__
<bound method ManifestFormat.__repr__ of changelog>
>>> mkosi.backend.ManifestFormat.changelog.__repr__()
'changelog'
This should work on all python versions. If python3.11 returns to previous
semantics before the final release, we can remove the workaround.
ubuntu/debian: Set up locale correctly on Debian/Ubuntu
Let's make sure we configure the locale. Also, some programs
expect /etc/default/locale to exist on Ubuntu/Debian so let's
create a symlink from there to /etc/locale.conf as well.
Let's not capture output by default. Instead, let's forward it
directly to stdout/stderr to simplify debugging. Similar to the
subprocess.run() function, let's add a capture_output argument
to allow configuring whether to capture the output.
We also remove the debug argument from Machine since logging to
stdout/stderr is now the default.
Drop --hostonly-initrd from test machine bootable images
Causes a few boot issues with rocky and alma bootable images so
let's remove the option as it the speed improvement shouldn't matter
too much for integration tests.
ci: Remove systemd.volatile from kernel command line
volatile doesn't work on many distros. We initially added it to
support booting GPT squashfs images but since we don't test those
in CI anymore, we can safely remove volatile from the kernel
commandline as well.
The 'asyncio_mode' default value will change to 'strict' in
future, please explicitly use 'asyncio_mode=strict' or
'asyncio_mode=auto' in pytest configuration file.
The difference is whether pytest considers async tests to be
asyncio-driven even when they are not marked @pytest.mark.asyncio
with 'auto' meaning yes, consider them even when not marked, and
'strict' requiring the marking.
This doesn't really make a difference for us, since we don't have
any async tests, but it's nevertheless nice to silence the warning.
Run dracut for unified kernel images instead of objcopy
objcopy is faster but it doesn't apply any changes in installed
files when running in incremental mode which is a regression. Let's
run dracut again to fix that regression.
We can if needed add an option later to use objcopy instead of dracut
if users would want that.
Rémi Palancher [Mon, 24 Jan 2022 08:59:29 +0000 (09:59 +0100)]
Add option to run nspawn in current unit
This commit adds --nspawn-keep-unit option to add --keep-unit option to
underlying systemd-nspawn commands. This makes systemd-nspawn uses the
current unit scope and allocated ressources. This can be notably useful
when mkosi is run by a system service.
Luca Boccassi [Tue, 29 Mar 2022 00:43:40 +0000 (01:43 +0100)]
Fix bootstrapping RPM distro on Debian
The Debian rpm/dnf packages store the db in the home directory, so
the bootstrapped image has a broken rpm database.
Move it to the right place if it happens.
centos: Write stream dnf variable file when a stream release is used
CentOS Stream SIGs use the $stream variable in their repo files to
identify the current CentOS Stream version. Let's make sure we write
this file so that SIG repo files can be copied into mkosi.reposdir
as is without requiring modifications to make them work.
Example SIG repo file using $stream:
https://git.centos.org/rpms/centos-release-hyperscale/blob/c8s-sig-hyperscale/f/SOURCES/CentOS-Stream-Hyperscale.repo
Daan De Meyer [Wed, 30 Mar 2022 14:00:04 +0000 (16:00 +0200)]
Add --repository-directory option
The repository directory can contain extra repositories to be
used when installing packages. If mkosi.reposdir/ exists, it's
used as the repository directory unless it's explicitly
specified.
Only supported for rpm based distros and Arch for now. We don't
support Ubuntu/Debian atm because we can't point apt to the
extra repositories directory because apt runs inside the image
compared to dnf and pacman which run outside of the image.
Daan De Meyer [Wed, 30 Mar 2022 07:58:15 +0000 (09:58 +0200)]
Reuse machine ID when re-using a cached image
4fb53aea9e04b931cccedf1545831e426d6ec2f7 broke incremental builds
for bootable Fedora images because when building the cached image,
the initrd is installed to "/efi/<machine-id>/...", and when doing
a cached build, a new machine ID is generated inside mkosi (but not
written to /etc/machine-id), making gen_kernel_images() unable to
find the initrd.
Let's fix the issue by re-using the machine ID from /etc/machine-id
when doing a cached build.
In the future, we can use the new entry-token feature of bootctl to
have kernel-install write to directory in /efi that's not tied to
the machine ID but until that's widely available this will have to
do.
Daan De Meyer [Tue, 29 Mar 2022 14:30:16 +0000 (16:30 +0200)]
centos: Rebuild the rpm db in bdb format on older centos releases
When building centos stream 8 images from Fedora, the resulting rpmdb
in the image is written in the sqlite format. The rpm version available
in centos stream 8 only supports reading the sqlite format but not writing
to it, which effectively makes installing rpm packages in the resulting
image impossible.
As a temporary workaround, we run rpm --rebuilddb inside the image to rebuild
the db in the older bdb format. Ideally we'd use the rpm from the host for this
but rpm has removed bdb support in newer versions so this isn't possible.
Luckily, we can remove this hack once we remove support for centos stream 8
and lower.
Daan De Meyer [Sat, 5 Mar 2022 15:51:21 +0000 (15:51 +0000)]
Replace dracut unified kernel image kernel-install script with objcopy
When using objcopy, we can generate the initrd in the install phase
which is cached which speeds up builds of incremental images. We use
objcopy from the host system to avoid having to install binutils in
all generated images.
We also call kernel-install manually in opensuse, debian and ubuntu
builds to make sure we can find an initrd image to pass to objcopy.
By calling kernel-install, we also make sure that
--without-unified-kernel-images now works for these distros as well.
gsegatti [Thu, 10 Mar 2022 17:38:10 +0000 (09:38 -0800)]
Merging CI tests with MkosiMachineTest class
- Removing the usage of the file at /tests/pexpect/boot.py
- Replacing the build/boot process ownership to the mkosi/machine.py file.
- All tests will attempt to build a MkosiMachineTestCase class and run the test functions.
- We leverage the load_args() function from __init__.py in order to replace the if's from the ci.yml file.
- If a set of options is invalid, we skip such test.
- We also define a specific exception for a invalid combination of arguments to be parsed, named "MkosiNotSupportedException".
- MkosiNotSupportedException inherits MkosiException.
gsegatti [Mon, 7 Mar 2022 15:29:06 +0000 (07:29 -0800)]
Adding "shell" verb to Machine class.
Summary: Adding support for running Mkosi images from within the Machine class using "shell".
- What we do here is skip booting an image whenever using such verb. Then, for running commands, we utilise run_shell_cmdline()'s to leverage systemd-nspawn.
- We also add the shell run of the current set of tests to the CI.
- We add the "--pipe" option to the cmdline utilised by run_shell_cmdline() in case future scripts use Mkosi from outside a terminal.
Daan De Meyer [Fri, 4 Mar 2022 20:57:24 +0000 (20:57 +0000)]
debian: Switch default release from unstable to testing
Unstable is a bit too bleading edge. Let's switch to testing which
is roughly 5 days behind unstable so we don't get affected by
temporary issues that make it to unstable.
Daan De Meyer [Fri, 18 Feb 2022 10:46:26 +0000 (10:46 +0000)]
Install a more specific match when --network-veth is used (#906)
* Install a more specific match when --network-veth is used
When doing more complicated network stuff in a QEMU VM, the network
file we install starts matching stuff it shouldn't match. Let's narrow
the match down by driver so we don't accidentally match against stuff
we don't want to match against.
Daan De Meyer [Mon, 14 Feb 2022 14:24:14 +0000 (14:24 +0000)]
Fix needs_build() logic
We should only check the -f option if the verb is one of the verbs
that needs a build. With the current check, we start rebuilding an
image even if the verb is "summary".
Daan De Meyer [Fri, 11 Feb 2022 12:12:58 +0000 (12:12 +0000)]
Error when trying to build an image without --bootable and run it with qemu
We can only check this when we're building the image, since when we're not
building the image it's not required to pass the --bootable option in order
to be able to use the qemu verb to run it in qemu.
This also fixes needs_build() to take the args.force option into account.
This fixes usage of needs_build() before unlink_output() is called.
Use Gentoo.EMERGE_UPDATE_OPTS for invoke_emerge call to install pkgs_boot
Using Gentoo.EMERGE_UPDATE_OPTS allows for greater maintainability than directly
specifying `--update` and `--deep`.
The configured `opts` for `invoke_emerge` enable the package manager to replace
blocking packages. This is required to successfully replace
`sys-kernel/installkernel-gentoo` (which is already installed in the gentoo
stage3 tar ball) with the requested `sys-kernel/installkernel-systemd-boot`.
Daan De Meyer [Thu, 3 Feb 2022 11:38:18 +0000 (11:38 +0000)]
ci: Add python integration tests job
To run the actual integration tests, we need to have the mkosi
action and dependencies installed. Instead of running the integration
tests as part of the unit tests job, let's add a new job for these
integration tests where we install the necessary dependencies (including
mkosi itself) and then run all tests marked with "integration" in pytest.
Add `--update` and `--deep` to invoke_emerge call for pkgs_boot
When generating bootable images for gentoo, the emerge call to install
pkgs_boot fails for `sys-kernel/installkernel-systemd-boot`:
```
[…]
‣ Invoking emerge(1) inside stage3
!!! /etc/portage/binrepos.conf is missing (or PORTAGE_BINHOST is unset), but use is requested.
* IMPORTANT: 9 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
!!! /etc/portage/binrepos.conf is missing (or PORTAGE_BINHOST is unset), but use is requested.
[binary N ] app-arch/cpio-2.12-r1-1
[binary N ] sys-firmware/edk2-ovmf-202105-r2-1
[binary N ] dev-libs/elfutils-0.186-1
[binary N ] sys-kernel/installkernel-systemd-boot-1-1
[binary N ] sys-kernel/dracut-055-r4-2
[binary N ] virtual/libelf-3-1
[binary N ] sys-kernel/gentoo-kernel-bin-5.15.19-1
[binary N ] virtual/dist-kernel-5.15.19-1
[blocks B ] sys-kernel/installkernel-gentoo ("sys-kernel/installkernel-gentoo" is soft blocking sys-kernel/installkernel-systemd-boot-1)
[blocks B ] sys-kernel/installkernel-systemd-boot ("sys-kernel/installkernel-systemd-boot" is soft blocking sys-kernel/installkernel-gentoo-3)
* Error: The above package list contains packages which cannot be
* installed at the same time on the same system.
(sys-kernel/installkernel-gentoo-3-1:0/0::gentoo, installed) pulled in by
sys-kernel/installkernel-gentoo required by (sys-kernel/gentoo-kernel-bin-5.15.19-1:5.15.19/5.15.19::gentoo, binary scheduled for merge) USE="initramfs -test"
(sys-kernel/installkernel-systemd-boot-1-1:0/0::gentoo, binary scheduled for merge) pulled inby
sys-kernel/installkernel-systemd-boot
gsegatti [Mon, 24 Jan 2022 12:25:00 +0000 (04:25 -0800)]
Removal of Gentoo check
The parse_args() method has a check for whether Gentoo's modules are currently installed.
While this allows the system to fail early, it makes unit testing dependable on installing such packages.
By removing this if() we're able to test argument parsing without on any distro with no package dependance.
Additionally, system's correctness ir preserved since this same check is done later on gentoo.py