]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
4 years agomkosi: extend --environment to cover all scripts 765/head
Zbigniew Jędrzejewski-Szmek [Sat, 7 Aug 2021 12:17:38 +0000 (14:17 +0200)] 
mkosi: extend --environment to cover all scripts

I would like to set environment variables for other scripts. But I
don't think adding separate options make sense: it should be fine to
just set the same environment variable for all scripts that are
invoked… After all, variables are best for "global" settings. Scripts
already get positional arguments that allow them to distinguish build
phases, so they don't need to use variables for this.

4 years agomkosi: rename --build-environment to --environment/-E
Zbigniew Jędrzejewski-Szmek [Sat, 7 Aug 2021 11:05:39 +0000 (13:05 +0200)] 
mkosi: rename --build-environment to --environment/-E

This just renames the option, but doesn't change the semantics yet.
The old name is kept for compatibility, but not advertised.

4 years agomkosi: pull in envvar value from the environment if no value specified
Zbigniew Jędrzejewski-Szmek [Sat, 7 Aug 2021 07:14:27 +0000 (09:14 +0200)] 
mkosi: pull in envvar value from the environment if no value specified

This makes --build-env=FOO behave like --build-env=FOO=$FOO. This is a
common case, and it makes some invocations more convenient. In
particular, we avoid exposing the variable on the commandline.

4 years agoman: rebuild the man page
Zbigniew Jędrzejewski-Szmek [Sat, 7 Aug 2021 10:52:09 +0000 (12:52 +0200)] 
man: rebuild the man page

4 years agobackend: try to use shlex.join 764/head
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 15:48:37 +0000 (17:48 +0200)] 
backend: try to use shlex.join

It was added in 3.8, and unfortunately we still support python3.7.
Also remove the last backtick use in output.

4 years agomkosi: remove other uses of backticks in comments and output
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 15:38:53 +0000 (17:38 +0200)] 
mkosi: remove other uses of backticks in comments and output

4 years agomkosi: also pass the named tuple to mount_image()
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 10:13:56 +0000 (12:13 +0200)] 
mkosi: also pass the named tuple to mount_image()

This will hopefully make things easier if we add even more partition
types in the future…

4 years agomkosi: define NamedTuple to hold luks_setup_all() output
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 16:16:32 +0000 (18:16 +0200)] 
mkosi: define NamedTuple to hold luks_setup_all() output

I'm using a NamedTuple here, instead of a dataclass, because the
dataclass does not support indexing and iteration. It certainly would
be possible to define those, but with typing it becomes quite a lot of
code (and typing of __iter__() that supports both indexing and slicing
is tricky and verbose).

BuildOutput has no inherent ordering — it's a bunch of completely
different objects. But here we have a list of partitions, so it's
reasonable to use a tuple for this.

4 years agomkosi: rework link_output_*() to handle None internally
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 14:55:52 +0000 (16:55 +0200)] 
mkosi: rework link_output_*() to handle None internally

This makes build_stuff() more legible.

4 years agomkosi: use dataclass to hold build_image() output
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 14:34:55 +0000 (16:34 +0200)] 
mkosi: use dataclass to hold build_image() output

Passing around all the arguments was getting unwieldy…

4 years agomkosi: use complete_step() in one more place
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 13:01:21 +0000 (15:01 +0200)] 
mkosi: use complete_step() in one more place

4 years agomkosi: prettify format string
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 12:58:19 +0000 (14:58 +0200)] 
mkosi: prettify format string

It's better to avoid backticks because they are special for the shell
and make select-and-paste operations harder.

4 years agomkosi: create cache copy also for non-raw output formats
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 10:39:40 +0000 (12:39 +0200)] 
mkosi: create cache copy also for non-raw output formats

I don't quite grok the logic to skip the creation of the cache copy.
I'm using Format=directory, and I expected the cache copy to be there.
Since we can't overwrite one directory with another, unlink the output
when copying. (For raw output, which is a file, we don't need to unlink
because we can replace the file atomically.)
With this change, it is created and everything seems to work fine.

The assert is needed to placate mypy.

4 years agomkosi: do not suppress non-Exception exceptions when checking urls
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 10:46:07 +0000 (12:46 +0200)] 
mkosi: do not suppress non-Exception exceptions when checking urls

Same story… Let's rename the function while at it.

4 years agomkosi: do not suppress non-Exception exceptions in unlink_try_hard()
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 12:32:09 +0000 (14:32 +0200)] 
mkosi: do not suppress non-Exception exceptions in unlink_try_hard()

In 01eac0078a06334ed938b68a09db8799b490dfe0 annotations to suppress
warnings about this were added, sadly without any explanation, so we
can only guess what the author had in mind. But it doesn't seem
appropriate… If I press ^C while removing some files, it seems quite
wrong to continue execution. Also, if those operations fail on
permission errors, we also don't want to continue.

("except:" catches BaseException, which includes KeyboardInterrupt and
other things which should only be caught in very special
circumstances, like interactive shells.)

4 years agomkosi: use f-string in some more places
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 10:40:26 +0000 (12:40 +0200)] 
mkosi: use f-string in some more places

I think it's easier to read the code when the argument is "inline".

4 years agomkosi: include the ellipsis+dot in complete_step() in the format string
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:58:49 +0000 (11:58 +0200)] 
mkosi: include the ellipsis+dot in complete_step() in the format string

