Creation of bmap files needs to take place before any compression
happens, since bmaptool has to know where the "holes" of the image lie.
Compression removes the holes, preventing bmap from recreating the
original raw image. Move the bmap calculation step before the
compression.
Joerg Behrmann [Wed, 1 Jun 2022 17:35:39 +0000 (19:35 +0200)]
ssh: make parse_ssh_agent only handle strings
pyright complains (wrongly I think) about value being None when passed to Path
to create the socket variable. Let's work around this by eliminating Nones as
values.
Daan De Meyer [Mon, 16 May 2022 13:57:53 +0000 (15:57 +0200)]
mkosi: Always use the embedded default version when no release is specified
Let's not have the host system determine the image distribution release.
Instead, let's always default to the default release embedded within mkosi.
This gives more consistent results when building images for a single distro
regardless of the host distribution.
Daan De Meyer [Tue, 17 May 2022 09:45:08 +0000 (11:45 +0200)]
machine: Translate \r\n to \n in logfile
Output lines from pexpect sent to the logfile will always end with
"\r\n" (side-effect of working with pseudo-TTYs) . On Github Actions,
this results in blank lines in the test output. Let's add a simple
adapter that translates "\r\n" back to "\n" before actually writing
to the logfile.
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.
Joerg Behrmann [Wed, 11 May 2022 07:41:35 +0000 (09:41 +0200)]
debian: include ca-certificates for bootstrap packages
apt throws warnings because it cannot verify the certificates for the security
repositories we included recently. We could add this to extra-packages, but then
ca-certificates is missing when we call apt update for the first time, so add it
to the debootsrap call.
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.