]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
3 years agoFix indentation in output 817/head
Zbigniew Jędrzejewski-Szmek [Mon, 20 Sep 2021 16:42:30 +0000 (18:42 +0200)] 
Fix indentation in output

Follow-up for 95aaafb11d.

3 years agoUse pathlib more in one more place
Zbigniew Jędrzejewski-Szmek [Mon, 20 Sep 2021 14:09:32 +0000 (16:09 +0200)] 
Use pathlib more in one more place

3 years agoMerge pull request #813 from dellgreen/dpg/811/add-rocky-linux
Daan De Meyer [Thu, 16 Sep 2021 12:30:39 +0000 (13:30 +0100)] 
Merge pull request #813 from dellgreen/dpg/811/add-rocky-linux

rocky: add support for rocky linux 8 with and without EPEL

3 years agoupdate man page to use full 'Rocky Linux' name in descriptions 813/head
Dell Green [Thu, 16 Sep 2021 09:25:01 +0000 (10:25 +0100)] 
update man page to use full 'Rocky Linux' name in descriptions

3 years agoadd missing centos_epel as an available distribution to build
Dell Green [Thu, 16 Sep 2021 09:09:32 +0000 (10:09 +0100)] 
add missing centos_epel as an available distribution to build

3 years agoupdate man page to include references to rocky linux
Dell Green [Thu, 16 Sep 2021 08:53:18 +0000 (09:53 +0100)] 
update man page to include references to rocky linux

3 years agoupdate CI to build rocky linux
Dell Green [Wed, 15 Sep 2021 10:00:06 +0000 (11:00 +0100)] 
update CI to build rocky linux

3 years agorocky: add support for rocky linux 8 with and without EPEL
Dell Green [Tue, 14 Sep 2021 17:57:24 +0000 (18:57 +0100)] 
rocky: add support for rocky linux 8 with and without EPEL

Closes: #811.
3 years agomkosi: fix typo
Lennart Poettering [Mon, 13 Sep 2021 15:45:02 +0000 (17:45 +0200)] 
mkosi: fix typo

3 years agoMerge pull request #791 from keszybz/smaller-gpt-areas
Daan De Meyer [Mon, 13 Sep 2021 09:02:13 +0000 (10:02 +0100)] 
Merge pull request #791 from keszybz/smaller-gpt-areas

Smaller gpt header and footer

3 years agoInstall extra trees after installing build results
Daan De Meyer [Fri, 10 Sep 2021 12:20:42 +0000 (13:20 +0100)] 
Install extra trees after installing build results

Fixes #789

3 years agomkosi: don't install skeleton trees into cached images again
Lennart Poettering [Fri, 10 Sep 2021 19:44:40 +0000 (21:44 +0200)] 
mkosi: don't install skeleton trees into cached images again

They already contain the skeleton trees, no need to copy them a second
time.

Fixes: #759
3 years agoRenamed argument UseSystemRepositories to UseHostRepositories
Ray Sit [Sat, 11 Sep 2021 05:09:52 +0000 (15:09 +1000)] 
Renamed argument UseSystemRepositories to UseHostRepositories
The use of the term system can be misleading as system can refer
to many different things. The term host is more accurate for what the
option is. Also updated the command help to identify the option is
for dnf-based distros.

3 years agoMerge pull request #807 from keszybz/fix-rawhide
Jörg Behrmann [Fri, 10 Sep 2021 17:35:12 +0000 (19:35 +0200)] 
Merge pull request #807 from keszybz/fix-rawhide

fedora: fix selection of rawhide

3 years agofedora: fix selection of rawhide 807/head
Zbigniew Jędrzejewski-Szmek [Fri, 10 Sep 2021 16:22:20 +0000 (18:22 +0200)] 
fedora: fix selection of rawhide

The keys are sorted, but by using sorted() we were "sorting" again
alphabetically, getting the order of "10", …, "36", "7", "8", "9".

3 years agoUse __future__.annotations everywhere 791/head
Zbigniew Jędrzejewski-Szmek [Fri, 10 Sep 2021 12:46:03 +0000 (14:46 +0200)] 
Use __future__.annotations everywhere

3 years agoTry calling blockdev --rereadpt in a loop
Zbigniew Jędrzejewski-Szmek [Thu, 9 Sep 2021 12:48:59 +0000 (14:48 +0200)] 
Try calling blockdev --rereadpt in a loop

It works fine locally, but we sometimes get failures in CI:

blockdev: ioctl error on BLKRRPART: Device or resource busy

I think it's race condition of some sort, so let's just try again
waiting a bit more each time. The total delay is up to about 2 s.

