]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
2 years agomkosi: put various script-related status lines together 1246/head
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 13:13:31 +0000 (15:13 +0200)] 
mkosi: put various script-related status lines together

For some reason the build script was described quite far from the
other scripts. Since 19a989fdafe3b50b7c6629efa64e6e4b1fa0c31a the same
environment is used for all scripts, so the "Script Environment" line
is now under all scripts, since it applies to all of them.

2 years agomkosi: verify scripts after parsing config, show status in summary
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 13:01:55 +0000 (15:01 +0200)] 
mkosi: verify scripts after parsing config, show status in summary

We would refuse a script if not found or not executable immediately when
parsing the argument. But only the last specified script matters, so it's
better to delay the check: in initial parsing store the path, and later check
that it exists and matches the relevant criteria, at the time when we also
check the outputs.

Similarly for tree inputs: they are checked at this time too.
This fixes #1167.

Instead of trying to generate error messages, just reuse normal Python
exceptions: i.e. os.access() is replaced by open(). This way we don't need to
come up with error messages for various conditions and possibly get them wrong.

Rework status command to show status of inputs and scripts:

$ bin/mkosi --extra-tree={./missing,/root/inaccessible} --{prepare,build,finalize,postinst}-script=/etc/fstab summary
COMMANDS:
                      verb: summary
                   cmdline:
...
CONTENT:
               Extra Trees: /home/zbyszek/src/mkosi/missing (No such file or directory)
                            /root/inaccessible (Permission denied)
            Skeleton Trees: none
...
              Build Script: /etc/fstab (Not executable)
...
        Postinstall Script: /etc/fstab (Not executable)
            Prepare Script: /etc/fstab (Not executable)
           Finalize Script: /etc/fstab (Not executable)
...

Colors are used to draw the eye to the problematic lines.

2 years agomkosi: use normal print stmts for summary
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 10:03:18 +0000 (12:03 +0200)] 
mkosi: use normal print stmts for summary

This is simpler and writes to stdout as we should, not stderr.

2 years agoMerge pull request #1151 from qdeslandes/map_permissions
Jörg Behrmann [Thu, 27 Oct 2022 11:01:44 +0000 (13:01 +0200)] 
Merge pull request #1151 from qdeslandes/map_permissions

Implement support for generated files ownership management.

2 years agoMerge pull request #1243 from keszybz/argparse-tweaks
Daan De Meyer [Thu, 27 Oct 2022 10:55:16 +0000 (12:55 +0200)] 
Merge pull request #1243 from keszybz/argparse-tweaks

Disallow option abbreviations and stop dumping usage information on error

2 years agoUpdate NEWS.md 1151/head
Quentin Deslandes [Thu, 27 Oct 2022 09:54:30 +0000 (11:54 +0200)] 
Update NEWS.md

2 years agoUse nspawn's rootidmap option for --bind mount
Quentin Deslandes [Tue, 18 Oct 2022 17:11:42 +0000 (19:11 +0200)] 
Use nspawn's rootidmap option for --bind mount

Bind-mount directories with nspawn's rootidmap option to prevent files
ownership discrepancies: files (and directories) created from within the
container in the mounted directory will be owned by the owner of the
directory on the backing filesystem.

This means, mkosi-generated directories and owner by any other user that
root won't be polluted by root-owned files and folders once the
container is stopped.

2 years agochown mkosi-generated directories
Quentin Deslandes [Tue, 18 Oct 2022 17:10:32 +0000 (19:10 +0200)] 
chown mkosi-generated directories

Change the owner of directories created by mkosi, unless --no-chown is
used. Directories owner will be set to SUDO_UID or PKEXEC_UID if
defined, or to current UID otherwise.

2 years agoAdd --noplugins when calling dnf
Daan De Meyer [Thu, 27 Oct 2022 08:09:45 +0000 (10:09 +0200)] 
Add --noplugins when calling dnf

Let's isolate image builds using dnf from the host a bit more by
disabling all plugins. For example, plugins such as versionlock
can interfere with the version of packages installed in the image
which we want to avoid.

2 years agomkosi: supress printing of argparse help on error 1243/head
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 08:39:11 +0000 (10:39 +0200)] 
mkosi: supress printing of argparse help on error

We build a precise error message, but then bury it under a wall of text
produced by print_usage(). The printing of help (or some subset of it) on
parsing error is just useless. Most likely the user made a typo in an option,
and printing a few dozen lines (and more in the future) of unhelpful
semi-related information is counterproductive.

I'm surprised that argparse doesn't make this configurable, but looking at the
code, it seems that the behaviour is hardcoded. Docs and stackoverflow also
yield no hints.

2 years agomkosi: disallow parameter abbreviations
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 08:31:37 +0000 (10:31 +0200)] 
mkosi: disallow parameter abbreviations