complete_step() already added an ellipsis and dot on its own (to the
opening message and to the cloing message, respectively), but in some
places we had "..." or "." in the format string anyway, so we eneded
up with six dots or four dots in output. But instead of fixing those
places, I think it's better to go in the opposite direction, and include
the terminator in the format string.

This is nicer because:
- It's just easier to see the complete format string including the
  terminator. The "saving" of a few characters by including it
  automatically isn't very important.
- If the line ends in a path, we should skip the terminator to make
  the path easier to select-and-paste. This is now trivial: just skip
  the terminator in the format string.
- If the step is "immediate" and we expect it to finish quickly and
  without any further output (like calling os.unlink() or such), we
  can skip the ellipsis.

While at it, let's change "..." to "…", it looks nicer and saves some
screen real estate.

4 years agobackend: indent printed steps by one space when recursing
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 10:36:30 +0000 (12:36 +0200)] 
backend: indent printed steps by one space when recursing

At least for me this makes the output a lot more easier to grok:
I know what is a substep of what:

‣ Detaching namespace...
‣ Setting up temporary workspace
‣ Temporary workspace in /home/zbyszek/src/mkosi-initrd/mkosi.output/.mkosi-bmqulbgi is now set up.
‣ Running second (final) stage to generate cached copy...
‣  Mounting image...
‣  Setting up basic OS tree...
‣  Mounting Package Cache...
‣  Installing Fedora...
‣   Mounting API VFS...
...
‣   Unmounting API VFS...
‣  Unmounting Package Cache...
‣  Removing random seed...
‣  Unmounting image...
‣  Installing cache copy ...
‣  Successfully installed cache copy /home/zbyszek/src/mkosi-initrd/mkosi.output/mkosi-5.13.4-200.fc34.x86_64.d.cache-pre-inst.
‣ Running second (final) stage...
...

4 years agobackend: move complete_step into the backend code
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 10:15:02 +0000 (12:15 +0200)] 
backend: move complete_step into the backend code

While at it, also make it a classmethod under MkosiPrinter…
It belongs there conceptually.

4 years agomkosi: say we are copying the cached tree only when it exists
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:59:31 +0000 (11:59 +0200)] 
mkosi: say we are copying the cached tree only when it exists

I was confused by the message that something is being copied in, when
there was nothing to copy.

4 years agomkosi: fix misleading comment
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:30:26 +0000 (11:30 +0200)] 
mkosi: fix misleading comment

4 years agomkosi: do not fail in incremental mode on second attempt to nuke locales
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:29:11 +0000 (11:29 +0200)] 
mkosi: do not fail in incremental mode on second attempt to nuke locales

We'd fail with FileNotFoundError on the second attempt :(

4 years agomkosi: do not fail in incremental mode on …/etc already existing
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:24:02 +0000 (11:24 +0200)] 
mkosi: do not fail in incremental mode on …/etc already existing

$ sudo mkosi --force -i --format=directory -o mkosi-5.13.4-200.fc34.x86_64.d/
...
‣ Unmounting API VFS...
‣ Unmounting Package Cache...
‣ Removing random seed...
‣ Unmounting image...
‣ Running second (final) stage...
‣ Mounting image...
‣ Setting up basic OS tree...
‣ (Unmounting image...)
Traceback (most recent call last):
...
FileExistsError: [Errno 17] File exists: '/home/zbyszek/src/mkosi-initrd/.mkosi-3legjys3/root/etc'

4 years agomkosi: de-emphasize completion of steps after an exception has occured
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 08:48:16 +0000 (10:48 +0200)] 
mkosi: de-emphasize completion of steps after an exception has occured

I had the following failure:
...
‣ Unmounting API VFS...
‣ Unmounting Package Cache...
‣ Removing random seed...
‣ Unmounting image...
‣ Running second (final) stage...
‣ Mounting image...
‣ Setting up basic OS tree...
‣ Unmounting image...
Traceback (most recent call last):
...
FileExistsError: [Errno 17] File exists: '/home/zbyszek/src/mkosi-initrd/.mkosi-5jv7jtu2/root/etc'

The error is generated in the block "Setting up basic OS tree...", but
the exception traceback is not printed immediately, so it seems like
it was generated in the "Unmounting image..." block. There could be
multiple lines of such cleanup, and it's hard to tell where the error
occurred without knowledge of mkosi internals. Let's de-bold and
parenthesize the steps that happen when we are in exception handling
blocks, so the reader can discern this more easily.

‣ Unmounting API VFS...
‣ Unmounting Package Cache...
‣ Removing random seed...
‣ Unmounting image...
‣ Running second (final) stage...
‣ Mounting image...
‣ Setting up basic OS tree...
‣ (Unmounting image...)
Traceback (most recent call last):
...
FileExistsError: [Errno 17] File exists: '/home/zbyszek/src/mkosi-initrd/.mkosi-3legjys3/root/etc'

4 years agomkosi: fix error message about existing output path
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 08:34:15 +0000 (10:34 +0200)] 
mkosi: fix error message about existing output path

With --format=directory, this is not a file…

4 years agoMerge pull request #763 from keszybz/man-feformatting
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 15:06:56 +0000 (17:06 +0200)] 
Merge pull request #763 from keszybz/man-feformatting

Man page formatting and grammar improvements + "Fedora Linux"

4 years agofedora: say "Fedora Linux" 763/head
Zbigniew Jędrzejewski-Szmek [Thu, 5 Aug 2021 09:16:52 +0000 (11:16 +0200)] 
fedora: say "Fedora Linux"