3 years agoman: add a stub description of --debug
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 08:54:10 +0000 (10:54 +0200)] 
man: add a stub description of --debug

The option is there, we should have some documentation for it.
But I think the current split is not very useful (e.g. why
"workspace-command", what does this even mean?), and I expect that
we'll want to review the list and hide some options before documenting
this. So the choices are not described in the man page yet.

3 years agoAdd --debug=disk and show sectors and raw sfdisk configs if selected
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 08:51:32 +0000 (10:51 +0200)] 
Add --debug=disk and show sectors and raw sfdisk configs if selected

The low-level sfdisk configs are quite useful when trying to figure
out what sfdisk doesn't like. But we shouldn't show this by default,
so this adds a new --debug selector and hides the detailed output
otherwise.

3 years agosfdisk: do not reread the partition table twice
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 07:50:13 +0000 (09:50 +0200)] 
sfdisk: do not reread the partition table twice

We call partprobe right after, so let's tell sfdisk to not do that
on its own. This avoids some pointless messages from sfdisk also.

3 years agomkosi: reserve much less area for GPT header and footer
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 13:36:06 +0000 (15:36 +0200)] 
mkosi: reserve much less area for GPT header and footer

We would reserve 1MB on both ends. This is what sfdisk (and other
tools) do by default. It probably makes sense for real disks, which
are large enough that 1–2 MB don't matter, and one might want to add
partitions later. For our images this isn't very useful. In fact, we
could probably go lower than 128 partitions, since we generally know
exactly how many we will create. But I'm leaving that for later,
because the savings are not large, and there might be compatiblity
issues involved. If it turns out that the changes done here don't
cause problems, we could consider making the max partition count
smaller, to save another 12 kb or so.

The "grain" (partition alignment) is set to 4096 bytes, even on
devices with 512 byte sectors. 4k devices are becoming more popular,
and we could trigger bad performance if the partitions was misaligned.

The code is reworked to take the specified first-lba into account.

(In the initial version of this patch that was posted, 'grain:4096'
was passed to sfdisk, and this seemed enough. But with various other
combinations of image sizes, sfdisk sometimes refuses to create the
expected layout when first-lba is not specified. So this version of
the patch specifies both values.)

Before: ‣ Resulting image size is 1.8M, consumes 848.0K.
After:  ‣ Resulting image size is 808.0K, consumes 808.0K.

3 years agomkosi: use blockdev --rereadpt instead of partx --update
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 18:25:56 +0000 (20:25 +0200)] 
mkosi: use blockdev --rereadpt instead of partx --update

With smaller devices, we trigger a bug in partx. It was fixed in
util-linux-2.37, but at least Fedora 34 still has 2.36. With
blockdev --rereadpt, it's the kernel which parses the table, which
should avoid the issue.

3 years agomkosi: use a dataclass for sfdisk output
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 10:48:43 +0000 (12:48 +0200)] 
mkosi: use a dataclass for sfdisk output

Also a list of lines instead of a manually constructed string. This
way the whole thing is more readable and it's easier to add and remove
fields.

No functional change.

3 years agoMerge pull request #804 from behrmann/importlib
Zbigniew Jędrzejewski-Szmek [Fri, 10 Sep 2021 06:48:31 +0000 (08:48 +0200)] 
Merge pull request #804 from behrmann/importlib

use importlib for static resources

3 years agomkosi: wrap importlib.resource in a write_resource function 804/head
Joerg Behrmann [Thu, 9 Sep 2021 16:10:09 +0000 (18:10 +0200)] 
mkosi: wrap importlib.resource in a write_resource function

3 years agomkosi: use importlib for static resources
Joerg Behrmann [Thu, 9 Sep 2021 14:43:34 +0000 (16:43 +0200)] 
mkosi: use importlib for static resources

3 years agomanifest: do not gather changelogs if they will not be used
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 19:11:06 +0000 (21:11 +0200)] 
manifest: do not gather changelogs if they will not be used

I wanted to keep the data collection and serialization parts completely
separate, and I thought that gathering of the changelogs is insignificant.
But with a lot of packages, it can add up. So let's do it only if it'll
be useful later on.

A direct motivation is https://bugzilla.redhat.com/show_bug.cgi?id=2002038:
rpm gets confused by some package names and cannot show the changelog.

3 years agoAdded option to skip use of hardcoded default dnf-distro repositories
Ray Sit [Thu, 9 Sep 2021 09:42:03 +0000 (19:42 +1000)] 
Added option to skip use of hardcoded default dnf-distro repositories
This UseSystemRepositories/--use-system-repositories option allows
mkosi to use the dnf repo files that exist on the system, instead of
locking the script into using the hardcoded repo file that only
contains the default repos for each distro. It is only applicable
to dnf based distros.