For interactive use, we have both short options and tab-completion.
Abbreviated options are problematic because of forward-compatibility:
if we add more options in the future, an older abbreviation might become
non-unique and stop working.

2 years agomkosi: do not build a temporary dictionary for kwargs
Zbigniew Jędrzejewski-Szmek [Thu, 27 Oct 2022 08:27:19 +0000 (10:27 +0200)] 
mkosi: do not build a temporary dictionary for kwargs

Let's use the usual method for passing mixed inherited and local keyword args.
We don't need to put the argument names in quotes so this looks nicer. Also,
if we were to make a mistake and pass the same kwargs in two places, previously
the local assignment would silently override the other value. But that seems
inverted because now the base class overwrites something specified by the daughter
class. Anyway, it's better to throw an error, which we now will do:

TypeError: argparse.ArgumentParser.__init__() got multiple values for keyword argument '…'

2 years agoRevert "mkosi: Always use the embedded default version when no release is specified"
Zbigniew Jędrzejewski-Szmek [Wed, 26 Oct 2022 21:16:56 +0000 (23:16 +0200)] 
Revert "mkosi: Always use the embedded default version when no release is specified"

This reverts commit 093d48a97b8211ff549f78f2b3b2ef77fcd45573.

I used mkosi without any explicit distro/version parameters and was surprised
that it built for Fedora 36 after successfully detecting that it's running on
Fedora 37. Using the host version is more likely to be what users expect, and
also avoids the awkward issue that when we hardcode some default version, this
version is likely to be "wrong" (not the latest) until both the distro and we
make a release.

Looking at this more generally, if we have some constant config that doesn't
specify the distro version, we have three possible source of the version
default: host distro version, latest version that was known was mkosi was
released, and actual latest released distro version. It is nice to use the
first option, because that is what users generally expect, and also this makes
mkosi "stable", i.e. we may upgrade it at any time and users will not observe
unexpected changes in defaults. This makes mkosi closer to guidelines for
upgrades in stable distros, see
https://docs.fedoraproject.org/en-US/fesco/Updates_Policy/#stable-releases.

093d48a97b8211ff549f78f2b3b2ef77fcd45573 was aiming for "consistent results",
but this gives consistency with the wrong thing. For a normal user, the host
distro version would never change "unexpectedly", and in fact it is expected
that the defaults of programs change when the host distro is upgraded and not
at any other time. Mkosi itself should provide stable and backwards-compatible
behaviour over releases.

2 years agocode: split out the handling of exceptions to a helper
Zbigniew Jędrzejewski-Szmek [Tue, 13 Sep 2022 15:58:13 +0000 (16:58 +0100)] 
code: split out the handling of exceptions to a helper

This is a bit of error-handling logic that shouldn't obscure the
main logic of the program.

2 years agoAdding custom retry amount to Machine.run()
gsegatti [Wed, 19 Oct 2022 02:56:18 +0000 (23:56 -0300)] 
Adding custom retry amount to Machine.run()

This PR aims to introduce a variable "retry_amount" passed via Machine's constructor.
This variable will define how many times a command will attempt to run when using a VM.
Default value remain as 30 if not explicitly set.

2 years agossh: fix copy_file for authorized_keys
William Roberts [Wed, 26 Oct 2022 15:46:21 +0000 (10:46 -0500)] 
ssh: fix copy_file for authorized_keys

