Daan De Meyer [Sun, 12 Mar 2023 17:23:01 +0000 (18:23 +0100)]
Extend credentials support
We now also read credentials from mkosi.credentials/. If a file in
mkosi.credentials/ is executable, we run the file and use its output
as the credential.
Daan De Meyer [Sun, 12 Mar 2023 15:54:00 +0000 (16:54 +0100)]
Stop mounting package caches into images when running scripts
The package manager in the container might be a very different
version than the one running on the host which could cause all
sorts of caching issues. Since we don't need the caches in the
image anymore as we run the package managers outside of the image,
let's stop mounting the cache directory into the image when running
scripts as well.
Daan De Meyer [Wed, 15 Feb 2023 17:09:29 +0000 (18:09 +0100)]
Add --initrd option
--initrd allows users to provide their own initrds. When used, we'll
automatically create another initrd per kernel containing just the
kernel modules and all the initrds to ukify.
We don't compress the kernel modules initrd as the kernel modules
should be compressed themselves already.
Daan De Meyer [Mon, 6 Mar 2023 10:09:31 +0000 (11:09 +0100)]
Use an overlay for the build image instead of a full image
Instead of building a second image for the build image, let's just
make it an overlay for the final image since the only difference
between the two is the list of installed packages. This speeds up
image builds and allows us to simplify the internal logic as well.
Daan De Meyer [Mon, 6 Mar 2023 09:32:55 +0000 (10:32 +0100)]
Packages related refactors
- Use Sequence as the type for passing package lists around
- Add install_packages() method to DistributionInstaller
- Remove install_packages_rpm() and use invoke_dnf() directly
Daan De Meyer [Fri, 3 Mar 2023 20:10:01 +0000 (21:10 +0100)]
Add fallback paths to PATH in run_workspace_command()
Some distros don't configure the appropriate default PATH for their
shell when executed non-interactively, so let's add some fallback
entries ourselves to make sure we can always find the executables we
need.
Franck Bui [Thu, 16 Feb 2023 10:50:32 +0000 (11:50 +0100)]
opensuse: 'leap' as release name is now an alias for 'stable'
Previously using 'leap' would have installed Leap 15.1 which doesn't make sense
since this version of Leap is obsolete and no more supported. Install the latest
stable version instead.
Franck Bui [Thu, 16 Feb 2023 08:20:00 +0000 (09:20 +0100)]
opensuse: fix --with-docs which had no effect
Doc installation has to be controlled via zypp.conf. However the config file
created in the rootfs wasn't considered even with `zypper --root=xxx ...`.
To force zypper to read the version in the rootfs, we must use the environment
variable 'ZYPP_CONF='.
Franck Bui [Wed, 15 Feb 2023 14:08:14 +0000 (15:08 +0100)]
opensuse: temporarily install the local mirror in the root
Instead of relying on '--reposd-dir' option, temporarily install the repo from
the local mirror like the final repos in the rootfs. This way we can introduce
and rely on a very limited number of helpers that manipulate the repositories
inside the rootfs, which should make the code easier to follow.
Daan De Meyer [Thu, 16 Feb 2023 12:38:56 +0000 (13:38 +0100)]
Simplify workspace setup
With the move to bubblewrap we don't run into issues anymore when
the workspace is located in the source directory so let's simplify
the workspace setup.
Nils Hanke [Mon, 13 Feb 2023 17:59:55 +0000 (18:59 +0100)]
Allow RPM to return total file sizes larger than 4GB
When an RPM has a total content size over 4GB, the --qf parameter
needs to use LONGSIZE instead of SIZE to display the total package
content file size, likely to keep compatibility with code
expecting 32 bit friendly values.
Otherwise, if a package is larger than 4GB, RPM returns (none).
Since this is later given as input to Python's int(),
it will throw an exception due to (none) not being a number.
Daan De Meyer [Thu, 9 Feb 2023 11:53:32 +0000 (12:53 +0100)]
Simplify kernel image and initrd handling
- Let's stop writing files in /etc in favor of passing the
information via other ways
- Let's stop defaulting to "bls" layout which is intended
for type 1 images, we only use UKIs so we don't need the
"bls" layout
- kernel-install now defaults to the "other" layout, which
means it won't create the entry directory in /boot anymore.
We update the initrd find logic to take this into account
- Remove --machine-id as it was only really there for testing
the config parsing which we now deal with by not storing the
machine ID at all
Daan De Meyer [Fri, 10 Feb 2023 09:40:03 +0000 (10:40 +0100)]
Set timezone credential to current timezone by default
We don't configure a default timezone in the images, so let's set
a timezone credential by default to the current timezone to avoid
a prompt during first boot.
Daan De Meyer [Thu, 9 Feb 2023 21:11:53 +0000 (22:11 +0100)]
centos: Do not try to resolve symlink
We don't have chase_symlinks(), resolving the symlink actually
resolves it on the host instead of in the image. Instead, let's
just unconditionally remove the symlink.
Daan De Meyer [Thu, 9 Feb 2023 09:01:07 +0000 (10:01 +0100)]
Drop --include-directory
Let's get rid of one more source of mounts. --include-dir can be replaced
by using --incremental and reading includes from the cached build image
tree. In the future, once build images become regular images, users can
read includes by simply using --directory output and reading includes
from the regular image output tree.
Daan De Meyer [Sun, 22 Jan 2023 17:29:49 +0000 (18:29 +0100)]
Enable unprivileged image builds
To enable this, when doing a build, we unshare a user namespace
with it's own private set of uids/gids obtained using newuidmap
and newgidmap. We also map the current user to the last UID/GID
in the UID/GID range from /etc/subuid and /etc/subgid. Together
with unsharing the mount namespace, this allows us to do
unprivileged bind and overlay mounts.
Next, we replace all usages of systemd-nspawn during the image build
with bubblewrap. systemd-nspawn cannot run as an unprivileged user
yet so we use bubblewrap which can. bubblewrap can also be used to
setup a chroot environment with API VFS filesystems so we make use
of that to setup chroot environments and remove all our homegrown
logic for it. This allows us to significantly reduce the amount of
mounts we do in mkosi itself.
To further reduce the amount of mounts, we modify the invocations
of all package managers to specify the cache directory via the
relevant option instead of mounting the cache directory into the
chroot. For apt, to accomplish this, we switch from using
DPkg::Chroot-Directory to setting the "--root" option for each
invocation of dpkg so that dpkg can access files outside of the
chroot.
Finally, we remove some options which become obsolete with this
commit, --idmap, --chown and --nspawn-keep-unit.
We also remove --source-file-transfer, --source-file-transfer-final
and the corresponding symlink options. Instead, we default to mounting
source files into the build tree. In the future, we'll add virtiofsd
support to allow accessing source files in qemu VMs.
We also move stuff around and create a few new files to store
helpers to avoid circular imports. There's also a little bit of
refactoring and cleanup all around.
Daan De Meyer [Tue, 7 Feb 2023 13:45:02 +0000 (14:45 +0100)]
Run preset-all on the final image
Let's run preset-all on the finalized image so that read-only
images (e.g. initrds) have the preset settings configured in the
image itself at creation time.
Daan De Meyer [Tue, 31 Jan 2023 18:37:28 +0000 (19:37 +0100)]
Remove btrfs subvolume deletion logic
Deleting btrfs subvolumes requires root. Given that we'll be moving
to primarily unprivileged execution soon, let's drop the logic for
deleting btrfs subvolumes. They're still deleted if the corresponding
directory is removed, it's just slightly slower.