3 years agoaction: Extract package manager build logic into separate script
Daan De Meyer [Thu, 9 Sep 2021 13:10:03 +0000 (14:10 +0100)] 
action: Extract package manager build logic into separate script

To make the action easier to debug, let's extract the logic for
building dnf and pacman into a script that we can run outside of
github actions. We also include an accompanying mkosi config that
can be used to test the script locally. Building the mkosi image
builds and installs all the package managers into the final image.

The final image can then be booted in QEMU, mkosi can be cloned and
tested using the installed package managers.

This commit also includes a bunch of general improvements to the
build logic:

- Install everything to /usr/lib/x86_64-linux-gnu so Ubuntu finds
libraries
- Make the script idempotent so it can take advantage of caching
(both in mkosi now using mkosi.builddir/ and in the future with GA)
- Use versioned build directories
- Update all package versions to the latest and make the necessary
modifications to the build script to keep everything building.

3 years agoci: update dependency versions for pacman install (#793)
168912916 859421311 [Thu, 9 Sep 2021 11:40:55 +0000 (13:40 +0200)] 
ci: update dependency versions for pacman install (#793)

3 years agotests: use @contextlib.contextmanager instead of a class
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 19:33:51 +0000 (21:33 +0200)] 
tests: use @contextlib.contextmanager instead of a class

3 years agoMerge pull request #794 from bluca/debian_pkg_cleanup
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 14:18:14 +0000 (16:18 +0200)] 
Merge pull request #794 from bluca/debian_pkg_cleanup

mkosi: implement metadata cleanup for apt and dpkg

3 years agomkosi: dont encrypt genkey private keys
Lennart Poettering [Wed, 8 Sep 2021 07:15:16 +0000 (09:15 +0200)] 
mkosi: dont encrypt genkey private keys

Let's turn off "DES" encryption of X509 private keys we generate. It's
not really a useful feature, we aren't really an interactive tool (and
thus asking for a password is weird). And it's not secure at all.

3 years agomkosi: fix some fall-out from the pathification
Lennart Poettering [Wed, 8 Sep 2021 07:14:49 +0000 (09:14 +0200)] 
mkosi: fix some fall-out from the pathification

A follow-up from the pathlib.Path conversion (#782)

3 years agomkosi: implement metadata cleanup for apt and dpkg 794/head
Luca Boccassi [Tue, 7 Sep 2021 22:35:24 +0000 (23:35 +0100)] 
mkosi: implement metadata cleanup for apt and dpkg

3 years agomkosi: fix clean_foo_metadata condition check
Luca Boccassi [Wed, 8 Sep 2021 09:39:01 +0000 (10:39 +0100)] 
mkosi: fix clean_foo_metadata condition check

It was switched around, and always cleaned the metadata if the
binary was present.

3 years agoMerge pull request #795 from poettering/gpt-types-tweak
Lennart Poettering [Wed, 8 Sep 2021 07:57:34 +0000 (09:57 +0200)] 
Merge pull request #795 from poettering/gpt-types-tweak

mkosi: clean up gpt type logic a tiny bit

3 years agomkosi: hook up i386 gpt pt types 795/head
Lennart Poettering [Tue, 7 Sep 2021 19:50:35 +0000 (21:50 +0200)] 
mkosi: hook up i386 gpt pt types

Let's actually hook up the i386 gpt pt types to be used.

(This uses the list of known uname machine fields we use in systemd:
https://github.com/systemd/systemd/blob/main/src/basic/architecture.c#L32
)

3 years agomkosi: drop ia64 partition type uuids
Lennart Poettering [Tue, 7 Sep 2021 19:48:50 +0000 (21:48 +0200)] 
mkosi: drop ia64 partition type uuids

These are never used, and I don't see that changing anytime soon given
the platform is pretty much dead. Hence let's drop these identifiers.

3 years agoMerge pull request #788 from behrmann/minpyversion
Zbigniew Jędrzejewski-Szmek [Wed, 8 Sep 2021 06:23:32 +0000 (08:23 +0200)] 
Merge pull request #788 from behrmann/minpyversion

Bump advertised minimum Python version and grab bag of typing

3 years agomkosi: change str(Path) to os.fspath(Path) 788/head
Joerg Behrmann [Tue, 7 Sep 2021 15:20:54 +0000 (17:20 +0200)] 
mkosi: change str(Path) to os.fspath(Path)

os.fspath calls the appropriate protocol instead of using the potentially lossy
string representation

3 years agomkosi: rewrite find_files to return Path objects
Joerg Behrmann [Tue, 7 Sep 2021 15:20:30 +0000 (17:20 +0200)] 
mkosi: rewrite find_files to return Path objects

3 years agoConfigure pyright
Joerg Behrmann [Tue, 7 Sep 2021 13:38:41 +0000 (15:38 +0200)] 
Configure pyright

3 years agomkosi: work around pyright warnings
Joerg Behrmann [Tue, 7 Sep 2021 13:38:08 +0000 (15:38 +0200)] 
mkosi: work around pyright warnings

3 years agomkosi: only pass strings to os.execvp
Joerg Behrmann [Tue, 7 Sep 2021 13:32:12 +0000 (15:32 +0200)] 
mkosi: only pass strings to os.execvp

3 years agomkosi: bump advertised minimum Python version
Joerg Behrmann [Tue, 7 Sep 2021 12:56:58 +0000 (14:56 +0200)] 
mkosi: bump advertised minimum Python version

So far the documentation and mypy config target Python 3.6, but our setup.py
already specified 3.7.

3 years agoMerge pull request #792 from keszybz/fix-tests
Daan De Meyer [Tue, 7 Sep 2021 19:56:00 +0000 (20:56 +0100)] 
Merge pull request #792 from keszybz/fix-tests

Fix tests

3 years agomkosi: fix typo in method name 792/head
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 18:32:20 +0000 (20:32 +0200)] 
mkosi: fix typo in method name