When attempting to copy the public key to the remote images
authorized_keys file, the parent path does not exist and the following
exception is thrown[1]:
‣  Generating SSH key pair…
‣  (Unmounting image)
‣  (Detaching /dev/loop17)
Traceback (most recent call last):
  File "/home/wcrobert/workspace/mkosi/mkosi/__init__.py", line 7357, in setup_ssh
    copy_file(f"{f.name}.pub", authorized_keys)
  File "/home/wcrobert/workspace/mkosi/mkosi/__init__.py", line 614, in copy_file
    with open_close(newpath, os.O_WRONLY | os.O_CREAT | os.O_EXCL, st.st_mode) as newfd:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/wcrobert/workspace/mkosi/mkosi/__init__.py", line 571, in open_close
    fd = os.open(path, flags | os.O_CLOEXEC, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/var/tmp/mkosi-_0v_4emp/root/root/.ssh/authorized_keys'

The path only existed up to "/var/tmp/mkosi-_0v_4emp/root", thus a mkdir
with -p semantics is required to create the full path, add that in.

[1] Note line numbers are off due to having some print's scattered
through the code for debugging.

Fixes: #1238
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2 years agofedora: move rpmdb content before replacing with symlink
Luke Asgill [Fri, 26 Aug 2022 02:39:57 +0000 (12:39 +1000)] 
fedora: move rpmdb content before replacing with symlink

Fixes #1113: building a Fedora 36 image using mkosi 13 on Fedora 35 results in
circular symlinks between /var/lib/rpm and /usr/lib/sysimage/rpm.

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2 years agoMake inserted root or /usr partition at least as big as RootSize
Michael A Cassaniti [Thu, 28 Jul 2022 12:02:09 +0000 (22:02 +1000)] 
Make inserted root or /usr partition at least as big as RootSize

When using SquashFS in particular, the size of the partition inserted will
always be the size of the SquashFS image. This change allows the partition
size to be set which allows for future growth.

2 years agomkosi: add new "pcrphase" tool to dracut initrds
Lennart Poettering [Wed, 21 Sep 2022 10:04:56 +0000 (12:04 +0200)] 
mkosi: add new "pcrphase" tool to dracut initrds

And lets sort the list of dracut additions again.

This is a companion to https://github.com/systemd/systemd/pull/24771,
and should probably be merged only after that got merged.

(If it's merged before it doesn't have any ill effects, but it's pretty
useless...)

2 years agoMerge pull request #1227 from DaanDeMeyer/fixes
Daan De Meyer [Mon, 17 Oct 2022 06:38:33 +0000 (08:38 +0200)] 
Merge pull request #1227 from DaanDeMeyer/fixes

Don't cache bootloader installation

2 years agoStreamline basic config installation 1227/head
Daan De Meyer [Fri, 14 Oct 2022 20:05:24 +0000 (22:05 +0200)] 
Streamline basic config installation

Let's do our basic config installation a little earlier in the build
to allow users the opportunity to override it if needed. Also, rename
all the functions for more consistency.

2 years agoDon't cache bootloader installation
Daan De Meyer [Fri, 14 Oct 2022 19:41:41 +0000 (21:41 +0200)] 
Don't cache bootloader installation

bootctl might configure itself differently depending on what's on
the rest of the system. If we run it as part of the cached image
build, we're doing the installation with files missing that might
influence the end result, so let's not do the installation as part
of the cached image build.

2 years agoMerge pull request #1213 from behrmann/automeasure
Daan De Meyer [Thu, 13 Oct 2022 15:12:30 +0000 (17:12 +0200)] 
Merge pull request #1213 from behrmann/automeasure

Rename --measure option and add a special value auto

2 years agoCopy also .git file for submodules
Fabian Wiesel [Mon, 10 Oct 2022 11:51:53 +0000 (11:51 +0000)] 
Copy also .git file for submodules

To properly get the commit history of a submodule,
we need the .git file pointing to the submodule
in the top-level git directory

2 years agoChunk partition insert using sendfile because sendfile has a maximum transfer size
Michael A Cassaniti [Fri, 7 Oct 2022 06:14:39 +0000 (17:14 +1100)] 
Chunk partition insert using sendfile because sendfile has a maximum transfer size

2 years agoinitrd can be versioned in Debian
Luca Boccassi [Sun, 9 Oct 2022 20:09:31 +0000 (21:09 +0100)] 
initrd can be versioned in Debian

In Bookworm the initrd is installed with the same version suffix
as the directory, for reasons. Check for both.

2 years agoBuild bootable images into directory
Pyfisch [Sun, 9 Oct 2022 09:04:38 +0000 (11:04 +0200)] 
Build bootable images into directory

closes #1214

2 years agoSpecify RPM dbpath when recording packages
Malte Poll [Fri, 30 Sep 2022 19:27:42 +0000 (21:27 +0200)] 
Specify RPM dbpath when recording packages

Workaround for Debian based hosts shipping a patch to store the rpmdb under ~/.
The rpmdb is moved to where the guest expects it
(/usr/lib/sysimage/rpm or /var/lib/rpm)
So rpm on Debian has to be told to search in that location.

2 years agorefactor mount_cache for better readability
Joerg Behrmann [Fri, 16 Sep 2022 16:15:11 +0000 (18:15 +0200)] 
refactor mount_cache for better readability

2 years agoMake SignExpectedPCR tri-valued 1213/head
Joerg Behrmann [Mon, 3 Oct 2022 14:55:57 +0000 (16:55 +0200)] 
Make SignExpectedPCR tri-valued

This makes SignEpectedPCR a tri-valued option using aspecial value "auto" in
addition to boolean values, where it will check whether cryptography is
importable and systemd-measure in the PATH and value True in that case and False
else.

For a True value it checks both conditions and fails hard if they are not met.

The checks are kept in the CLI definition so that what comes out stays a clean
boolean value and doesn't leak any decisions into layers further down. This
unfortunately necesitates a custom default value in the tests, so that they are
robust against what's installed on the system they run on and also needs to use
a function for the argparse type=, since actions are not called for every value.

2 years agorename --measure to --sign-expected-pcr
Joerg Behrmann [Mon, 3 Oct 2022 14:23:38 +0000 (16:23 +0200)] 
rename --measure to --sign-expected-pcr

2 years agoFix crash in setup_package_cache
Pyfisch [Sun, 2 Oct 2022 20:22:58 +0000 (22:22 +0200)] 
Fix crash in setup_package_cache

Otherwise mkosi crashes if config.cache_path is None.

2 years agoMerge pull request #1200 from behrmann/postswtmp2
Daan De Meyer [Fri, 30 Sep 2022 12:57:08 +0000 (14:57 +0200)] 
Merge pull request #1200 from behrmann/postswtmp2

Guard cryptography imports

2 years agoMerge pull request #1208 from behrmann/runnoexec
Daan De Meyer [Fri, 30 Sep 2022 12:56:21 +0000 (14:56 +0200)] 
Merge pull request #1208 from behrmann/runnoexec

Use run instead of execvp in genkey command

2 years agoMake generate_secure_boot_key use run instead of os.execvp 1208/head
Joerg Behrmann [Fri, 30 Sep 2022 09:52:38 +0000 (11:52 +0200)] 
Make generate_secure_boot_key use run instead of os.execvp

2 years agouse os.fspath instead of str to stringify run arguments
Joerg Behrmann [Fri, 30 Sep 2022 09:51:49 +0000 (11:51 +0200)] 
use os.fspath instead of str to stringify run arguments

str and bytes pass through it as is, but things supporting the __fspath__
protocol, like pathlib.Path, will use that.

2 years agoubuntu: Replace platform.machine() check with args.architecture check
Marek Vasut [Sun, 25 Sep 2022 04:39:39 +0000 (06:39 +0200)] 
ubuntu: Replace platform.machine() check with args.architecture check

Test args.architecture instead when selecting the ports.ubuntu.com .
The args.architecture will default to "aarch64" if running on a aarch64
machine and respect command line --architecture switch as well. This is
necessary in case the mkosi is generating foreign architecture container
(e.g. mkosi on amd64 generates arm64 container).

Fix security.ubuntu.com URL, which has to point to ubuntu-ports for
aarch64 machines.

2 years agoarchlinux: Replace platform.machine() check with args.architecture check
Marek Vasut [Sun, 25 Sep 2022 23:12:08 +0000 (01:12 +0200)] 
archlinux: Replace platform.machine() check with args.architecture check

Test args.architecture instead when selecting the mirror.archlinuxarm.org .
The args.architecture will default to "aarch64" if running on a aarch64
machine and respect command line --architecture switch as well. This is
necessary in case the mkosi is generating foreign architecture container
(e.g. mkosi on amd64 generates arm64 container).

Fix Architecture parameter passed into pacman.conf to permit generation
of foreign architecture containers.

The test on debian/sid amd64 used to generate archlinuxarm aarch64
container looks something like this:
1) Setup pacman
```
$ pacman-key --init
```
- Download http://mirror.archlinuxarm.org/aarch64/core/archlinuxarm-keyring-20140119-2-any.pkg.tar.xz
- Verify the download
- Extract keys into /usr/share/keyrings
```
$ pacman-key --populate
$ pacman-key --populate archlinuxarm
$ pacman-key --refresh-keys
```
2) Run `mkosi --architecture aarch64 ...`