This is the new official name, see
https://fedoraproject.org/wiki/Changes/Fedora_Linux_in_os-release.

4 years agoman: improve grammar in description of --incremental
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 09:58:07 +0000 (11:58 +0200)] 
man: improve grammar in description of --incremental

4 years agoman: make files bold in list, adjust phrasing
Zbigniew Jędrzejewski-Szmek [Tue, 3 Aug 2021 18:38:29 +0000 (20:38 +0200)] 
man: make files bold in list, adjust phrasing

We said that all files are optional *before* starting the list of files,
then for each individual file, and then again *after* the list. Let's
simplify this by describing files without mentioning that is is optional.
Similarly, we don't need to emphasize the fact that scripts are executable
for each script… readers generally know that.

Let's also make the terms bold, so it's easier to find the interesting
paragraph in this wall of text.

Also break into paragraphs more; remove underlining from "OS" — it's a
normal abbreviation and the markup was confusing; use "/" at the end
of directories; use more markup for paths; move the description of
mkosi.skeleton above mkosi.extra.

Co-authored-by: Jörg Behrmann <behrmann@physik.fu-berlin.de>
4 years agoAdded in check for modules.dep prior to running dracut install
Ray Sit [Thu, 10 Jun 2021 03:21:19 +0000 (13:21 +1000)] 
Added in check for modules.dep prior to running dracut install

4 years agodocumented execution flow
nopeslide [Mon, 14 Jun 2021 10:46:13 +0000 (12:46 +0200)] 
documented execution flow

4 years agophoton: switch mirror to packages.vmware.com
Oluf Lorenzen [Tue, 3 Aug 2021 09:03:51 +0000 (11:03 +0200)] 
photon: switch mirror to packages.vmware.com

following <https://kb.vmware.com/s/article/82322> the repos have been switched to packages.vmware.com

4 years agobump version numbers for v10 v10
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 17:10:53 +0000 (19:10 +0200)] 
bump version numbers for v10

4 years agoMerge pull request #760 from keszybz/various-cleanups
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 17:05:49 +0000 (19:05 +0200)] 
Merge pull request #760 from keszybz/various-cleanups

Various cleanups without functional changes

4 years agofedora: use F34 by default
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 13:13:18 +0000 (15:13 +0200)] 
fedora: use F34 by default

F32 is no more…

4 years agoqemu: revert back to virtio from virtio-scsi-pci on Debian
Luca Boccassi [Fri, 18 Jun 2021 12:14:42 +0000 (13:14 +0100)] 
qemu: revert back to virtio from virtio-scsi-pci on Debian

Debian images on qemu fails to boot with virtio-scsi-pci. Reverting back to
virtio does not show issues with the EFI shell, everything boots correctly,
so do that when running Debian images.

4 years agomkosi: refactor creation of FIRMWARE_LOCATIONS lists 760/head
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 11:28:00 +0000 (13:28 +0200)] 
mkosi: refactor creation of FIRMWARE_LOCATIONS lists

It's nicer to make it more "declarative" by creating the lists
directly, instead of appending items one by one.

The newline is dropped from the error message: it's generally nicer to
make error messages one line. On a terminal, output will get wrapped
anyway.

Blame black, not me, for the ugly list formatting.

4 years agomkosi: refactor mangling of /etc/locale.gen into a separate function
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 10:58:47 +0000 (12:58 +0200)] 
mkosi: refactor mangling of /etc/locale.gen into a separate function

4 years agoNEWS: add remaining entries for v10
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 12:17:10 +0000 (14:17 +0200)] 
NEWS: add remaining entries for v10

4 years agoman: adjust wording and regenerate page
Zbigniew Jędrzejewski-Szmek [Fri, 30 Jul 2021 12:16:44 +0000 (14:16 +0200)] 
man: adjust wording and regenerate page

4 years agomkosi: if image version logic is enabled, make sure to generate root= entry in kernel...
Lennart Poettering [Fri, 2 Jul 2021 21:23:45 +0000 (23:23 +0200)] 
mkosi: if image version logic is enabled, make sure to generate root= entry in kernel command line

When the --image-version= logic is enabled this indicates that multiple
versions of an OS might be used in parallel within the same partition
table eventually. That makes it essential to boot the right root file
system from each unified kernel, so that kernel and root fs always match
up correctly.

If Verity is on this already worked, since we encode roothash= on the
kernel cmdline in that case, and that implies the root fs to use. Now,
ensure for verity-less cases that this works too.

We use PARTLABEL= match, using the image-id/image-version combination,
i.e. matching how we pick the label for the partition.

If the image version logic is not used, let's continue to not use the
a root= for simplicity reasons. In that case automatically finding the
root fs via fully automatic discovery should be simple and robust.

4 years agomkosi.md: Remove "in AUR" as the package has been moved to [community]
Morten Linderud [Mon, 5 Jul 2021 12:19:02 +0000 (14:19 +0200)] 
mkosi.md: Remove "in AUR" as the package has been moved to [community]

Signed-off-by: Morten Linderud <morten@linderud.pw>
4 years agoGithub Action: Update rpm version
Michal Koutný [Mon, 21 Jun 2021 14:16:14 +0000 (16:16 +0200)] 
Github Action: Update rpm version

The version 4.16.0 is affected by fallout from [1] in openSUSE:

> 2021-06-11 18:32:57 <1> fv-az272-819(29580) [zypp::exec++] ExternalProgram.cc(start_program):259 Executing 'rpmdb2solv' '-r' '/var/tmp/mkosi-jaz2krpn/root' '-X' '-p' '/var/tmp/mkosi-jaz2krpn/root/etc/products.d' '-o' '/var/tmp/mkosi-jaz2krpn/root/var/cache/zypp/solv/@System/solvwh4W4S'
> 2021-06-11 18:32:57 <1> fv-az272-819(29580) [zypp::exec++] ExternalProgram.cc(start_program):424 pid 29581 launched
> 2021-06-11 18:32:57 <2> fv-az272-819(29580) [zypp] TargetImpl.cc(buildCache):932   warning: invalid %_db_backend:
> 2021-06-11 18:32:57 <2> fv-az272-819(29580) [zypp] TargetImpl.cc(buildCache):932   warning: using dummy database, installs not possible
> 2021-06-11 18:32:57 <2> fv-az272-819(29580) [zypp] TargetImpl.cc(buildCache):932   rpmdb2solv: no error
> 2021-06-11 18:32:57 <1> fv-az272-819(29580) [zypp::exec++] ExternalProgram.cc(checkStatus):518 Pid 29581 exited with status 1

This is fixed [2] (backported also to 4.16.1, so bump to latest release
as of now 4.16.2).

[1] https://github.com/rpm-software-management/rpm/commit/471b7be4bd5cc7f245f9aa00c7784a7056e439b7
[2] https://github.com/rpm-software-management/rpm/commit/0644e4e79c841b03d606fc8bb035ec311f4bfb17

4 years agoGithub Action: Install pip module matching the git revision
Michal Koutný [Fri, 11 Jun 2021 16:54:13 +0000 (18:54 +0200)] 
Github Action: Install pip module matching the git revision

When the action is referenced with a particular git revision (e.g.
'uses: foo/mkosi@refspec') the given revision should be deployed.
Achieve that by installing pip directly from the action directory
(instead of a released/packaged version).

4 years agoGithub Action: Install zypper so that openSUSE container can be built
Michal Koutný [Mon, 15 Feb 2021 17:44:44 +0000 (18:44 +0100)] 
Github Action: Install zypper so that openSUSE container can be built

4 years agomkosi: be more careful when determining ifname for qemu machine
Lennart Poettering [Fri, 2 Jul 2021 21:27:23 +0000 (23:27 +0200)] 
mkosi: be more careful when determining ifname for qemu machine

Let's preferable use the image ID if we have it. and let's cut out any
'_' version suffix.

(This matters, since otherwise we might synthesize ifnames, that contain
version info, and thus dots, and that doesn't really work well for
ifnames)

4 years agoMerge pull request #740 from poettering/main
Daan De Meyer [Thu, 1 Jul 2021 11:16:32 +0000 (12:16 +0100)] 
Merge pull request #740 from poettering/main

mkosi: speed up "mkosi -i -f -B"

4 years agoMerge pull request #746 from bluca/debian_network
Daan De Meyer [Thu, 1 Jul 2021 11:13:42 +0000 (12:13 +0100)] 
Merge pull request #746 from bluca/debian_network

Debian: fallback to user/host network in qemu/nspawn with no networkd, manually enable resolved

4 years agoCorrect pacman hook name
Alex Wicks [Thu, 1 Jul 2021 01:58:07 +0000 (02:58 +0100)] 
Correct pacman hook name

Fixes systemd/mkosi#750
Pacman hooks must end with .hook as per Arch wiki
However mkosi's hook to update bootctl when the kernel updates ends in -hook instead of .hook
This means the hook doesn't get fired and kernel upgrades fail

4 years agodebian: enable resolved and symlink /etc/resolv.conf 746/head
Luca Boccassi [Fri, 18 Jun 2021 17:28:08 +0000 (18:28 +0100)] 
debian: enable resolved and symlink /etc/resolv.conf

By default resolved is disabled, and /etc/resolv.conf is an actual file with
'nameserver 127.0.0.1'.

4 years agonspawn: fallback to host network mode if networkd is not running
Luca Boccassi [Fri, 18 Jun 2021 18:14:38 +0000 (19:14 +0100)] 
nspawn: fallback to host network mode if networkd is not running

On Debian systemd-networkd is not the default network manager, so
there's nothing configuring the veth bridge.
If networkd is not running, simply fallback to using the host
network. This will not provide isolation, but at least the
connectivity is restored.

4 years agoqemu: fallback to usermode network if networkd is not running
Luca Boccassi [Fri, 18 Jun 2021 16:52:49 +0000 (17:52 +0100)] 
qemu: fallback to usermode network if networkd is not running

On Debian systemd-networkd is not the default network manager, Network-Manager is.
Fallback from TAP + veth to usermode networking. It is slower and NATted, but it
still works.

4 years agomkosi: add option to resolve symlinks when copying build sources.
Blair Bonnett [Fri, 25 Jun 2021 07:40:57 +0000 (09:40 +0200)] 
mkosi: add option to resolve symlinks when copying build sources.

This allows common build scripts or resources to be symlinked into the
build source directory, but then be copied into the build/final image as
actual files instead of symlinks.

4 years agomkosi: when using cached images, randomize fs and partition uuids explicitly 740/head
Lennart Poettering [Wed, 16 Jun 2021 15:16:14 +0000 (17:16 +0200)] 
mkosi: when using cached images, randomize fs and partition uuids explicitly

This addresses an annoying issue when building cached images containing
btrfs file systems: the kernel btrfs driver refuses mounting or handling
multiple different file systems with the same uuid. This means using an
image and building the next at the same time fails — as long as the
UUIDs of the newly build image aren't refreshed.