3 years agoMake sure we append Paths to the lists of extra/skeleton trees
Daan De Meyer [Tue, 7 Sep 2021 14:39:05 +0000 (15:39 +0100)] 
Make sure we append Paths to the lists of extra/skeleton trees

3 years agomkosi+tests: fix default and tests for CleanPackageMetadata
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 16:24:03 +0000 (18:24 +0200)] 
mkosi+tests: fix default and tests for CleanPackageMetadata

CleanPackageMetadataAction inherits from BooleanAction, which sets
false as the default. And we want the default to be 'auto'.

Fixup for bd1d8577ef5bb2973677bc9da65b927c279b534c.

3 years agomkosi+tests: fix handling and tests for Path arguments
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 16:22:28 +0000 (18:22 +0200)] 
mkosi+tests: fix handling and tests for Path arguments

This should have been done in 5a24a9fd9e9eea4c1a9cf2e9c1980697fd9b922b.
The code is getting more and more complex, because previously we
relied on having a string which could be both multiple items with
a separator, or just a single thing… With Path() this doesn't work
nearly so nicely.

3 years agoMerge pull request #786 from keszybz/override-various-autodetection-features
Daan De Meyer [Tue, 7 Sep 2021 13:04:39 +0000 (14:04 +0100)] 
Merge pull request #786 from keszybz/override-various-autodetection-features

Override various autodetection features

3 years agoTODO: remove one finished item, add two minor bugs 786/head
Zbigniew Jędrzejewski-Szmek [Mon, 6 Sep 2021 11:33:46 +0000 (13:33 +0200)] 
TODO: remove one finished item, add two minor bugs

3 years agomkosi: do not expand globs in manager metadata removal twice
Zbigniew Jędrzejewski-Szmek [Mon, 6 Sep 2021 08:29:22 +0000 (10:29 +0200)] 
mkosi: do not expand globs in manager metadata removal twice

We would do globbing internally in clean_*_metadata(), and then again
in remove_glob(). We want to do globbing early to only emit the
message when there's anything to remove. So let's stop calling
remove_glob().

While at it, make the internal variable names a bit shorter.

3 years agoAllow disabling the of script autodetection
Zbigniew Jędrzejewski-Szmek [Sun, 5 Sep 2021 12:23:22 +0000 (14:23 +0200)] 
Allow disabling the of script autodetection

The idea is to allow specifing "--finalize-script=" to override the finalize
script to not be invoked, even in "mkosi.finalize" is present.

Right now, if there's a mkosi.build/mkosi.finalize/… file present, the
only way to prevent the script from running is to specify something
like --build-script=/bin/true (or move the script out of the way).
Sometimes it's useful to be able to skip the script. The code is changed
to convert '' to a placeholder value that is taken to mean that no script
should be executed. (None is already used to mean "no config", and implies
autodetection, so we can't use it for this purpose.)

3 years agofedora: store full key identifiers internally
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 08:46:45 +0000 (10:46 +0200)] 
fedora: store full key identifiers internally

Fedora website currently uses short identifiers, and we can't do anything
about this until they fix it. But let's store the full hash internally.

Inpired by https://github.com/systemd/mkosi/pull/784#issuecomment-913819662.

3 years agoAllow overriding autodetection of package manager metadata cleanup
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 18:56:20 +0000 (20:56 +0200)] 
Allow overriding autodetection of package manager metadata cleanup