2 years agomake measuring an option 1200/head
Joerg Behrmann [Thu, 22 Sep 2022 15:44:28 +0000 (17:44 +0200)] 
make measuring an option

2 years agoguard cryptography imports
Joerg Behrmann [Thu, 22 Sep 2022 08:37:05 +0000 (10:37 +0200)] 
guard cryptography imports

2 years agoFix undefined PIPE issue
Daan De Meyer [Thu, 22 Sep 2022 08:08:23 +0000 (10:08 +0200)] 
Fix undefined PIPE issue

2 years agoMerge pull request #1198 from DaanDeMeyer/swtpm
Lennart Poettering [Wed, 21 Sep 2022 20:25:07 +0000 (22:25 +0200)] 
Merge pull request #1198 from DaanDeMeyer/swtpm

swtpm followups

2 years agoAdd Fedora 38 and Fedora 39 signing key
Malte Poll [Wed, 21 Sep 2022 15:49:57 +0000 (17:49 +0200)] 
Add Fedora 38 and Fedora 39 signing key

2 years agomkosi: pre-calculate expected PCR 11 values, and sign them, and include in unified...
Lennart Poettering [Wed, 21 Sep 2022 10:05:16 +0000 (12:05 +0200)] 
mkosi: pre-calculate expected PCR 11 values, and sign them, and include in unified kernel image

