]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
3 years agossh: do not print warning if networkd is not running on the host 850/head
Luca Boccassi [Tue, 2 Nov 2021 19:38:41 +0000 (19:38 +0000)] 
ssh: do not print warning if networkd is not running on the host

Tools like VSCode can use 'mkosi ssh' but use pexpect, so don't print
these warnings as it will break them.

3 years agossh: add port parameter
Luca Boccassi [Tue, 2 Nov 2021 01:18:58 +0000 (01:18 +0000)] 
ssh: add port parameter

When NetworkVeth is disabled, allow to simply connect on localhost:.

3 years agossh: optionally connect to ssh-agent
Luca Boccassi [Mon, 1 Nov 2021 23:38:37 +0000 (23:38 +0000)] 
ssh: optionally connect to ssh-agent

If a path to the ssh-agent socket (typically /run/user/1000/gnupg/S.gpg-agent.ssh) is passed,
connect to it to fetch the public key(s) with ssh-add -L and avoid passing
the key(s) manually to ssh.

3 years agodebian: do not try to enable resolved if systemd is not in the package list
Luca Boccassi [Tue, 2 Nov 2021 14:22:55 +0000 (14:22 +0000)] 
debian: do not try to enable resolved if systemd is not in the package list

It will not be installed, so it will fail

3 years agoFix --base-image and --base-packages combination
Luca Boccassi [Thu, 4 Nov 2021 12:59:33 +0000 (12:59 +0000)] 
Fix --base-image and --base-packages combination

args.base_packages defaults to 'True', so it's never 'None', so this
check was always false. Remove it.

3 years agossh: enable ssh.socket on Debian/Ubuntu
Luca Boccassi [Mon, 1 Nov 2021 23:32:20 +0000 (23:32 +0000)] 
ssh: enable ssh.socket on Debian/Ubuntu

On Debian/Ubuntu there's a socket plus templated service for the ssh
server, which works much more nicely than the fixed one. Use it.

3 years agomkosi: add utility functions to create unit dropin configs
Joerg Behrmann [Thu, 4 Nov 2021 13:37:14 +0000 (14:37 +0100)] 
mkosi: add utility functions to create unit dropin configs

3 years agomanifest: record the architecture field separately
Luca Boccassi [Thu, 4 Nov 2021 00:28:06 +0000 (00:28 +0000)] 
manifest: record the architecture field separately

We recently split this out in https://systemd.io/COREDUMP_PACKAGE_METADATA/
and the package-notes tooling, so split it out here too.

3 years agoRemove check=True argument from calls to run()
Daan De Meyer [Tue, 2 Nov 2021 12:27:26 +0000 (12:27 +0000)] 
Remove check=True argument from calls to run()

check=True is the default for our version of run() so let's not pass
check=True explicitly anywhere whenever we call run().

3 years agoMerge pull request #841 from bluca/manifest_debian
Daan De Meyer [Tue, 2 Nov 2021 14:37:07 +0000 (14:37 +0000)] 
Merge pull request #841 from bluca/manifest_debian

manifest: add support for deb distros

3 years agoCall flush() in a few more places
Daan De Meyer [Sun, 31 Oct 2021 21:01:28 +0000 (21:01 +0000)] 
Call flush() in a few more places

Since we never explicitly close these files, sometimes the stuff
we write to them doesn't seem to get flushed which causes the
files to be empty in the output directory. Add calls to flush()
to make sure the files aren't empty when mkosi finishes.

3 years agomanifest: add support for deb distros 841/head
Luca Boccassi [Sat, 16 Oct 2021 20:39:41 +0000 (21:39 +0100)] 
manifest: add support for deb distros

Use 'dpkg-query' and 'apt-get changelog' to get metadata and changelogs

3 years agobackend: optionally capture output with run_workspace_command
Luca Boccassi [Sun, 24 Oct 2021 16:40:22 +0000 (17:40 +0100)] 
backend: optionally capture output with run_workspace_command