There are cases where the package metadata should be removed, even
though the manager is present. For example, when the manager is pulled
in through dependencies or needs to be present in the image for
whatever other reasons.  Similarly, there are cases where the metadata
should remain in the image, even though the package manager is
provided externally.

In particular, it is useful when building an image which will later on
be used as a "sysext base". Without the metadata, we will try to
install all packages again. So we want to keep the dnf/rpm metadata.
Later, when building a "sysext", dnf/rpm will be visible from the base
layer, even though it will not be present in the sysext layer being built.
We want to remove the dnf/rpm metadata.

3 years agomkosi: decode utf-8 earlier in run() commands
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 13:34:34 +0000 (15:34 +0200)] 
mkosi: decode utf-8 earlier in run() commands

No funtional difference, but in general it's a good idea to avoid
explicit conversions and push the decoding of binary data into the
file layer.

3 years agomkosi: use +=[] instead of .append()
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 12:59:53 +0000 (14:59 +0200)] 
mkosi: use +=[] instead of .append()

It's more pleasing to the eye. It also works better when we have two
items to add.

3 years agoMerge pull request #782 from keszybz/pathify-all-paths
Daan De Meyer [Mon, 6 Sep 2021 18:52:50 +0000 (20:52 +0200)] 
Merge pull request #782 from keszybz/pathify-all-paths

Use pathlib.Path for paths

3 years agomkosi: drop mkdir_last() 782/head
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 07:38:11 +0000 (09:38 +0200)] 
mkosi: drop mkdir_last()

AFAICT, it's exactly the same as .mkdir(exist_ok=True).

3 years agomkosi: drop strange try..except block
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 07:32:05 +0000 (09:32 +0200)] 
mkosi: drop strange try..except block

I guess the intent was to guard against .cmdline being not present.
But it's declared in the class and will always be there.

3 years agomkosi: use Path for path-like objects
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 07:19:02 +0000 (09:19 +0200)] 
mkosi: use Path for path-like objects

The Path object generally works better for the kind of operations that
we need to do. In some cases it can be a bit awkward — for example just
appending a suffix requires some annoying gyrations. But overall, the
amount of code text is reduced and I think it's easier to read.

Some bugs were fixed on the way: in particular dedent() was missed in
when writing some configuration files (90-mkosi-vmlinuz-add.hook,
60-mkosi-vmlinuz-remove.hook).

The intent is to have no functional change, though with this amount of
churn some regression is likely… I tested this by building a bunch
of different projects with diverse configurations, and at least mkosi
doesn't crash, though I didn't check the produced images in detail.

An additional advantage is that we have stronger typing: before many
functions took a bunch of 'str' arguments, and now the paths at least
have a distinct type.

3 years agomkosi: stop using deepcopy when parsing arguments
Zbigniew Jędrzejewski-Szmek [Wed, 1 Sep 2021 14:41:54 +0000 (16:41 +0200)] 
mkosi: stop using deepcopy when parsing arguments

The code was modifing the passed argv array internally. And in fact,
parse_args_distribution_group() only worked correctly if
parse_args_file_group() was previously used to modify the argv array. Let's
drop all this, and never modify the input arguments. In the few cases where
it's appropriate, a copy is made internally.

Also shorten names of internal variables. defaults_file vs. default_file vs.
all_defaults_files was only making the code harder to read.

3 years agoMerge pull request #783 from keszybz/all-white
Daan De Meyer [Mon, 6 Sep 2021 13:25:52 +0000 (15:25 +0200)] 
Merge pull request #783 from keszybz/all-white

Drop black from ci, add a check that tabs are not used, do pyflakes check, adjust indentation

3 years agomkosi: fix specification of compression algorithm for mksquashfs
Zbigniew Jędrzejewski-Szmek [Mon, 6 Sep 2021 12:13:56 +0000 (14:13 +0200)] 
mkosi: fix specification of compression algorithm for mksquashfs

I think this wasn't properly updated when CompressFs=/CompressOutput=
was added.

3 years agofedora: add keys until F36
Zbigniew Jędrzejewski-Szmek [Sun, 5 Sep 2021 17:28:11 +0000 (19:28 +0200)] 
fedora: add keys until F36

I also added older keys: we might want to build images with
older Fedora, and it's better to have the key hashes than
not to have them. The list now includes all keys listed by
fedora-gpg-keys-34-2.noarch.

3 years agoci: add a check for tabs 783/head
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 11:41:33 +0000 (13:41 +0200)] 
ci: add a check for tabs