This patches makes sure when using a cached image we'll refresh disk,
partition and file system uuids. We generate them randomly, exactly like
we would have them when using non-cached builds.

This also ensures that the partition labels are rewritten when images
versions are bumped.

(Eventually we should probably start hashing the uuids from the
configuration state in some form, to provide a certain level of
reproducibility, but for now let's just randomize them.)

4 years agomkosi: speed up "mkosi -i -f -B"
Lennart Poettering [Tue, 15 Jun 2021 08:49:18 +0000 (10:49 +0200)] 
mkosi: speed up "mkosi -i -f -B"

When building images with image IDs and image versions it's a good idea
to reuse the pre-pared cached images from the earlier versions (I mean,
that's why cacheing/incremental operation exists). So far the cached
image names was derived 1:1 from the output file name, but if that
includs the image version it will be different for each build and hence
never suitable as cache.

Hence, if the image ID/version logic is used, let's change the naming
regime for the cache file, and let's derive it direcly from image name,
not taking the version into account.

4 years agoMerge pull request #744 from keszybz/add-remove-files
Daan De Meyer [Fri, 18 Jun 2021 16:25:24 +0000 (17:25 +0100)] 
Merge pull request #744 from keszybz/add-remove-files

Add --remove-files=/RemoveFiles=

4 years agomkosi: adjust comment 744/head
Zbigniew Jędrzejewski-Szmek [Fri, 18 Jun 2021 13:42:07 +0000 (15:42 +0200)] 
mkosi: adjust comment

> This comment is outdated, since we don't use the csv module anywhere.

4 years agoAdd --remove-files=/RemoveFiles=
Zbigniew Jędrzejewski-Szmek [Fri, 18 Jun 2021 11:56:15 +0000 (13:56 +0200)] 
Add --remove-files=/RemoveFiles=

This allows a post-install cleanup to be done. For example,
for initrd images:

  RemoveFiles=
        # we don't need this after the binary catalogs have been built
        /usr/lib/systemd/catalog
        /etc/udev/hwdb.d
        /usr/lib/udev/hwdb.d

As suggested in https://github.com/systemd/mkosi/pull/728#discussion_r646523736

4 years agoMerge pull request #743 from keszybz/minor-cleanups-suggested-by-rpmlint
Zbigniew Jędrzejewski-Szmek [Fri, 18 Jun 2021 07:39:52 +0000 (09:39 +0200)] 
Merge pull request #743 from keszybz/minor-cleanups-suggested-by-rpmlint

Minor cleanups suggested by rpmlint

4 years agomkosi: avoid mutable default arguments 743/head
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:41:58 +0000 (13:41 +0200)] 
mkosi: avoid mutable default arguments

4 years agomkosi: use 'in' in one more place
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:40:21 +0000 (13:40 +0200)] 
mkosi: use 'in' in one more place

4 years agomkosi: drop unused for_cache parameter
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:28:48 +0000 (13:28 +0200)] 
mkosi: drop unused for_cache parameter

4 years agomkosi: don't use [] as default argument
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:22:44 +0000 (13:22 +0200)] 
mkosi: don't use [] as default argument

rpmlint warns that this is dangerous. We don't modify the argument,
so actually this is safe here, but it's still nice to avoid this
potential pitfall.

4 years agomkosi: drop unused root argument
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:20:24 +0000 (13:20 +0200)] 
mkosi: drop unused root argument

4 years agomkosi: drop python2-style super() args
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:16:35 +0000 (13:16 +0200)] 
mkosi: drop python2-style super() args

4 years agomkosi: drop unused f from f-strings
Zbigniew Jędrzejewski-Szmek [Thu, 17 Jun 2021 11:16:21 +0000 (13:16 +0200)] 
mkosi: drop unused f from f-strings

Also, drop "+" from between string literals.

4 years agomkosi: don't use bsdtar on mandriva
Lennart Poettering [Wed, 16 Jun 2021 15:33:31 +0000 (17:33 +0200)] 
mkosi: don't use bsdtar on mandriva

Let's simplify things and use GNU tar everywhere, to expose somewhat
systematic behaviour on all distros.

This mirrors what systemd's importd daemon already does: force GNU tar
use even on distros where "tar" resolves to bsdtar.

4 years agoMerge pull request #728 from keszybz/cpio-and-zstd
Daan De Meyer [Wed, 16 Jun 2021 10:04:45 +0000 (11:04 +0100)] 
Merge pull request #728 from keszybz/cpio-and-zstd

cpio and zstd

4 years agoignore return code of fstrim
nopeslide [Fri, 21 May 2021 16:23:31 +0000 (18:23 +0200)] 
ignore return code of fstrim

devices (i.e. virtualized) may not support fstrim operations.

4 years agoFix short-form 'readonly' deprecation
Edwin Kofler [Tue, 8 Jun 2021 06:59:52 +0000 (06:59 +0000)] 
Fix short-form 'readonly' deprecation

4 years agoci: try cpio everywhere we try tar 728/head
Zbigniew Jędrzejewski-Szmek [Tue, 8 Jun 2021 06:58:42 +0000 (08:58 +0200)] 
ci: try cpio everywhere we try tar

4 years agoci: pip install types-dataclasses
Zbigniew Jędrzejewski-Szmek [Wed, 9 Jun 2021 11:57:54 +0000 (13:57 +0200)] 
ci: pip install types-dataclasses

Builds now fail with:

