Daan De Meyer [Thu, 10 Aug 2023 10:31:22 +0000 (12:31 +0200)]
Make sure the private tmpfs in bwrap() doesn't hide workspace
The workspace might be in /tmp so we need to make sure we mount it
first before we mount the workspace so that the workspace is on top
of the private tmpfs.
make mkosi docs from resources available via the documentation verb
This allows, especially when running different versions of mkosi, to always
have the right documentation on hand no matter how that version of mkosi was
installed.
Daan De Meyer [Tue, 8 Aug 2023 13:57:14 +0000 (15:57 +0200)]
Introduce preset dependencies
Instead of building presets in alphanumerical order, let's introduce
a proper concept of dependencies. Dependencies are configured with
the new "Dependencies=" option in the new "[Preset]" section. All
presets configured with "Dependencies=" are built before the current
preset.
We drop the alphanumerical preset in favor of explicit dependencies.
Daan De Meyer [Wed, 9 Aug 2023 06:48:29 +0000 (08:48 +0200)]
Don't reverse list option values found in the same option
Items from earlier settings should take precedence over items from
later settings, but that doesn't mean we should reverse items found
in the same setting.
Daan De Meyer [Tue, 8 Aug 2023 11:38:39 +0000 (13:38 +0200)]
Install extra packages for centos/alma/rocky to fix CI failure
This increases the size of the generated image a bit which makes
sure repart calculates a minimal partition size for the XFS
filesystem so that populating the partition doesn't run out of space.
Daan De Meyer [Tue, 8 Aug 2023 11:17:45 +0000 (13:17 +0200)]
Mark gentoo as experimental and unsupported
Gentoo issues won't be actively looked at by the core maintainers and
there's no guarantee that gentoo PRs will get reviewed or not (or they
might just be merged without review). Gentoo specific hacks outside of
gentoo.py will generally not be accepted.
- We also drop all gentoo specific modifications outside of gentoo.py
- We also stop running CI for gentoo
Conditions for dropping the experimental status of gentoo:
- No more stage 3 tarball required to build a gentoo image. Either we only
do binary packages or gentoo images can be built from directly from an immutable
host system or tools tree with portage and compiler tools installed
- Proper division of systemd components into subpackages so that we can build
a gentoo initrd with systemd installed but without pulling in ukify and python
- An official and up-to-date binary package repository that allows gentoo CI
to complete in a similar amount of time as the other distributions
Daan De Meyer [Mon, 7 Aug 2023 19:25:17 +0000 (21:25 +0200)]
Add ip=enp0s2:any to default kernel cmdline extra
When booting with --qemu-gui, the network interface is named
differently so let's account for that and configure networkd to
manage that interface as well.
Daan De Meyer [Mon, 7 Aug 2023 18:03:44 +0000 (20:03 +0200)]
Make sure options are always applied last in bwrap() and chroot_cmd()
That way, if the options remount anything read-only, we can be sure
it doesn't affect any of the operations set up in bwrap() and chroot_cmd()
themselves.
Daan De Meyer [Mon, 7 Aug 2023 15:02:43 +0000 (17:02 +0200)]
Move network argument from chroot_cmd() to bwrap()
If we're not supposed to use the network, that should apply to the
script running on the host as well, so move the network argument
from chroot_cmd() to bwrap().
We just always mount resolv.conf into the image now. If the network
namespace is unshared, there's not much that can be done with the
info in there anyway.
Daan De Meyer [Mon, 7 Aug 2023 10:53:32 +0000 (12:53 +0200)]
Don't drop privileges when running qemu and invoked as root
Depending on the environment and what options are used, running qemu
might require root privileges. So if we're invoked as root and we're
going to run qemu, let's not drop privileges.
Daan De Meyer [Sun, 6 Aug 2023 18:39:01 +0000 (20:39 +0200)]
Don't resolve paths in two cases
- Target paths should not be resolved
- When checking paths for the paths logic, let's not resolve either
and leave that to the parser implementation itself
Daan De Meyer [Sun, 6 Aug 2023 18:22:49 +0000 (20:22 +0200)]
Rework check_inputs()
Let's just check for existence with exists() instead of relying on
exceptions. Also improve error checking and make sure we check
package manager trees as well.
Daan De Meyer [Sun, 6 Aug 2023 12:25:52 +0000 (14:25 +0200)]
Always use str as the type parameter for CompletedProcess
We always set text=True when calling subprocess.run(), so we know
that the type is going to be str, so let's encode that to get
better type checking from mypy.
Daan De Meyer [Sun, 6 Aug 2023 09:59:51 +0000 (11:59 +0200)]
Move kernel modules logic to kmod.py
We also rework the logic a bit so we have one function
gen_required_kernel_modules() that is used for both trimming kernel
modules and for generating the kernel modules initrd.
Daan De Meyer [Sun, 6 Aug 2023 09:40:31 +0000 (11:40 +0200)]
Introduce archive.py
Let's gather the cpio and tar functions in archive.py. We also get
rid of the make_tar(), make_initrd() and make_directory() output
functions and make sure we also mount the root's passwd and related
files when creating cpios.
Daan De Meyer [Sun, 6 Aug 2023 08:55:25 +0000 (10:55 +0200)]
Documentation and summary improvements
- Reorder config items in the summary to put more related stuff together
- Add missing config items to the summary
- Move Ssh= option to Content as it modifies the image
- Move CacheOnly= option to Distribution
- Document Passphrase=
- Reorder documentation to match summary
Daan De Meyer [Sat, 5 Aug 2023 15:14:08 +0000 (17:14 +0200)]
Use umask to control new file/directory permissions
The primary reason to use umask is that python's mkdir() functions
and methods only apply the given mode to the final component of the
path, and not to its parent paths if parents=True is specified. Aside
from that, it's also just nicer to make sure the file/directory has
the right mode from the start instead of having to modify it later with
chmod().
We also clean up permissions in general, making sure we set umask
explicitly whenever we create a file or directory in state.root and
remove explicit permissions when we're not writing files in state.root.
Daan De Meyer [Sat, 5 Aug 2023 16:55:10 +0000 (18:55 +0200)]
Get rid of scandir_recursive() and find_files()
- Use rglob() from pathlib instead of scandir_recursive()
- Use absolute paths when dealing with kernel modules instead of
relative paths. Only make the paths relative in make_cpio()
Daan De Meyer [Sat, 5 Aug 2023 14:12:43 +0000 (16:12 +0200)]
Rework tar archive handling
- Instead of relying on shutil.unpack_archive(), let's always use tar
- Introduce archive_tree() and extract_tree() to abstract tar archives
- Make sure tar always uses the user/group information from the root dir
- Enable all features
- Make sure tar doesn't overwrite directory permissions
Daan De Meyer [Sat, 5 Aug 2023 13:49:54 +0000 (15:49 +0200)]
Remove TarStripSelinuxContext=
We now generate images with correct selinux labels. If selinux labels
are not needed, they can simply be excluded when extracting the archive,
but let's always include them when generating the archive and then users
can choose what to do with the labels when extracting.
Daan De Meyer [Fri, 4 Aug 2023 11:27:25 +0000 (13:27 +0200)]
Install boot loader after running postinst script
The boot loader package might be installed by the postinst script so let's
account for that and only do the boot loader stuff after running the
postinst script.
Daan De Meyer [Fri, 4 Aug 2023 10:26:30 +0000 (12:26 +0200)]
Add some extra environment variables for scripts
When running a command with mkosi-chroot, one often wants to refer
to paths under $SRCDIR, $OUTPUTDIR, ... inside the chroot. The issue
is that variable expansion happens before mkosi-chroot is called and
has a chance to modify them to point to the locations inside the chroot.
To allow easily referring to the locations inside the chroot, let's
add variants of the directory environment variables prefixed with
"CHROOT_" containing the location of the paths inside the chroot.