Surprisingly, none of the standard tools complain about tabs in the
code, at least in some locations. I expected that python3 would always
complain, or at least tabnanny, or pyflakes… Let's roll a simple custom
check.

Use '-P' to request perl-compatible regular expressions even the user
has a different default configures so that '\t' works as expected.

3 years agoci: run pyflakes in ci
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 11:53:25 +0000 (13:53 +0200)] 
ci: run pyflakes in ci

It seems to find unused imports and such, without generating too much noise.

3 years agomkosi: turn off black formatting in a few places, adjust formatting
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 10:16:35 +0000 (12:16 +0200)] 
mkosi: turn off black formatting in a few places, adjust formatting

Now that we don't enforce black formatting, it's easier to have better
formatting in various places.

Multi-line error messages need to be wrapped to <=80 chars, and dedented.

3 years agoMerge pull request #781 from keszybz/run-debug
Daan De Meyer [Fri, 3 Sep 2021 13:12:20 +0000 (15:12 +0200)] 
Merge pull request #781 from keszybz/run-debug

Fix --debug=run

3 years agoci: drop black check
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 11:37:30 +0000 (13:37 +0200)] 
ci: drop black check

Closes #779.

3 years agoDrop unused imports and f-prefixes and variables
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 11:36:21 +0000 (13:36 +0200)] 
Drop unused imports and f-prefixes and variables

Based on pyflakes hints.

3 years agoReplace contextlib.ExitStack by direct cm invocations
Zbigniew Jędrzejewski-Szmek [Sat, 28 Aug 2021 09:37:19 +0000 (11:37 +0200)] 
Replace contextlib.ExitStack by direct cm invocations

I think it's nicer to keep things simple. Unfortunately black
turns the first chunk into a complete mess, so it needs to be disabled.
With python 3.9+ we will be able to drop the line continuations.

3 years agomkosi: adjust comment for readability 781/head
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 08:20:33 +0000 (10:20 +0200)] 
mkosi: adjust comment for readability

3 years agomkosi: make ARG_DEBUG a set
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 08:20:18 +0000 (10:20 +0200)] 
mkosi: make ARG_DEBUG a set

With this change, ARG_DEBUG is always the same (mutable) object.
Before it was first a tuple, and then a list, so the object (and type)
changed. When we did 'from backend import ARG_DEBUG', we would get a
reference to the tuple, and then when ARG_DEBUG was adjusted in backend,
the import wasn't properly updated. ('backend.ARG_DEBUG' would refer
to one object, and '__init__.ARG_DEBUG' to a different one.)

With this change, --debug run works again for me.

3 years agomkosi/backend: fix priting of the executed commands
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 08:16:44 +0000 (10:16 +0200)] 
mkosi/backend: fix priting of the executed commands

Apparently this got borked in 80523f224e2f07b04bf14ec098da7108cdb1e070
and nobody noticed.

3 years agoMerge pull request #780 from keszybz/man-use-config-keys-as-primary
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 08:44:27 +0000 (10:44 +0200)] 
Merge pull request #780 from keszybz/man-use-config-keys-as-primary

Use config keys as primary in documentation, rename [Packages] to [Content]

3 years agoMerge pull request #768 from keszybz/mkosi-manifest
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 10:41:23 +0000 (12:41 +0200)] 
Merge pull request #768 from keszybz/mkosi-manifest

mkosi: record package list and changelogs in files

3 years agoman: regerate man page 780/head
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 10:40:59 +0000 (12:40 +0200)] 
man: regerate man page

3 years agoMove settings for password/autologin to [Content]
Zbigniew Jędrzejewski-Szmek [Fri, 27 Aug 2021 16:32:44 +0000 (18:32 +0200)] 
Move settings for password/autologin to [Content]

3 years agoRename [Packages] to [Content]
Zbigniew Jędrzejewski-Szmek [Tue, 17 Aug 2021 11:55:38 +0000 (13:55 +0200)] 
Rename [Packages] to [Content]

Initially, that section was mostly about packages. But now we have
a bazillion settings, out of which only a handful is about packages.

Backwards compatibility is preserved, the old name is automatically
translated in the config parser.

3 years agoman: describe SkeletonTree before ExtraTree
Zbigniew Jędrzejewski-Szmek [Tue, 17 Aug 2021 10:54:41 +0000 (12:54 +0200)] 
man: describe SkeletonTree before ExtraTree

In ee67e6ab3ea0353791eb3a37d166341dafeb44a5 I did the anologous change
in the Files section, but missed this spot.

3 years agoman: minor fixes and rewrappings of long paragraphs
Zbigniew Jędrzejewski-Szmek [Tue, 17 Aug 2021 10:39:44 +0000 (12:39 +0200)] 
man: minor fixes and rewrappings of long paragraphs