2 years agoSoothe some CodeQL warnings
Joerg Behrmann [Wed, 21 Sep 2022 15:02:47 +0000 (17:02 +0200)] 
Soothe some CodeQL warnings

2 years agoRename run_..._cmdline() functions to run_..._setup() 1198/head
Daan De Meyer [Wed, 21 Sep 2022 16:41:20 +0000 (18:41 +0200)] 
Rename run_..._cmdline() functions to run_..._setup()

Better name since these functions end up doing more than just
constructing the command line to be used.

2 years agoStart swtpm from within run_qemu_cmdline()
Daan De Meyer [Wed, 21 Sep 2022 16:38:24 +0000 (18:38 +0200)] 
Start swtpm from within run_qemu_cmdline()

Let's always start swtpm when we're going to run a qemu machine.
To avoid callers having to do the setup themselves, let's start
swtpm from within run_qemu_cmdline(). We can reuse the context
stack inside run_qemu_cmdline() to manage the start_swtpm()
context.

2 years agomkosi: invoke qemu with swtpm, it's 2022!
Lennart Poettering [Wed, 21 Sep 2022 10:40:32 +0000 (12:40 +0200)] 
mkosi: invoke qemu with swtpm, it's 2022!

If we find swtpm around we'll use it, otherwise not.

Fixes: #1191
2 years agoci: use CodeQL instead of LGTM
Frantisek Sumsal [Wed, 14 Sep 2022 09:33:51 +0000 (11:33 +0200)] 
ci: use CodeQL instead of LGTM

As LGTM is going to be shut down by EOY[0], let's move the code scanning to
CodeQL as recommended. Thanks to GH integration the results from such
scans will be shown both in the respective PR and in the Security ->
Code Scanning tab[1].

[0] https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/
[1] https://github.com/systemd/mkosi/security/code-scanning

2 years agoMerge pull request #1190 from DaanDeMeyer/drop-nspawn-executable
Jörg Behrmann [Wed, 21 Sep 2022 09:12:13 +0000 (11:12 +0200)] 
Merge pull request #1190 from DaanDeMeyer/drop-nspawn-executable

Allow single files to be used with --extra-search-paths

2 years agoDrop MKOSI_NSPAWN_EXECUTABLE 1190/head
Daan De Meyer [Wed, 21 Sep 2022 07:01:09 +0000 (09:01 +0200)] 
Drop MKOSI_NSPAWN_EXECUTABLE

Now that --extra-search-paths supports single files, there's no
need anymore for MKOSI_NSPAWN_EXECUTABLE so let's drop it.

2 years agoAllow single files to be used with --extra-search-paths
Daan De Meyer [Wed, 21 Sep 2022 07:25:26 +0000 (09:25 +0200)] 
Allow single files to be used with --extra-search-paths

Sometimes we just want to use one file from a directory of files
with --extra-search-paths. Let's make sure we support this by putting
a symlink to the file in a temporary directory and adding that directory
to PATH.

2 years agoNo longer mention black and fix indentation
Pyfisch [Sun, 11 Sep 2022 12:25:14 +0000 (14:25 +0200)] 
No longer mention black and fix indentation

Mkosi uses 4 spaces for indentation, fix 2 functions with 8 spaces.
Since #779 formatting with black wasn't enforced but still mentioned as required in README.

2 years agoStart nspawn containers with read/write permissions
Pyfisch [Sun, 11 Sep 2022 18:36:26 +0000 (20:36 +0200)] 
Start nspawn containers with read/write permissions

Don't set the --read-only flag for nspawn containers if just the root partition is read-only.
Don't set the --volatile=overlay flag for images created with usr-only or a generated root.
If the --volatile=overlay flag is set the container won't find the shell or init program.

2 years agoRun mkosi serve without root
Pyfisch [Thu, 15 Sep 2022 15:03:49 +0000 (17:03 +0200)] 
Run mkosi serve without root

If the output image already exists mkosi serve works without root.
Otherwise an error message is shown (as before).

Show the correct URL where the artifacts are served.

2 years agoOpenMandriva no need to run disable_pam_securetty
Tomasz Paweł Gajc [Wed, 14 Sep 2022 19:49:42 +0000 (21:49 +0200)] 
OpenMandriva no need to run disable_pam_securetty

2 years agoInstall package manager by default
Daan De Meyer [Sat, 10 Sep 2022 11:53:49 +0000 (13:53 +0200)] 
Install package manager by default

Currently, we have package managers installed by default in Arch/Ubuntu
but not in Fedora/CentOS and variants. Let's make this more consistent
by making a package manager available by default in all distributions.

2 years agoAdd note to MkosiConfig documentation
Pyfisch [Fri, 9 Sep 2022 14:30:29 +0000 (16:30 +0200)] 
Add note to MkosiConfig documentation

