]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
3 years agoUse fixed comment format distro TODOs 840/head
Zbigniew Jędrzejewski-Szmek [Mon, 18 Oct 2021 12:10:43 +0000 (14:10 +0200)] 
Use fixed comment format distro TODOs

3 years agomkosi: add RemovePackages= option
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 12:03:15 +0000 (14:03 +0200)] 
mkosi: add RemovePackages= option

This is useful to reduce the size of the final image by dropping
packages which are required during the installation, but are not needed
in the final image. So in particular, this includes packages pulled
in as Requires(pre) on rpm-based systems.

Example:
 sudo mkosi -r rawhide-36 --remove-package=shadow-utils

3 years agoman: describe the syntax that Packages= accepts a bit more
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 12:04:49 +0000 (14:04 +0200)] 
man: describe the syntax that Packages= accepts a bit more

What exactly is supported is different between the different distros.
But let's at least list the various options, so that people are aware
of the possibilities. Many people might not even think about the more
esoteric ones.

3 years agofedora: do not pull duplicate repo metadata on rawhide
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 10:19:12 +0000 (12:19 +0200)] 
fedora: do not pull duplicate repo metadata on rawhide

3 years agomkosi: fix grammar in comment
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 10:13:03 +0000 (12:13 +0200)] 
mkosi: fix grammar in comment

3 years agomkosi: simplify repo selection for rpm distros
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 10:12:44 +0000 (12:12 +0200)] 
mkosi: simplify repo selection for rpm distros

We create a custom repo file from scratch, with a bunch of repos.
We would then pass --disablerepo=* --enablerepo=… --enablerepo=…
to dnf to enable the repos we configured. This is pointlessly complicated:
let's instead just enable the repos in the config file we write.
(The config file is only used by the dnf commands we invoke.)

This changes the behaviour of UseHostRepositories=true a bit:
we now use the repos that are enabled on the host, instead of enabling
select repos. I think this actually makes more sense: the list of
repos on the host and their names is something that we have no control
over. So we don't really know which ones to enable. And the user can
still use Repositories= to select some repos. So UseHostRepositories=true
alone means "use host repositories as configured", and
UseHostRepositories=true + Repositories=… means "use the specified
host repositories".

3 years agomkosi: move install_centos_repos_old() right after …_new()
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 09:37:47 +0000 (11:37 +0200)] 
mkosi: move install_centos_repos_old() right after …_new()

I have no idea why they were separated, but it was confusing when editing
the code.

3 years agomkosi: refactor the code to call yum/dnf
Zbigniew Jędrzejewski-Szmek [Fri, 15 Oct 2021 08:42:21 +0000 (10:42 +0200)] 
mkosi: refactor the code to call yum/dnf

Each function to install packages is split in two:
an invoke_[t]dnf() function that accepts a verb and a list of packages,
and an install_packages_[t]dnf() function that calls the first
one with 'install' as the verb.

The idea is to allow other verbs to be called in the future.

I also merged invoke_dnf, invoke_yum, invoke_yum_or_dnf into a single
function. Nowadays, yum is just an aliast to dnf, so they both accept
the same options and provide the same functionality. They actually were
called with different options, but I think this was by mistake: people
added new functionality and forgot to update the callpath for yum.
And if the ancient yum in EPEL doesn't support some option, we can easily
conditionalize on the command name internally.
(Effectively, this changes how yum is called, more options are passed to
it now.)

3 years agonspawn: Copy RLIMIT_CORE and RLIMIT_NOFILE in non-booted nspawn containers
Daan De Meyer [Wed, 13 Oct 2021 10:18:41 +0000 (11:18 +0100)] 
nspawn: Copy RLIMIT_CORE and RLIMIT_NOFILE in non-booted nspawn containers

Avoid surprises by copying open files and coredump limits from the user
running mkosi. Most noteably, this makes sure core dumps in non-booted
mkosi containers actually end up on the host as previously the coredump
size limit was zero in non-booted mkosi nspawn containers which led to
no coredumps being generated at all on the host of processes that dumped
core in the build containers (e.g. tests that raise SIGABRT).