3 years agoman: refer to settings primarily by their config file name
Zbigniew Jędrzejewski-Szmek [Tue, 17 Aug 2021 10:31:32 +0000 (12:31 +0200)] 
man: refer to settings primarily by their config file name

This implements the first part of #769: the structure of the man page
is changed from:

Command Line Parameters
--foo
...
Command Line Parameters and their Settings File Counterparts
--foo Output Foo=
...

to:

Settings
[Output] section
Foo=
--foo
...

I think the new order is both easier to read _and_ easier to maintain.
E.g. the table with option name mappings was missing a few entries.

I dropped "(see above)" and "(see below)" in various places. The user
knows that they can search for a given option name, and we don't need
to tell them. And since the target of this "anchor" usually isn't right
below or right above, they will need to use search _anyway_.

An exception is when we wanted to refer to a description of a file
in the Files section. In those cases I changed "(see below)" to
"(see "Files" section below)" so the user actually knows what to look
for.

I inserted FIXMEs for various issues. Trying to fix everything at once
would lead to an unreviable commit…

The regeneration of man/ is not included in the commits, because it's
annoying to constantly fix this up when rebasing patches. I'll do it
one go at the end.

3 years agoMerge pull request #776 from keszybz/network-never
Daan De Meyer [Mon, 30 Aug 2021 08:49:43 +0000 (09:49 +0100)] 
Merge pull request #776 from keszybz/network-never

Fix handling of --with-network=never and actually apply the setting in dnf as documented

3 years agodnf: when runnning with --network=never, use package metadata cache 776/head
Zbigniew Jędrzejewski-Szmek [Wed, 4 Aug 2021 10:40:51 +0000 (12:40 +0200)] 
dnf: when runnning with --network=never, use package metadata cache

This implements the ability to rebuild packages from cache that was requested
in #700. I don't think it can be said to resolve the issue, since this is
only a partial solution, but useful nonetheless.

3 years agoFix the handling of --with-network
Zbigniew Jędrzejewski-Szmek [Fri, 27 Aug 2021 17:39:30 +0000 (19:39 +0200)] 
Fix the handling of --with-network

The man page describes "never", and the initial parser supported that,
but later on it was treated as a boolean.

3 years agomkosi: remove unnecessary argument specification 768/head
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 12:56:02 +0000 (14:56 +0200)] 
mkosi: remove unnecessary argument specification

'dest' is autoinitialized to the option name.

3 years agomkosi: add ManifestFormat= option to select what is written
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 12:54:27 +0000 (14:54 +0200)] 
mkosi: add ManifestFormat= option to select what is written

The default is 'json'. Specifying the empty list disables writing
of the manifest.

4 years agomkosi: use image output format type when cleaning up stale btrfs devices
Peter Morrow [Thu, 26 Aug 2021 11:39:12 +0000 (12:39 +0100)] 
mkosi: use image output format type when cleaning up stale btrfs devices

Rather than using the presence of the btrfs-progs/tools package as the
indicator to run "btrfs device scan -u" use the output format type.

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
4 years agoDon't let dracut generate implicit devices in hostonly mode
Daan De Meyer [Fri, 20 Aug 2021 13:33:13 +0000 (14:33 +0100)] 
Don't let dracut generate implicit devices in hostonly mode

If hostonly_default_device is enabled, details from the host system devices
leak into the initrd which we want to avoid. For example, this caused the
seclabel mount option to leak into the mount options of my mkosi generated
BTRFS mount options rendering the image unbootable in QEMU.

4 years agoFix pyright typing errors 773/head
Daan De Meyer [Sun, 8 Aug 2021 12:58:25 +0000 (13:58 +0100)] 
Fix pyright typing errors

pyright is an alternative type checker for Python. It's main advantage
over mypy is that it's a lot faster than mypy which makes it a lot more
pleasant to use in VSCode for in-editor type checking.

This commit fixes the typing errors flagged by pyright.

4 years agomkosi: only print the summary when explicitly requested
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 11:58:41 +0000 (13:58 +0200)] 
mkosi: only print the summary when explicitly requested

Originally, the summary was printed whenever a build was done.
With 1f9a758fad3debbdddd2947a19978de3909aabf7, it is only printed
for cached builds. But that is surprising: when I turn on caching,
I suddently get extra output. Let's just print the summary when
requested.

4 years agomkosi: enhance ListAction to filter out duplicates
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 12:02:28 +0000 (14:02 +0200)] 
mkosi: enhance ListAction to filter out duplicates

All the arguments we use it for don't care about the order and
repeats, but it's nicer for the user if we remove duplicates.

