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.