3 years agoMerge pull request #833 from keszybz/manifest-recording-improvements
Zbigniew Jędrzejewski-Szmek [Wed, 13 Oct 2021 20:35:22 +0000 (22:35 +0200)] 
Merge pull request #833 from keszybz/manifest-recording-improvements

Manifest recording improvements

3 years agoMerge pull request #834 from keszybz/fedora-35-no-glibc-minimimal-langpack
Jörg Behrmann [Wed, 13 Oct 2021 15:37:07 +0000 (17:37 +0200)] 
Merge pull request #834 from keszybz/fedora-35-no-glibc-minimimal-langpack

fedora: only add glibc-minimal-langpack for F33-

3 years agofedora: only add glibc-minimal-langpack for F33- 834/head
Zbigniew Jędrzejewski-Szmek [Sat, 11 Sep 2021 06:54:54 +0000 (08:54 +0200)] 
fedora: only add glibc-minimal-langpack for F33-

Since F34, glibc changed from 'Suggests: glibc-all-langpacks' to
'Suggests: glibc-minimal-langpack', so we don't need to do this ourselves.
The advantage is that we avoid one line of output from dnf (about
glibc-minimal-langpack being already installed, which is confusing when
the user didn't request glibc-minimal-langpack explicitly).

3 years agoMerge pull request #836 from keszybz/tools-shell-cleanup
Jörg Behrmann [Tue, 12 Oct 2021 15:46:27 +0000 (17:46 +0200)] 
Merge pull request #836 from keszybz/tools-shell-cleanup

Shell coding cleanup and one documentation update

3 years agoman: mention cpio output 836/head
Zbigniew Jędrzejewski-Szmek [Tue, 12 Oct 2021 10:40:24 +0000 (12:40 +0200)] 
man: mention cpio output

Fixes #835.

3 years agotools/do-a-release: capitalize the commit title
Zbigniew Jędrzejewski-Szmek [Tue, 12 Oct 2021 10:35:52 +0000 (12:35 +0200)] 
tools/do-a-release: capitalize the commit title

That matches the prevalent style.

3 years agotools/do-a-release: stop trying to adjust MKOSI_TAG
Zbigniew Jędrzejewski-Szmek [Tue, 12 Oct 2021 10:34:00 +0000 (12:34 +0200)] 
tools/do-a-release: stop trying to adjust MKOSI_TAG

It was removed in 030873a0fe541df062974708e6afebd669c86232.
(The sed didn't do anything, so it wasn't harmful.)

3 years agotools: make shellcheck clean
Zbigniew Jędrzejewski-Szmek [Tue, 12 Oct 2021 10:30:47 +0000 (12:30 +0200)] 
tools: make shellcheck clean

https://github.com/koalaman/shellcheck/wiki/SC2268 is a good read.
Is says the reason to use x-prefix was fixed in bash in 1996.

3 years agoUse temporary variable to simplify function invocation 833/head
Zbigniew Jędrzejewski-Szmek [Mon, 20 Sep 2021 17:14:27 +0000 (19:14 +0200)] 
Use temporary variable to simplify function invocation

Also let's use normal PEP8-style indentation.

3 years agomanifest: when recording packages, ignore packages from the base image
Zbigniew Jędrzejewski-Szmek [Thu, 9 Sep 2021 11:04:39 +0000 (13:04 +0200)] 
manifest: when recording packages, ignore packages from the base image

This solves the problem that the generated package list included all packages
visible in the combined overlay when building something on top of a base image.
Instead, we want just the stuff that was added in the overlay.

I considered some other approaches:
- use 'dnf history info' to query what the last transacation was.
  The output is human-readable tabular text, and would have to be parsed.
  This could be done, but there's a bigger problem: we don't necessarilly
  know that the last transaction is all that matters. And in fact, as
  raised by mdomonko in #rpm-ecosystem, dnf is not the only way to install
  rpm packages. Using rpm directly also covers direct rpm invocations,
  which could be done from the build scripts.
- look at rpm transaction id. This still has the problem that we don't
  know if the last transaction is all that matters.

So overall, the simple time-based approach should be no worse than the other
ones, and is trivially easy to implement.

3 years agomanifest: change ".packages" suffix to ".changelog"
Zbigniew Jędrzejewski-Szmek [Thu, 9 Sep 2021 10:39:08 +0000 (12:39 +0200)] 
manifest: change ".packages" suffix to ".changelog"

".packages" was inspired by kiwi, where the original idea came from. But the
format is different anyway, and I'm constantly confused by the format name and
suffix being different, even though I wrote the feature. Let's just make them
the same.

3 years agoman: adjust the description of ReadOnly
Zbigniew Jędrzejewski-Szmek [Mon, 11 Oct 2021 18:56:07 +0000 (20:56 +0200)] 
man: adjust the description of ReadOnly

The reader might think that the flag actually enforces this somehow,
but it's just a hint that is easy to ignore.

Inspired by https://github.com/systemd/mkosi/issues/821.

3 years agoSilence sfdisk when refreshing partition tables
Daan De Meyer [Mon, 11 Oct 2021 14:00:34 +0000 (15:00 +0100)] 
Silence sfdisk when refreshing partition tables

Let's try to keep the output minimal when building from cached images.
Currently sfdisk is the only program producing non-trivial amounts of
output when building from cached images so let's pass the --quiet flag
when refreshing partition tables.

3 years agoMerge pull request #802 from keszybz/systexts
Zbigniew Jędrzejewski-Szmek [Mon, 11 Oct 2021 07:50:46 +0000 (09:50 +0200)] 
Merge pull request #802 from keszybz/systexts

Support for creating sysexts

3 years agoReplace dd call by an normal write call 802/head
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 12:53:57 +0000 (14:53 +0200)] 
Replace dd call by an normal write call