3 years agogentoo: support gentoo (#717)
Paymon MARANDI [Thu, 21 Oct 2021 09:51:13 +0000 (05:51 -0400)] 
gentoo: support gentoo (#717)

Flow is the following:

we fetch stage3, untar it into the image's root and run emerge(1) from
within that root tree.

we _append_ our configurations to /etc/portage/env/mkosi.conf users
should not use that file since it, to some extend, documents what was
done during the image creation. users could instead drop-in their conf
file under mkosi.skeleton/etc/portage/env/ (say user.conf) and a pointer
under package.env/ (say user) with:
*/* user.conf

profile:
for now we only support 17.1/no-multilib; arm64 support is on the
roadmap.

3 years agoRevert "gentoo: support gentoo (#717)"
Zbigniew Jędrzejewski-Szmek [Thu, 21 Oct 2021 19:31:58 +0000 (21:31 +0200)] 
Revert "gentoo: support gentoo (#717)"

This reverts commit c4243b5b72c9f7ba08d3644586e49d2bbc0f8457.

The authorship was wrong.

3 years agobin/mkosi: support running from the source checkout
Zbigniew Jędrzejewski-Szmek [Thu, 21 Oct 2021 07:39:50 +0000 (09:39 +0200)] 
bin/mkosi: support running from the source checkout

It is super useful for development if we can use the helper and not
worry about setting PYTHONPATH manually. We can also run mkosi directly after
cloing the repo, without doing any other setup.

3 years agogentoo: support gentoo (#717)
jrun [Thu, 21 Oct 2021 09:51:13 +0000 (05:51 -0400)] 
gentoo: support gentoo (#717)

Flow is the following:

we fetch stage3, untar it into the image's root and run emerge(1) from
within that root tree.

we _append_ our configurations to /etc/portage/env/mkosi.conf users
should not use that file since it, to some extend, documents what was
done during the image creation. users could instead drop-in their conf
file under mkosi.skeleton/etc/portage/env/ (say user.conf) and a pointer
under package.env/ (say user) with:
*/* user.conf

profile:
for now we only support 17.1/no-multilib; arm64 support is on the
roadmap.

3 years agoMerge pull request #846 from bluca/removal_debian
Jörg Behrmann [Thu, 21 Oct 2021 07:57:28 +0000 (09:57 +0200)] 
Merge pull request #846 from bluca/removal_debian

mkosi: implement RemovePackages= option for apt

3 years agomkosi: implement RemovePackages= option for apt 846/head
Luca Boccassi [Tue, 19 Oct 2021 22:09:30 +0000 (23:09 +0100)] 
mkosi: implement RemovePackages= option for apt

3 years agoREADME: skip eol versions and sites in the badge
Zbigniew Jędrzejewski-Szmek [Tue, 19 Oct 2021 20:10:08 +0000 (22:10 +0200)] 
README: skip eol versions and sites in the badge

https://github.com/repology/repology-webapp/issues/117

3 years agoMerge pull request #842 from bluca/sysext_debian
Zbigniew Jędrzejewski-Szmek [Wed, 20 Oct 2021 07:38:43 +0000 (09:38 +0200)] 
Merge pull request #842 from bluca/sysext_debian

sysext: support building deb extensions

3 years agosysext: support building deb extensions 842/head
Luca Boccassi [Sat, 16 Oct 2021 23:27:41 +0000 (00:27 +0100)] 
sysext: support building deb extensions

debootstrap will fail if the root is already populated, so skip it when building
an extension.
While there, skip also other tasks that apply only to the base image (kernel, etc).

3 years agomkosi: do not install base packages in extensions
Luca Boccassi [Tue, 19 Oct 2021 20:41:10 +0000 (21:41 +0100)] 
mkosi: do not install base packages in extensions

3 years agomkosi: do not configure dracut if it is not installed
Luca Boccassi [Tue, 19 Oct 2021 20:40:45 +0000 (21:40 +0100)] 
mkosi: do not configure dracut if it is not installed

3 years agotyping: use Iterator instead of Generator
Zbigniew Jędrzejewski-Szmek [Mon, 18 Oct 2021 20:08:16 +0000 (22:08 +0200)] 
typing: use Iterator instead of Generator

Inspired by https://sethmlarson.dev/blog/2021-10-18/tests-arent-enough-case-study-after-adding-types-to-urllib3:
> Don’t expose Generators unless you want Generator functionality
>
> Generators have additional behaviors over iterables so if the API isn’t meant
> to be used like a generator then it’s best to keep this fact a secret and
> annotate with Iterable[X] instead of Generator[X, None, None].

3 years agoMerge pull request #840 from keszybz/remove-packages
Zbigniew Jędrzejewski-Szmek [Mon, 18 Oct 2021 19:02:17 +0000 (21:02 +0200)] 
Merge pull request #840 from keszybz/remove-packages

Clean up repo management and add RemovePackages= option

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 agoMerge pull request #839 from DaanDeMeyer/revert-nofile
Jörg Behrmann [Fri, 15 Oct 2021 08:37:41 +0000 (10:37 +0200)] 
Merge pull request #839 from DaanDeMeyer/revert-nofile

Remove NOFILE adjustment from nspawn settings

3 years agoRemove NOFILE adjustment from nspawn settings 839/head
Daan De Meyer [Thu, 14 Oct 2021 13:56:58 +0000 (15:56 +0200)] 
Remove NOFILE adjustment from nspawn settings

See https://github.com/systemd/mkosi/pull/837#issuecomment-943362723

3 years agomkosi: Fix autologin configs for different PAM versions
Vishal Verma [Wed, 6 Oct 2021 07:36:19 +0000 (01:36 -0600)] 
mkosi: Fix autologin configs for different PAM versions

Some PAM versions require full /dev/<tty> paths for the autologin setup
done by mkosi, where as others only need the <tty> portion.

If full paths are required, the <tty> only setup breaks, and vice versa.
However having both variants in the config isn't adverse in any way.

As distros upgrade their PAM versions, the distro based checks would
have to constantly play whack-a-mole to switch to the 'prefix-required'
vs. not variations.

Add both variants unconditionally - this way we solve the problem for
all distros, regardless of when they update.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
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.