2 years agoCreate environment in MkosiState
Pyfisch [Fri, 9 Sep 2022 12:01:04 +0000 (14:01 +0200)] 
Create environment in MkosiState

Initialize the MkosiState environment from MkosiConfig,
then include the additional variables IMAGE_ID and IMAGE_VERSION.

2 years agoInclude image ID and version in environment variables
Michael A Cassaniti [Fri, 19 Aug 2022 02:53:41 +0000 (12:53 +1000)] 
Include image ID and version in environment variables

This change will allow the image ID and image version arguments to be referenced
in scripts (prepare, build, postinst, finalize). This is useful for substituting
or adding into relevant files.

This change also moves the environment from MkosiConfig to MkosiState.

2 years agofedora: Drop fedora 34 workaround
Daan De Meyer [Sat, 10 Sep 2022 11:24:49 +0000 (13:24 +0200)] 
fedora: Drop fedora 34 workaround

Fedora 34 is not supported anymore, so let's drop the workaround

2 years agodebian/ubuntu: Increase apt recursive limit
Marek Vasut [Thu, 1 Sep 2022 00:46:21 +0000 (20:46 -0400)] 
debian/ubuntu: Increase apt recursive limit

With debian 11.4 amd64 host, mkosi fails with the following:
"
Chrooting into /var/tmp/mkosi-_elvunh3/root/
dpkg: error: cannot stat pathname '/tmp/apt-dpkg-install-LyrJgL': No such file or directory
"
By increasing the recursive limit, the parameter --recursive
is not passed to dpkg and the list of packages is passed to
dpkg on a command line instead of in the /tmp/apt-dpkg-install
temp file, which also avoids the aforementioned failure. There
seem to be no way to explicitly disable passing the --recursive
parameter to dpkg via apt options.

However, this is still a workaround. It is not clear why the
temp files are not found. Furthermore, add Debug::pkgDPkgPM=1
apt option makes this problem go away as well, which might
indicate some sort of race condition.

2 years agoMerge pull request #1176 from DaanDeMeyer/know-arg-stdout-devnull
Daan De Meyer [Thu, 8 Sep 2022 09:17:52 +0000 (11:17 +0200)] 
Merge pull request #1176 from DaanDeMeyer/know-arg-stdout-devnull

Send stdout to devnull when checking nspawn known arg

2 years agoMerge pull request #1165 from DaanDeMeyer/fixes
Daan De Meyer [Thu, 8 Sep 2022 09:17:34 +0000 (11:17 +0200)] 
Merge pull request #1165 from DaanDeMeyer/fixes

Follow ups for the MkosiConfig/MkosiState split

2 years agoMake sure nspawn doesn't try to start a container in nspawn_knows_arg() 1176/head
Daan De Meyer [Thu, 8 Sep 2022 08:24:04 +0000 (10:24 +0200)] 
Make sure nspawn doesn't try to start a container in nspawn_knows_arg()

2 years agoSend stdout to devnull when checking nspawn known arg
Daan De Meyer [Thu, 8 Sep 2022 08:17:58 +0000 (10:17 +0200)] 
Send stdout to devnull when checking nspawn known arg

We only need stderr, let's send any output printed to stdout
to /dev/null

2 years agoUse 0 as the default value for partition sizes instead of None 1165/head
Daan De Meyer [Sun, 4 Sep 2022 19:06:54 +0000 (21:06 +0200)] 
Use 0 as the default value for partition sizes instead of None

2 years agoDerive cleanup value from state
Daan De Meyer [Sun, 4 Sep 2022 13:13:53 +0000 (15:13 +0200)] 
Derive cleanup value from state

2 years agoMove for_cache into MkosiState
Daan De Meyer [Sun, 4 Sep 2022 12:56:52 +0000 (14:56 +0200)] 
Move for_cache into MkosiState

2 years agoPass MkosiState directly to more functions
Daan De Meyer [Sun, 4 Sep 2022 12:13:42 +0000 (14:13 +0200)] 
Pass MkosiState directly to more functions

We have quite a few functions that take both state.config and
state.root as arguments. Instead of passing these arguments separately,
let's just pass the state directly to these functions.

2 years agoMove MkosiConfig into MkosiState
Daan De Meyer [Fri, 2 Sep 2022 20:38:31 +0000 (22:38 +0200)] 
Move MkosiConfig into MkosiState

Avoid having to pass both around by just making the config a member
of the state.

2 years agoMove workspace and a few related functions into MkosiState
Daan De Meyer [Fri, 2 Sep 2022 20:01:16 +0000 (22:01 +0200)] 
Move workspace and a few related functions into MkosiState

Allows us to get rid of the workspace(root) function which was
always a hack to avoid passing too many arguments around.