We would create a file with 0 padding to force it to a certain size.
This seems fairly ugly, in particular when we later want to use the
blob in other contexts. Also, since 9e0b115e0c, this shouldn't be necessary.
And if we're just copying bytes from a file we already have open, with no
padding, we might just as well do this without forking.

3 years agomkosi: add support for verity also for generated roots
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 11:06:38 +0000 (13:06 +0200)] 
mkosi: add support for verity also for generated roots

In a sysext, I have a squashfs partition that I want to do verity for.
Before this change, we'd fail with an assertion that the root device partition
is not set.

The conditional is bit busy, but I couldn't find a shorter form that
would make mypy happy.

3 years agomkosi: make insert_partition*() return Partition
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 10:50:44 +0000 (12:50 +0200)] 
mkosi: make insert_partition*() return Partition

The return value currently isn't used. By returning the Partition
object we can get access to things like the blockdev path, but also
size, so this is more flexible.

3 years agomkosi: delete overlayfs whiteout files
Zbigniew Jędrzejewski-Szmek [Mon, 6 Sep 2021 08:35:36 +0000 (10:35 +0200)] 
mkosi: delete overlayfs whiteout files

Overlay uses char(0,0) files to mark items that are present in the lower
layers, but were removed in the upper layer. At least for the case
of sysexts, we want to get rid of those. Maybe if other uses of this
feature appear, we might want to make this removal optional.

Hat tip to @brau_ner for explaining what those files are.

3 years agomkosi: split out the fs recursor from find_files()
Zbigniew Jędrzejewski-Szmek [Mon, 6 Sep 2021 08:31:59 +0000 (10:31 +0200)] 
mkosi: split out the fs recursor from find_files()

In preparation for future use… No functional change intended.

3 years agoAdd support for creating "sysexts" with the BaseImage option
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 19:05:58 +0000 (21:05 +0200)] 
Add support for creating "sysexts" with the BaseImage option

The general approach is to first create a base image with the base
set of packages, and then install the new layer on top. To make this
work nicely, the base layer should have --clean-package-metadata=false:

KVER=5.14.0-0.rc5.42.fc35.x86_64
sudo PYTHONPATH=$HOME/src/mkosi python3 -m mkosi --build-env=KERNEL_VERSION=$KVER -f -o initrd-$KVER.d -r rawhide-36 --debug run --format=directory --clean-package-metadata=0
sudo PYTHONPATH=$HOME/src/mkosi python3 -m mkosi --build-env=KERNEL_VERSION=$KVER -f -o initrd-$KVER-ssh.d -r rawhide-36 --debug run --package='!*,openssh-server' --format=gpt_squashfs --clean-package-metadata=1 --base-image=mkosi.output/initrd-$KVER.d