× Run python3 -m mypy mkosi
mkosi/__init__.py:12:1: error: Library stubs not installed for "dataclasses"
(or incompatible with Python 3.6)  [import]
    import dataclasses
    ^
mkosi/__init__.py:12:1: note: Hint: "python3 -m pip install types-dataclasses"
mkosi/__init__.py:12:1: note: (or run "mypy --install-types" to install all missing stub packages)
mkosi/__init__.py:12:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
mkosi/__init__.py:6247:12: error: Too many arguments for "CommandLineArguments"
 [call-arg]
        return CommandLineArguments(**vars(args))
               ^
Found 2 errors in 1 file (checked 3 source files)
Error: Process completed with exit code 1.

4 years agotyping: avoid warning about CompletedProcess.stdin being None
Zbigniew Jędrzejewski-Szmek [Mon, 7 Jun 2021 07:33:45 +0000 (09:33 +0200)] 
typing: avoid warning about CompletedProcess.stdin being None

In this particular case, stdin=subprocess.PIPE was passed, so we know
that .stdin is not None.

https://github.com/python/mypy/issues/10583

4 years agomkosi: rework compression config, add support for zstd
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 12:24:03 +0000 (14:24 +0200)] 
mkosi: rework compression config, add support for zstd

We had --compress and --xz. This is changed to --compress-fs (which is like
the old --compress), --compress-output (which is like --xz, except configurable),
and --compress (which tries to do the right thing depending on the output type).

With zstd, the difference in decompression time is massive:
$ time zstdcat image.cpio.zstd >/dev/null
0.221 s total
$ time xzcat image.cpio.xz >/dev/null
3.592 s total

$ ls -lg image.cpio.* image.cpio
-rw-rw-r-- 1 zbyszek 149408256 May 21 13:56 image.cpio
-rw-r--r-- 1 zbyszek  53032056 May 21 13:57 image.cpio.xz
-rw-r--r-- 1 zbyszek  59085907 May 21 13:49 image.cpio.zstd

v2:
- rename options to --compress-fs and --compres-output, unify handling
  of cpio and tar.

v3:
- use tar --use-compress-program= instead of subprocess.Popen()

v4:
- rebased after the backend.py split

4 years agomkosi: add support for building cpio archives
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 05:54:00 +0000 (07:54 +0200)] 
mkosi: add support for building cpio archives

This may be useful to create initramfs images, see
https://github.com/keszybz/mkosi-initrd.

I also tried an implementation using libarchive. The code was a little
bit simpler, but unfortunately the generated archive wasn't to the
kernel's liking. I think both the compressio options *and* the
underlying cpio format were a bit different. I think we should just accept
that the kernel is only tested with the specific output produced by cpio
with some specific settings.

4 years agomkosi: add variant of subprocess.Popen() that does not wait
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 05:54:00 +0000 (07:54 +0200)] 
mkosi: add variant of subprocess.Popen() that does not wait

We had run() which was a wrapper around subprocess.run().
This addes spawn(), which starts the process and does not wait for it.

v2:
- run() is changed to be call spawn() and wait and throw an exception
  if check is True.

v3:
- run() is a completely separate function again.

  It turns out that run() does a bunch of handling of input and output
  that would need to be recreated. In the end, the duplication of
  logging is a smaller issue than fiddling with input and output
  encodings.

v4:
- rebased

4 years agomkosi: fix alignment of Packages: line
Zbigniew Jędrzejewski-Szmek [Sat, 5 Jun 2021 13:05:18 +0000 (15:05 +0200)] 
mkosi: fix alignment of Packages: line

It was indented by two less.

4 years agomkosi: kill /usr/share/locale when installing Fedora
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 11:53:20 +0000 (13:53 +0200)] 
mkosi: kill /usr/share/locale when installing Fedora

Even with glibc-minimal-langpack, we still get ~30 MB of files
there with systemd + dependencies.

4 years agomkosi: reword error messages a bit
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 05:53:38 +0000 (07:53 +0200)] 
mkosi: reword error messages a bit

4 years agoMerge pull request #729 from behrmann/split_part1
Zbigniew Jędrzejewski-Szmek [Fri, 11 Jun 2021 07:19:32 +0000 (09:19 +0200)] 
Merge pull request #729 from behrmann/split_part1

Split precursor

4 years agoMerge pull request #730 from keszybz/help-pretiffication
Zbigniew Jędrzejewski-Szmek [Fri, 11 Jun 2021 06:50:09 +0000 (08:50 +0200)] 
Merge pull request #730 from keszybz/help-pretiffication

mkosi: do not repeat option lists in help output

4 years agoAdd typing to make mypy happy 730/head
Zbigniew Jędrzejewski-Szmek [Sun, 6 Jun 2021 17:41:32 +0000 (19:41 +0200)] 
Add typing to make mypy happy

Co-authored-by: Jörg Behrmann <behrmann@physik.fu-berlin.de>
4 years agomkosi: do not repeat option lists in help output
Zbigniew Jędrzejewski-Szmek [Sat, 5 Jun 2021 15:04:26 +0000 (17:04 +0200)] 
mkosi: do not repeat option lists in help output

--- /tmp/out1 2021-06-05 17:01:24.327828067 +0200
+++ /tmp/out2 2021-06-05 17:01:32.367897483 +0200
@@ -59,21 +59,19 @@
   --version             show program's version number and exit

 Distribution:
-  -d {fedora,debian,ubuntu,arch,opensuse,mageia,centos,centos_epel,clear,photon,openmandriva}, --distribution {fedora,debian,ubuntu,arch,opensuse,mageia,centos,centos_epel,clear,photon,openmandriva}
+  -d, --distribution {fedora,debian,ubuntu,arch,opensuse,mageia,centos,centos_epel,clear,photon,openmandriva}
                         Distribution to install
-  -r RELEASE, --release RELEASE
+  -r, --release RELEASE
                         Distribution release to install
-  -m MIRROR, --mirror MIRROR
-                        Distribution mirror to use
+  -m, --mirror MIRROR   Distribution mirror to use
   --repositories REPOS  Repositories to use
   --architecture ARCHITECTURE
                         Override the architecture of installation

 Output:
-  -t {directory,subvolume,tar,cpio,gpt_ext4,gpt_xfs,gpt_btrfs,gpt_squashfs,plain_squashfs}, --format {directory,subvolume,tar,cpio,gpt_ext4,gpt_xfs,gpt_btrfs,gpt_squashfs,plain_squashfs}
+  -t, --format {directory,subvolume,tar,cpio,gpt_ext4,gpt_xfs,gpt_btrfs,gpt_squashfs,plain_squashfs}
                         Output Format
-  -o PATH, --output PATH
-                        Output image path
+  -o, --output PATH     Output image path
   --output-split-root PATH
                         Output root or /usr/ partition image path (if --split-
                         artifacts is used)

… and so on.

4 years agofactor out leaf functions that will be needed for separating out distributions 729/head
Joerg Behrmann [Fri, 4 Jun 2021 15:24:43 +0000 (17:24 +0200)] 
factor out leaf functions that will be needed for separating out distributions

This reuses knowledge gained from #715. The functions included here are needed
to when distributiosn are moved to their own subpackages. This change has no
functional changes.

4 years agocapitalise arg_debug to show it's a global variable
Joerg Behrmann [Fri, 4 Jun 2021 15:03:22 +0000 (17:03 +0200)] 
capitalise arg_debug to show it's a global variable

4 years agotyping: use generics in @dictify type annotations
Zbigniew Jędrzejewski-Szmek [Thu, 3 Jun 2021 15:29:57 +0000 (17:29 +0200)] 
typing: use generics in @dictify type annotations

Instead of saying that it only works for [str, str], say it can create
a mapping of any two types. I verified that if I add a generator of a
different type, everything works as expected and mypy can detect type
mismatches.

I still don't know how to say that the wrapper takes the same
arguments as the decorated function. It would require a type
metavariable that would mean "some set of args and kwargs", and I
don't think there is syntax for anything like this.

4 years agoMerge pull request #724 from keszybz/drop-packages
Daan De Meyer [Thu, 3 Jun 2021 18:30:42 +0000 (19:30 +0100)] 
Merge pull request #724 from keszybz/drop-packages

mkosi: stop automatically inserting packages

4 years agomkosi: make run_pacman() function top-level 724/head
Zbigniew Jędrzejewski-Szmek [Tue, 25 May 2021 14:56:23 +0000 (16:56 +0200)] 
mkosi: make run_pacman() function top-level

No need to have this function dynamic.

4 years agomkosi: sort packages in installation list
Zbigniew Jędrzejewski-Szmek [Tue, 25 May 2021 14:48:57 +0000 (16:48 +0200)] 
mkosi: sort packages in installation list

It looks nice if the command line is tidy and the same on repeated
invocations. Plain sorted() would put '(' first, but conceptually it's
nice to have it last, so one can think "this will be installed if
those other things are listed first". The installer does not care of
course.

4 years agomkosi: optionally insert less packages automatically
Zbigniew Jędrzejewski-Szmek [Mon, 24 May 2021 12:42:39 +0000 (14:42 +0200)] 
mkosi: optionally insert less packages automatically

systemd, systemd-udev and some other packages were always
automatically inserted since the first version of mkosi. But this
approach is too heavy in some cases. To allow more flexibility while
maintaining backwards compat, this patch does two interleaved changes:

1. BasePackages=yes|no|conditional is added.

  With BasePackages=yes, we get status quo ante.

  With BasePackages=no, only packages specified by the user are
  installed.

  With BasePackages=conditional, on rpm systems, packages are
  installed if the matching base package would be installed. On
  deb/arch/… systems, equivalent to BasePackages=yes. (In other words,
  only rpm supports this natively. I'm not aware of similar
  functionality in other installers. install_arch() tries to achieve
  something similar by comparing package sets.)

  The default is "yes", to preseve unchanged behaviour by default.

2. Various packages that were installed unconditionally are converted
  to be conditional.

  This way we make more cases work automatically out of the box
  (e.g. the user only needs to specify 'systemd', not the
  subpackages), but allow deps to be cut down.

Looking at some concrete examples in Fedora:

- dracut: dracut is only necessary if using an initrd (and of
  course only if the initrd image is generated using dracut, and only
  if it is generated locally). But even for bootable images, a kernel
  with no initramfs might be enough. Or when using kvm, a direct
  kernel boot with an externally-provided kernel+initrd, etc.
  So pulling in dracut and dependencies is often not necessary.

- kernel-modules: despite the name, actually basic modules are in
  kernel-core. And kernel-modules is non-core modules. (And yes,
  kernel-modules-extra is extra-non-core-modules, and
  kernel-modules-internal is something else yet again).

- kernel-core: as with dracut, having a kernel image is not necessary
  in many scenarios.