2 years agoDo dnf setup outside of centos repo functions
Daan De Meyer [Fri, 2 Sep 2022 19:45:01 +0000 (21:45 +0200)] 
Do dnf setup outside of centos repo functions

2 years agoMake MkosiConfig a frozen dataclass
Daan De Meyer [Fri, 2 Sep 2022 14:20:54 +0000 (16:20 +0200)] 
Make MkosiConfig a frozen dataclass

The config should be immutable after parsing. Let's enforce this
(somewhat) by making MkosiConfig a frozen dataclass.

2 years agoMove final machine ID into MkosiState
Daan De Meyer [Fri, 2 Sep 2022 14:18:12 +0000 (16:18 +0200)] 
Move final machine ID into MkosiState

Instead of modifying the config object when we're reusing a
machine ID from a cached image, let's set the final machine id in
MkosiState and only the machine ID in MkosiConfig for any machine
ID provided by the user.

2 years agoStop setting --uuid option when calling nspawn
Daan De Meyer [Fri, 2 Sep 2022 14:10:53 +0000 (16:10 +0200)] 
Stop setting --uuid option when calling nspawn

From the description of --uuid in nspawn's man page:

> Set the specified UUID for the container. The init system will
> initialize /etc/machine-id from this if this file is not set yet.
> Note that this option takes effect only if /etc/machine-id in the
> container is unpopulated.

Since we run the build with a machine ID in /etc/machine-id, there's
no point in passing the --uuid option.

2 years agoAdd final cache path to MkosiState
Daan De Meyer [Fri, 2 Sep 2022 14:02:56 +0000 (16:02 +0200)] 
Add final cache path to MkosiState

Instead of changing the config cache path to the new temporary
cache path if no cache path is configured, let's not touch the
config and store the final cache path in the state instead.

This also changes the temporary cache path to be in the workspace
instead of in the output directory.

2 years agoMove state into build_stuff()
Daan De Meyer [Fri, 2 Sep 2022 13:34:01 +0000 (15:34 +0200)] 
Move state into build_stuff()

We shouldn't need access to the state anywhere outside build_stuff()
so let's limit its scope to that function.

2 years agoMove secure boot args initialization into argparse defaults
Daan De Meyer [Fri, 2 Sep 2022 13:32:20 +0000 (15:32 +0200)] 
Move secure boot args initialization into argparse defaults

We want to be able to have an immutable config struct, so let's
initialize these variables before creating the config.

2 years agoOnly set umask when we're writing stuff into the image
Daan De Meyer [Fri, 2 Sep 2022 13:29:15 +0000 (15:29 +0200)] 
Only set umask when we're writing stuff into the image

Everything done outside of that can be done with the default umask.
This allows us to get rid of original_umask.

2 years agoMerge pull request #1170 from DaanDeMeyer/kernel-install-no-env
Daan De Meyer [Wed, 7 Sep 2022 07:57:06 +0000 (09:57 +0200)] 
Merge pull request #1170 from DaanDeMeyer/kernel-install-no-env

Don't pass environment when running kernel-install

2 years agoNormalize environment for all scripts 1170/head
Daan De Meyer [Mon, 5 Sep 2022 09:07:05 +0000 (11:07 +0200)] 
Normalize environment for all scripts

Let's make sure we run all scripts with the environment from the
config.

2 years agodebian/ubuntu: Pass Architecture option to apt
Marek Vasut [Thu, 1 Sep 2022 00:16:09 +0000 (20:16 -0400)] 
debian/ubuntu: Pass Architecture option to apt

Pass the target architecture to apt, otherwise mkosi ... --architecture
pulls in packages for the host architecture. This fixes generation of
container images for non-host architectures, e.g. generation of images
on amd64 host for arm64 target.

2 years agosupport floats for parse_bytes
Joerg Behrmann [Sat, 3 Sep 2022 18:35:37 +0000 (20:35 +0200)] 
support floats for parse_bytes

Fixes: #1168
2 years agoDon't pass environment when running kernel-install
Daan De Meyer [Mon, 5 Sep 2022 09:00:29 +0000 (11:00 +0200)] 
Don't pass environment when running kernel-install

Initially introduced in 32d09033e94f36993bede7016948e0702a4cb185,
but the reason wasn't recorded. Generally, we don't want to pass
just any environment variables to kernel-install, so let's not pass
the entire environment when running it.

2 years agoSign systemd-boot EFI binaries under /usr
Michael A Cassaniti [Mon, 8 Aug 2022 13:03:37 +0000 (23:03 +1000)] 
Sign systemd-boot EFI binaries under /usr

If secure boot signing is enabled with UEFI then `systemd-boot` binaries which
are at `/usr/lib/systemd/boot/efi` should be signed with the same signing key
that is used for EFI binaries within the ESP. In comparison to signed ESP
binaries, the '.signed' extension will be kept.