This produces a sysext, except that the release files are missing.
I currently create them through a finalize script. At some point we might
move this functionality into mkosi, but I think it's better to get some
experience with sysexts first.

3 years agomkosi: split out do_mount() from mount_loop()
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 19:00:13 +0000 (21:00 +0200)] 
mkosi: split out do_mount() from mount_loop()

This is in preparation for later changes. No functional change
indended except minor debug output changes.

3 years agoMerge pull request #829 from keszybz/fix-ownership
Zbigniew Jędrzejewski-Szmek [Fri, 8 Oct 2021 14:47:37 +0000 (16:47 +0200)] 
Merge pull request #829 from keszybz/fix-ownership

mkosi: do not set umask(0)

3 years agoMerge pull request #830 from poettering/discard-moa
Zbigniew Jędrzejewski-Szmek [Fri, 8 Oct 2021 14:26:09 +0000 (16:26 +0200)] 
Merge pull request #830 from poettering/discard-moa

mkosi: fix dd sparse mess

3 years agomkosi: when done, dig out all holes (unless we compress anyway) 830/head
Lennart Poettering [Fri, 8 Oct 2021 10:40:13 +0000 (12:40 +0200)] 
mkosi: when done, dig out all holes (unless we compress anyway)

We likely have some NUL bytes in the image, let's explicitly seek them
out and punch holes into them.

3 years agomkosi: discard partition block devices before writing into them with dd's 'sparse...
Lennart Poettering [Fri, 8 Oct 2021 10:39:40 +0000 (12:39 +0200)] 
mkosi: discard partition block devices before writing into them with dd's 'sparse' option

Otherwise there might be the GPT footer lingering in the partition.

3 years agoRefactor the setting of the mode of output files 829/head
Zbigniew Jędrzejewski-Szmek [Thu, 7 Oct 2021 14:22:12 +0000 (16:22 +0200)] 
Refactor the setting of the mode of output files

This doesn't change anything, but is a bit nicer to read.

3 years agomkosi: do not set umask(0)
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 16:04:44 +0000 (18:04 +0200)] 
mkosi: do not set umask(0)

This will have very bad results unless one controls *all* places where
a file can be created. This is possible in systemd and C code, but is
unlikely to work well here, where we have lots of high-level code and
call helpers which can also create files.

So let's use a reasonable value, i.e. 0o022 as the umask during runtime.
This will let us create files with the expected permissions in the image.
After we produce our outputs, we already chown and chmod using the
original umask, so the output have the expected permissions anyway.

Fixes #699.

3 years agorefactoring: add context manager to set umask
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 16:04:44 +0000 (18:04 +0200)] 
refactoring: add context manager to set umask

This is a bit longer, but nicer.

3 years agoMerge pull request #798 from poettering/signed-gpt
Zbigniew Jędrzejewski-Szmek [Thu, 7 Oct 2021 13:10:42 +0000 (15:10 +0200)] 
Merge pull request #798 from poettering/signed-gpt

mkosi: add support for PKCS7 signed images

3 years agoREADME: add repology "versions" badge
Zbigniew Jędrzejewski-Szmek [Wed, 6 Oct 2021 10:01:54 +0000 (12:01 +0200)] 
README: add repology "versions" badge

HTML is used so that alignment can be specified.

3 years agoci: add types-cryptography to CI environment 798/head
Zbigniew Jędrzejewski-Szmek [Tue, 5 Oct 2021 18:12:59 +0000 (20:12 +0200)] 
ci: add types-cryptography to CI environment

3 years agoRename Partition.name to Partition.description
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 12:53:47 +0000 (14:53 +0200)] 
Rename Partition.name to Partition.description

As suggested in https://github.com/systemd/mkosi/pull/798#discussion_r714875622.

3 years agoisort: apply isort
Zbigniew Jędrzejewski-Szmek [Tue, 28 Sep 2021 16:05:15 +0000 (18:05 +0200)] 
isort: apply isort