- systemd: on big example where it's not useful is systemd itself.
  When using mkosi to build a systemd test image from sources,
  installing the system package forces all deps to be installed, which
  might not be desired. Dropping systemd from the installation list
  makes mkosi useful for non-systemd stuff (some container types or
  non-systemd inits).

  When installing systemd from sources, we do *not* want subpackages like
  systemd-udev to be installed. Having a mix of systemd-from-sources and
  a different compilation of systemd-udev-from-distro is likely to cause
  linking issues and other incompatibilities.

- grub* / systemd-boot: people might want to use grub even if sd-boot
  is available, etc.

For conditionalization, why do it using rpm syntax, and not interally
in code? For some cases, the effect is almost the same. But in other
cases, the installer has more information. For example, glibc usually
is not specified explicitly, but is pulled in through deps. We want
glibc-minimal-langpack only if something else pulls in glibc, and we
cannot resolve this from inside mkosi. But even for other packages,
the user might use a meta-package or a package group or a file path or
a virtual provide, and we cannot know in general what package will be
used to resolve the dependency. Using boolean dependencies makes this
much more reliable.

4 years agoopensuse: install "openssh-server", not "o", "p", "e", …
Zbigniew Jędrzejewski-Szmek [Tue, 25 May 2021 14:24:50 +0000 (16:24 +0200)] 
opensuse: install "openssh-server", not "o", "p", "e", …

4 years agophoton: install user-specified packages too
Zbigniew Jędrzejewski-Szmek [Tue, 25 May 2021 14:24:13 +0000 (16:24 +0200)] 
photon: install user-specified packages too

I assume this was an uninteded omission.

4 years agomkosi: allow inline comments (but only with "#")
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 14:06:58 +0000 (16:06 +0200)] 
mkosi: allow inline comments (but only with "#")

For example, it's super useful to comment on a list of packages:

Packages=
        glibc-minimal-langpack    # avoid pulling in other glibc langpacks
        less                      # this makes 'systemctl' much nicer to use ;)

;-comments are not allowed, because the colon doesn't stand out
enough. I was considering also adding comment_prefixes=('#',) to
disallow ;-comments everywhere, but that'd be a compatibility break
which I don't see enough justification for.

4 years agoMerge pull request #720 from keszybz/two-refactorings-and-a-bugfix
Daan De Meyer [Mon, 24 May 2021 08:50:59 +0000 (09:50 +0100)] 
Merge pull request #720 from keszybz/two-refactorings-and-a-bugfix

Some refactorings and bugfixes

4 years agomkosi: move two dynamically created methods to class level 720/head
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 13:51:35 +0000 (15:51 +0200)] 
mkosi: move two dynamically created methods to class level

4 years agoman: regerate man page
Zbigniew Jędrzejewski-Szmek [Sun, 23 May 2021 09:17:26 +0000 (11:17 +0200)] 
man: regerate man page

4 years agodocs: use backticks around --options
Zbigniew Jędrzejewski-Szmek [Sun, 23 May 2021 09:15:56 +0000 (11:15 +0200)] 
docs: use backticks around --options

Without this, pandoc renders "--" as "–".

4 years agomkosi: fix TypeError on unknown output format
Zbigniew Jędrzejewski-Szmek [Sat, 22 May 2021 20:43:42 +0000 (22:43 +0200)] 
mkosi: fix TypeError on unknown output format

Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/zbyszek/src/mkosi/mkosi/__main__.py", line 31, in <module>
    main()
  File "/home/zbyszek/src/mkosi/mkosi/__main__.py", line 11, in main
    args = parse_args()
  File "/home/zbyszek/src/mkosi/mkosi/__init__.py", line 5283, in parse_args
    args = parse_args_file_group(argv, default_path)
  File "/home/zbyszek/src/mkosi/mkosi/__init__.py", line 5320, in parse_args_file_group
    return parser.parse_args(argv_post_parsed)
  File "/usr/lib64/python3.9/argparse.py", line 1818, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.9/argparse.py", line 1851, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.9/argparse.py", line 2060, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.9/argparse.py", line 2000, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.9/argparse.py", line 1912, in take_action
    argument_values = self._get_values(action, argument_strings)
  File "/usr/lib64/python3.9/argparse.py", line 2444, in _get_values
    self._check_value(action, value)
  File "/usr/lib64/python3.9/argparse.py", line 2496, in _check_value
    if action.choices is not None and value not in action.choices:
  File "/usr/lib64/python3.9/enum.py", line 373, in __contains__
    raise TypeError(
TypeError: unsupported operand type(s) for 'in': 'str' and 'EnumMeta'

With the patch:
usage: mkosi [-h] [--version]
             ...
             {build,clean,help,summary,genkey,bump,serve,build,shell,boot,qemu,ssh} ...
mkosi: error: argument -t/--format: unknown Format: 'asfd'

It would be nice to also get rid of the list of options in the help
message: it's not helpful to the user at all.

4 years agomkosi: rewrite os-release parsing
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 11:51:51 +0000 (13:51 +0200)] 
mkosi: rewrite os-release parsing

This used the code from https://github.com/systemd/systemd/pull/19686,
except that walrus is removed for python3.7 compatibility.

4 years agomkosi: make one os.walk() more like the others
Zbigniew Jędrzejewski-Szmek [Fri, 21 May 2021 05:46:55 +0000 (07:46 +0200)] 
mkosi: make one os.walk() more like the others

We currently have three very similar loops, let's avoid unnecessary
shortening of variable names in one.