The udev daemon and rules are split off from the main systemd package
because they aren't necessary in containers. When we're doing bootable
images, we definitely want systemd-udev to be installed.
Remove mkosi.default from repo and add it to .gitignore
Causes more issues that it solves. Currently, one always has to be
careful to specify --default /dev/null when running in the mkosi project
directory to avoid options from the mkosi.default file taking effect.
The mkosi.default file also only works on distros with dnf. Removing it
and putting it into the .gitignore also makes it easier for developers
to put their own symlink to their distro of choice in place.
Delay KeyboardInterrupt() handling when running a subprocess
Because we weren't giving subprocess time to gracefully exit, we'd
often get "Device or resource is busy" errors when CTRL+C'ing mkosi
as we we'd try to unmount directories while a subprocess was still
running in it. By delaying handling of SIGINT while a subprocess is
running, the subprocess can exit gracefully which prevents EBUSY errors
from occurring when running cleanup code. To allow interrupting hanging
subprocesses, we only delay the first SIGINT we receive. If a user
presses CTRL+C again, we exit immediately as before.
- Use single exception: MkosiException
- Throw MkosiException from die
- Print error immediately in die instead of in main exception handler.
This makes sure the error message is written to the terminal before
all the cleanup messages from the context managers.
- Convert some existing exceptions to MkosiException so they don't print
a stacktrace.
Drops the user into a shell if the build script fails with a non-zero
exit code. We still fail the build afterwards so the user can
immediately start again after he fixes his build script.
This option streamlines launching headless qemu virtual machines from
the command line via mkosi's qemu verb. When this option is specified,
mkosi configures the image for headless connections and adds the
-nographic option when launching the vm via mkosi's qemu verb. Instead
of launching a separate window, qemu connects the host's terminal to the
vm via the serial console. This allows working with the vm from the
comfort of your own terminal instead of the linux console which is used
when qemu starts the vm in a separate window.
We make sure all terminal features still work by overriding the TERM
value for serial-getty@ttyS0 in the vm with the TERM value from the
host's terminal emulator which we get from the TERM environment variable
that mkosi is started with.
Joerg Behrmann [Tue, 29 Oct 2019 10:20:00 +0000 (11:20 +0100)]
mkosi: make mkosi mypy --strict compliant
This commit makes mkosi compliant against running mypy in strict mode (with mypy
0.750).
- All missing type declarations are added,
- generic types are made explicit,
- __class__ usage is made explicit, and
- no longer necessary casts are removed.
mkosi: add explicit check for loopdev being not None to placate mypy
mypy throws an error on checking the mount_image function
> mkosi:969: error: Argument 1 to "partition" has incompatible type "Optional[str]"; expected "str"
> mkosi:972: error: Argument 1 to "partition" has incompatible type "Optional[str]"; expected "str"
because as of yet it cannot deduce, that loopdev will only be non-None if
args.esp_partno or args.xbootldr_partno are non-None as well, since they will
only be non-None on bootable images, which necessarily will be disk images, and
loopdev will only be None on non-disk images, i.e.
disk image -> loopdev is not None and args.esp_partno maybe None
non-disk image -> loopdev is None and args.esp_partno is None
Márton Morvai [Thu, 11 Jun 2020 14:42:54 +0000 (16:42 +0200)]
Call finalize script as described in documentation
Finalize script is now called as last step before build script in first
stage and as last step before image is made read-only/generated image is
made in second stage.
Finalize script is not called when creating cached images.
Daan De Meyer [Tue, 30 Jun 2020 20:13:56 +0000 (22:13 +0200)]
Stop ignoring umount errors
This was hiding a rather nasty bug in pacstrap/unshare. Silencing
the umount errors complicated finding the actual error so let's not
ignore unmounting errors.
Daan De Meyer [Tue, 30 Jun 2020 09:44:36 +0000 (11:44 +0200)]
Pass root around instead of workspace
Most of the functions operate on the image root instead of the
workspace so it makes sense to pass the root directory instead of
the workspace. Access to the workspace directory is done via the
workspace function that simply returns the parent directory of the
root directory.
This commit only refactors code and does not change behavior.
Ivan Shapovalov [Tue, 23 Jun 2020 16:11:27 +0000 (19:11 +0300)]
mkosi: fix `-t submodule` output
By the time we get to creating the root submodule, the directory already exists
because we self-bind-mount it in mount_image(), and it is too late to convert it
because of the same.
Thus, move the root subvolume creation into its own step just prior to
mount_image().
Michal Koutný [Fri, 15 May 2020 17:22:00 +0000 (19:22 +0200)]
Install openSUSE packages in one go
Minimal pattern may install packages that are conflicting with packages
installed in the second stage and that requires manual resolution (e.g.
replace busybox-coreutils with coreutils).
As there is no need to do installation in two steps, install all
packages in one zypper call, making it resolve potential conflicts
itself.
Michal Koutný [Wed, 13 May 2020 14:15:41 +0000 (16:15 +0200)]
Always fill machine_id in built image
The build script may run commands relying on machine_id and since we
don't run build script with full-fledged PID 1, uuid passed from
systemd-nspawn won't be effective. Hence for the build stage use
machine_id even for non-bootable images (as per note in build_stuff,
it's not the first such use).
Michal Koutný [Wed, 6 May 2020 13:19:12 +0000 (15:19 +0200)]
Fix --skip-final-phase builds referencing None
If we skip the second stage, we shoud work with results of the first
stage, not nothing, otherwise we fail:
> ‣ Skipping (second) final image build phase.
> Traceback (most recent call last):
> File "/projects/mkosi/mkosi", line 4895, in <module>
> main()
> File "/projects/mkosi/mkosi", line 4891, in main
> run_verb(a)
> File "/projects/mkosi/mkosi", line 4866, in run_verb
> build_stuff(args)
> File "/projects/mkosi/mkosi", line 4691, in build_stuff
> raw = qcow2_output(args, raw)
> File "/projects/mkosi/mkosi", line 2981, in qcow2_output
> assert raw is not None
> AssertionError
Daan De Meyer [Tue, 19 May 2020 17:26:15 +0000 (19:26 +0200)]
Arch: Avoid synchronizing repositories in second pacman invocation
pacstrap synchronizes package repositories by default which we've
already done in the first call to pacstrap. By calling pacman
directly, we avoid the unnecessary second sync.