3 years agoindentation: keep each condition on a separate line
Zbigniew Jędrzejewski-Szmek [Mon, 20 Sep 2021 14:09:09 +0000 (16:09 +0200)] 
indentation: keep each condition on a separate line

We would have two conditions joined by 'and', and we would have
the first operand and half of the second on the first line, and
the remainder of the second operand on multiple lines.

3 years agoAdd Partition and PartitionTable classes
Zbigniew Jędrzejewski-Szmek [Mon, 20 Sep 2021 14:06:27 +0000 (16:06 +0200)] 
Add Partition and PartitionTable classes

The general idea is that those closes collect attributes and information
about the abstract partition table, but are independent of any underlying
block device. The definitions exists indendependently of a block device
and can be applied later on.

Partitions are referred to by enum PartitionIdentifier.

The calculation of the space necessary for those partitions is centralized
in the class, so we don't have multiplace places where we arrive at slightly
different formulas for the expected disk size.

3 years agomkosi: port to python-cryptography
Lennart Poettering [Mon, 13 Sep 2021 15:45:45 +0000 (17:45 +0200)] 
mkosi: port to python-cryptography

This is mostly based on Jörg Behrmann's (@behrmann) work.

3 years agodoc: document Verity=signed
Lennart Poettering [Fri, 10 Sep 2021 20:10:25 +0000 (22:10 +0200)] 
doc: document Verity=signed

3 years agomkosi: optionally, sign verity data
Lennart Poettering [Tue, 7 Sep 2021 20:56:20 +0000 (22:56 +0200)] 
mkosi: optionally, sign verity data

This adds support for creating signed GPT disk images. If Verity=signed
is set this will not only generate and insert Verity data into the
image, but then use the resulting root hash, sign it and include it in
an additional partition. It will also write the resulting PKCS7
signature out into a new .roothash.p7s file.

This scheme is compatible with kernel 5.4's PKCS7 signature logic for
dm-verity: the resulting .p7s file can be passed as-is to the kernel (or
systemd's RootHashSignature= setting).

The partition this embedds contains a simple JSON object containing
three fields. The verity root hash, the PKCS7 data (i.e. the same data
as in the .p7s file, but in base64), and SHA256 fingerprint of the
signing key. This partition is supposed to be read by the image
dissection logic of systemd, to implement signed single-file images.
(The corresponding PR for systemd I am still working on).

This opens up two avenues for image verification:

1. Everything in one file: the single, "unified" GPT disk image contains
   three partitions, for payload data, verity data and verity signature.

2. Split out: root hash and its signature are stored in two "sidecar"
   files.

(Of course I'd personally always go the "unified" way, but given the
RootHashSignature= logic exists already, and it's easy to support, let's
support it.)

This uses the key already used for doing secureboot image signing.
Conceptually this makes a ton of sense: we sign the same stuff here
after all: the contents of the image, supporting two different
entrypoints to the image: one via UEFI booting the image, and once for
attaching directly to an image from a running system. Admittedly, the
"mkosi.secure-boot.key" and "mkosi.secure-boot.certificate" monikers for
this key pair might be a bit suprising though.

Corresponding PR in systemd is:

https://github.com/systemd/systemd/pull/20691

3 years agoMove PartitionTable to backend
Zbigniew Jędrzejewski-Szmek [Wed, 15 Sep 2021 13:46:31 +0000 (15:46 +0200)] 
Move PartitionTable to backend

I think we should split out utils.py or something later on. But let's
at least move it out of the main file.

3 years agoMerge pull request #820 from keszybz/printf-modernization
Jörg Behrmann [Tue, 5 Oct 2021 12:49:42 +0000 (14:49 +0200)] 
Merge pull request #820 from keszybz/printf-modernization

Modernization of string formatting syntax and set construction

3 years agotests: convert remaining printf-style formatting 820/head
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 09:05:45 +0000 (11:05 +0200)] 
tests: convert remaining printf-style formatting

For some reason, pyupgrade misses those.