Also, let's make it not fail on non-string types, so that it can
be used with enum.Enum.

4 years agobackend: move the OutputFormat conversion helpers to a mix-in class
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 10:18:42 +0000 (12:18 +0200)] 
backend: move the OutputFormat conversion helpers to a mix-in class

No functional change.

4 years agomkosi: print paths relative to the current working directory
Zbigniew Jędrzejewski-Szmek [Thu, 12 Aug 2021 09:08:03 +0000 (11:08 +0200)] 
mkosi: print paths relative to the current working directory

We would print a bunch of paths, and they tend to be quite long,
especially if 'mkosi.output' is used. The output on the console is
supposed to be pretty and easy to read. The user is most likely to
use the path to interact with the file in the same terminal, e.g.
'less mkosi.output/something.manifest', so let's just print the
paths that are underneath the current directory as relative to it.
This makes the output more readable while the paths can still be
used directly in subsequent commands most of the time.

Also, drop "Successfully" from messages: it is a long word, and
superfluous, since we either print an error message or this.

4 years agomkosi: record package list and changelogs in a text file
Zbigniew Jędrzejewski-Szmek [Tue, 10 Aug 2021 20:21:16 +0000 (22:21 +0200)] 
mkosi: record package list and changelogs in a text file

The output is something like this:

"""
Packages: 117
Size:     158417187

--------------------------------------------------------------------------------

SourcePackage: acl-2.3.1-2.fc35.src.rpm
Packages:      acl libacl
Size:          254969

Changelog:
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Mar 16 2021 Kamil Dudka <kdudka@redhat.com> - 2.3.1-1
- new upstream release
...
"""

The idea is that it's easy to diff such files. When the changes are
relatively small, for example between the same distro on different days,
we can easily see what changed, and why. For example, between F34 and F35
I get the following diff:

-Packages: 120
-Size:     164097624
+Packages: 117
+Size:     158417187
...
-SourcePackage: acl-2.3.1-1.fc34.src.rpm
+SourcePackage: acl-2.3.1-2.fc35.src.rpm
 Packages:      acl libacl
-Size:          255585
+Size:          254969

 Changelog:
+* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.1-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
+
 * Tue Mar 16 2021 Kamil Dudka <kdudka@redhat.com> - 2.3.1-1
 - new upstream release
...
-SourcePackage: compat-readline5-5.2-39.fc34.src.rpm
-Packages:      compat-readline5
-Size:          389854
-
-Changelog:
-* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.2-39
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
-
-* Thu Aug 13 2020 Tomas Korbar <tkorbar@redhat.com> - 5.2-38
-- Use make macros
-- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
-
-* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.2-37
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
-
-* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.2-36
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
-
-* Fri Jan 17 2020 Jeff Law <law@redhat.com> - 5.2-35
-- Fix configure test for MUST_REINSTALL_SIGLHANDLERS
-  compromised by LTO
-
-* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.2-34
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
-
-* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.2-33
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
...
-SourcePackage: cracklib-2.9.6-25.fc34.src.rpm
-Packages:      cracklib
-Size:          251906
+SourcePackage: cracklib-2.9.6-26.fc35.src.rpm
+Packages:      cracklib cracklib-dicts
+Size:          10066620

 Changelog:
+* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.9.6-26
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
+
 * Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.9.6-25
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
"""

So when the package changed, we know *why* it changed, and can often
jump directly to the related bugs and such. For example, we now get
cracklib-dicts (yes, very useful), but the package itself didn't change.
Something else pulls it in [1]. Such a diff is useful when trying to
see debug regressions between related builds or minimizing the package
set.

Fixes #748.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1992607

4 years agomkosi: record package list in a json manifest
Zbigniew Jędrzejewski-Szmek [Tue, 10 Aug 2021 20:21:16 +0000 (22:21 +0200)] 
mkosi: record package list in a json manifest

The output is something like this

{
  "packages": [
    {
      "type": "rpm",
      "name": "acl",
      "version": "2.3.1-2.fc35.x86_64"
    },
    {
      "type": "rpm",
      "name": "alternatives",
      "version": "1.19-1.fc35.x86_64"
    },
    {
      "type": "rpm",
      "name": "audit-libs",
      "version": "3.0.3-2.fc35.x86_64"
    },
    ...
  ]
}

This is a partial step towards #700, but has other uses too.

4 years agobackend: classify distributions according to the package type
Zbigniew Jędrzejewski-Szmek [Wed, 11 Aug 2021 14:15:15 +0000 (16:15 +0200)] 
backend: classify distributions according to the package type

Also add a very simple test to check that I didn't mess something up
too badly with all the casts and __new__ twiddling.