Without this change, any tool that copies these binaries into the ESP will
(likely) be copying an unsigned copy of `systemd-boot`. The service
`systemd-boot-update.service` is just one example of a service that will
regularly attempt to update `systemd-boot` within the ESP.

2 years agoMerge pull request #1164 from rphibel/put-root-and-do_run_build_script-in-mkosistate
Daan De Meyer [Fri, 2 Sep 2022 12:44:32 +0000 (14:44 +0200)] 
Merge pull request #1164 from rphibel/put-root-and-do_run_build_script-in-mkosistate

Put root and do_run_build_script in MkosiState

2 years agoMove output_signature in MkosiConfig 1164/head
Richard Phibel [Fri, 2 Sep 2022 09:22:29 +0000 (11:22 +0200)] 
Move output_signature in MkosiConfig

2 years agoCorrect formatting of MkosiConfig/MkosiState function parameters
Richard Phibel [Fri, 2 Sep 2022 09:20:33 +0000 (11:20 +0200)] 
Correct formatting of MkosiConfig/MkosiState function parameters

2 years agoPut root and do_run_build_script in MkosiState
Richard Phibel [Thu, 1 Sep 2022 18:26:29 +0000 (20:26 +0200)] 
Put root and do_run_build_script in MkosiState

2 years agoUpdate NEWS file
Joerg Behrmann [Thu, 1 Sep 2022 13:17:22 +0000 (15:17 +0200)] 
Update NEWS file

2 years agoSplit MkosiArgs into MkosiConfig and MkosiState
Richard Phibel [Wed, 24 Aug 2022 16:52:08 +0000 (18:52 +0200)] 
Split MkosiArgs into MkosiConfig and MkosiState

This split will enable serializing the configuration used to build the
image

2 years agoMerge pull request #1162 from DaanDeMeyer/aarch64-machine
Daan De Meyer [Wed, 31 Aug 2022 15:52:12 +0000 (17:52 +0200)] 
Merge pull request #1162 from DaanDeMeyer/aarch64-machine

aarch64 qemu fixes

2 years agoUse qemu's "virt" machine on aarch64 1162/head
Daan De Meyer [Wed, 31 Aug 2022 12:37:33 +0000 (14:37 +0200)] 
Use qemu's "virt" machine on aarch64

q35 is not supported when using qemu-system-aarch64

2 years agoAlways prefer architecture specific qemu paths
Daan De Meyer [Wed, 31 Aug 2022 13:17:14 +0000 (15:17 +0200)] 
Always prefer architecture specific qemu paths

The generic paths might not be for the current architecture, so
let's make sure we prefer architecture specific firmware without
secure boot support over generic firmware with secure boot support.

2 years agoDon't load passwords unless a build is needed
Jacob Emmert-Aronson [Mon, 15 Aug 2022 06:08:26 +0000 (23:08 -0700)] 
Don't load passwords unless a build is needed

This change allows setting password files to be readable only by root
for added security.  Additionally, if encryption is requested and no
passphrase file exists, the user will not be prompted to enter a
passphrase unless the mkosi invocation results in an image build.

2 years agoFix typo
Richard Phibel [Tue, 30 Aug 2022 13:27:42 +0000 (15:27 +0200)] 
Fix typo

2 years agoMerge pull request #1153 from bluca/verity_names
Daan De Meyer [Tue, 30 Aug 2022 11:39:47 +0000 (13:39 +0200)] 
Merge pull request #1153 from bluca/verity_names

Verity: rename split files to match what systemd expects

2 years agonspawn: use --link-journal=no
Luca Boccassi [Mon, 29 Aug 2022 22:06:07 +0000 (23:06 +0100)] 
nspawn: use --link-journal=no

The host might not have a journal.

On a minimal qemu build image on OBS, building SUSE Tumbleweed,
linking the journal fails with:

  Failed to retrieve machine ID: No medium found

2 years agoVerity: rename split files to match what systemd expects 1153/head
Luca Boccassi [Sat, 27 Aug 2022 23:11:13 +0000 (00:11 +0100)] 
Verity: rename split files to match what systemd expects

foo.raw means systemd searches automatically for foo.verity, foo.roothash/usrhash,
foo.roothash/usrhash.p7s so make the output match these existing
expectations

      Output Split Root FS: /home/luca/git/mkosi/mkosi.output/debian~unstable/image.usr.raw.zstd
       Output Split Verity: /home/luca/git/mkosi/mkosi.output/debian~unstable/image.usr.verity.zstd
  Output Split Verity Sig.: /home/luca/git/mkosi/mkosi.output/debian~unstable/image.usr.usrhash.p7s.zstd