3 years agotree-wide: use run(text=…)
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 09:02:46 +0000 (11:02 +0200)] 
tree-wide: use run(text=…)

It is supported since Python 3.7, and we don't support anything lower.

3 years agobackend: drop unecessary quoting and type name
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 08:57:05 +0000 (10:57 +0200)] 
backend: drop unecessary quoting and type name

__future__.annotations was added, so we don't need this any more.

3 years agotree-wide: modernize string formatting calls
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 08:56:11 +0000 (10:56 +0200)] 
tree-wide: modernize string formatting calls

Pyupgrade + some manual fixups.

3 years agotests: modernize syntax
Zbigniew Jędrzejewski-Szmek [Mon, 4 Oct 2021 08:53:25 +0000 (10:53 +0200)] 
tests: modernize syntax

Done with https://github.com/asottile/pyupgrade.

3 years agoMerge pull request #822 from behrmann/appeasepyright
Zbigniew Jędrzejewski-Szmek [Tue, 5 Oct 2021 07:58:09 +0000 (09:58 +0200)] 
Merge pull request #822 from behrmann/appeasepyright

Appease pyright

3 years agotyping: appease pyright and disable mypy unusued import warning 822/head
Joerg Behrmann [Mon, 4 Oct 2021 15:17:06 +0000 (17:17 +0200)] 
typing: appease pyright and disable mypy unusued import warning

Since pyright reuses the same comments to ignore types, one can get into
unsatisfiable situations, where one type checker accepts something but the other
doesn't. At this point we only have three instances of type ignore hints anyway,
sol et's relax our mypy settings somewhat, so that we can shut up pyright, when
necessary.

3 years agomkosi: explicitly make paths passed to the environment strings
Joerg Behrmann [Mon, 4 Oct 2021 15:16:22 +0000 (17:16 +0200)] 
mkosi: explicitly make paths passed to the environment strings

3 years agoMerge pull request #819 from behrmann/shellcheck
Zbigniew Jędrzejewski-Szmek [Mon, 27 Sep 2021 12:55:05 +0000 (14:55 +0200)] 
Merge pull request #819 from behrmann/shellcheck

Add shellcheck for embedded shell scripts

3 years agoci: add shellcheck 819/head
Joerg Behrmann [Thu, 23 Sep 2021 16:32:45 +0000 (18:32 +0200)] 
ci: add shellcheck

3 years agomkosi: make shellscripts we ship shellcheck clean
Joerg Behrmann [Thu, 23 Sep 2021 16:32:31 +0000 (18:32 +0200)] 
mkosi: make shellscripts we ship shellcheck clean

3 years agodracut: make sure images with IMAGE_VERSION but without IMAGE_ID can boot
Lennart Poettering [Thu, 23 Sep 2021 09:23:22 +0000 (11:23 +0200)] 
dracut: make sure images with IMAGE_VERSION but without IMAGE_ID can boot

If an image version is set but no image ID mkosi's table currently
places generic labels in the partition labels, instead of the image ids
(because we have none...). This means we cannot refrence the root
partition via root=PARTLABEL=… on the kernel cmdline. Hence do not do
that.

This change ensures we don't try to use IMAGE_ID-based root=PARTLABEL=
kernel cmdline swtches without IMAGE_ID being set.

(Note that the main reason IMAGE_ID/IMAGE_VERSION exists is to allow
versioned setups, i.e. where multiple versions of the same thing exist.
In such a case it's important to reference the right rootfs version that
matches the whole setup we are building here. But if IMAGE_ID isn't set
then this multi-version logic is not desired and we can assume that only
a single version of the OS is in the partition table, and thus rely on
gpt-auto-generators automatic root file system discovery)

3 years agoalma: add support for alma linux 8 with and without EPEL
Dell Green [Mon, 20 Sep 2021 13:11:56 +0000 (14:11 +0100)] 
alma: add support for alma linux 8 with and without EPEL

- Closes #814

3 years agoMerge pull request #817 from keszybz/cleanups
Jörg Behrmann [Mon, 20 Sep 2021 20:50:27 +0000 (22:50 +0200)] 
Merge pull request #817 from keszybz/cleanups

Two trivial cleanups

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