]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
2 years agocentos: Modernize repo URLs 1308/head
Daan De Meyer [Mon, 16 Jan 2023 12:45:55 +0000 (13:45 +0100)] 
centos: Modernize repo URLs

Let's use DNF variables where we can. We also modify releasever to
be only the release version without "-stream" and use $stream when
we need the releasever with "-stream". This matches the upstream
usages of these variables.

2 years agocentos: Use lowercase repo identifiers everywhere
Daan De Meyer [Mon, 16 Jan 2023 12:23:33 +0000 (13:23 +0100)] 
centos: Use lowercase repo identifiers everywhere

2 years agoMerge pull request #1302 from DaanDeMeyer/repart-format
Daan De Meyer [Sun, 15 Jan 2023 19:23:48 +0000 (20:23 +0100)] 
Merge pull request #1302 from DaanDeMeyer/repart-format

Default to the distro preferred filesystem instead of ext4

2 years agoMerge pull request #1305 from DaanDeMeyer/stuff
Daan De Meyer [Fri, 13 Jan 2023 16:13:15 +0000 (17:13 +0100)] 
Merge pull request #1305 from DaanDeMeyer/stuff

Assorted changes

2 years agocentos: Install epel-release if EPEL repository is configured 1305/head
Daan De Meyer [Fri, 13 Jan 2023 15:01:03 +0000 (16:01 +0100)] 
centos: Install epel-release if EPEL repository is configured

2 years agocentos: Remove duplicate code
Daan De Meyer [Fri, 13 Jan 2023 15:00:37 +0000 (16:00 +0100)] 
centos: Remove duplicate code

2 years agocentos: Move epel selection to --repositories option
Daan De Meyer [Fri, 13 Jan 2023 12:15:08 +0000 (13:15 +0100)] 
centos: Move epel selection to --repositories option

Instead of having different distros for epel, let's just enable it
via the --repositories option.

2 years agoStreamline --repositories
Daan De Meyer [Fri, 13 Jan 2023 13:58:29 +0000 (14:58 +0100)] 
Streamline --repositories

2 years agoMake --repository-directory take multiple arguments
Daan De Meyer [Fri, 13 Jan 2023 12:53:21 +0000 (13:53 +0100)] 
Make --repository-directory take multiple arguments

2 years agoRemove --use-host-repositories
Daan De Meyer [Fri, 13 Jan 2023 12:06:45 +0000 (13:06 +0100)] 
Remove --use-host-repositories

This option is superseded by --repository-directory which can be
used for exactly the same purpose so let's remove this very specific
option in favor of using --repository-directory.

2 years agoMerge pull request #1281 from behrmann/python39
Daan De Meyer [Fri, 13 Jan 2023 15:19:02 +0000 (16:19 +0100)] 
Merge pull request #1281 from behrmann/python39

Bump Python to 3.9

2 years agoactions: bump checkout to v3 to remove spuriours node.js version warnings 1281/head
Joerg Behrmann [Fri, 13 Jan 2023 12:26:46 +0000 (13:26 +0100)] 
actions: bump checkout to v3 to remove spuriours node.js version warnings

2 years agogentoo: fix unsupported escape sequence in regex
Joerg Behrmann [Fri, 13 Jan 2023 09:07:31 +0000 (10:07 +0100)] 
gentoo: fix unsupported escape sequence in regex

2 years agoUpdate typing to use generics for standard container classes
Joerg Behrmann [Fri, 13 Jan 2023 09:20:45 +0000 (10:20 +0100)] 
Update typing to use generics for standard container classes

Also use the non-deprecated typing imports

2 years agoRemove casts that are no longer necessary with Python 3.9
Joerg Behrmann [Fri, 13 Jan 2023 09:07:07 +0000 (10:07 +0100)] 
Remove casts that are no longer necessary with Python 3.9

2 years agoUpdate pathlib call sites to use Python 3.9 features
Joerg Behrmann [Tue, 29 Nov 2022 13:17:59 +0000 (14:17 +0100)] 
Update pathlib call sites to use Python 3.9 features

These are:
- the unlink method gained the parameter missing_ok=
- Path objects now have a readlink method

2 years agoUse the walrus operator were applicable
Joerg Behrmann [Fri, 13 Jan 2023 09:01:25 +0000 (10:01 +0100)] 
Use the walrus operator were applicable

2 years agoUse removeprefix and removesuffix were applicable
Joerg Behrmann [Tue, 29 Nov 2022 12:54:18 +0000 (13:54 +0100)] 
Use removeprefix and removesuffix were applicable

2 years agoDrop subprocess workaround for pre python 3.9
Joerg Behrmann [Thu, 1 Sep 2022 14:41:10 +0000 (16:41 +0200)] 
Drop subprocess workaround for pre python 3.9

2 years agoBump python version in config files
Joerg Behrmann [Thu, 1 Sep 2022 14:40:41 +0000 (16:40 +0200)] 
Bump python version in config files

2 years agoMerge pull request #1304 from DaanDeMeyer/fix-rpmdb
Jörg Behrmann [Thu, 12 Jan 2023 15:04:11 +0000 (16:04 +0100)] 
Merge pull request #1304 from DaanDeMeyer/fix-rpmdb

Fix rpmdb

2 years agoci: Add opensuse 1302/head
Daan De Meyer [Thu, 12 Jan 2023 11:27:29 +0000 (12:27 +0100)] 
ci: Add opensuse

We run opensuse CI in systemd so we should do the same in mkosi.

2 years agoopensuse: Disable dracut hostonly via dropin
Daan De Meyer [Thu, 12 Jan 2023 11:55:21 +0000 (12:55 +0100)] 
opensuse: Disable dracut hostonly via dropin

Unlike the centos variants, opensuse does not have a
dracut-config-generic package to disable hostonly mode, so we do
it via a dropin instead.

2 years agoremove if check that's always true
Daan De Meyer [Thu, 12 Jan 2023 11:40:15 +0000 (12:40 +0100)] 
remove if check that's always true

2 years agoDefault to the distro preferred filesystem instead of ext4
Daan De Meyer [Tue, 10 Jan 2023 14:43:15 +0000 (15:43 +0100)] 
Default to the distro preferred filesystem instead of ext4

Note that we don't default to btrfs due to an issue where mounting
COW copies of the same filesystem more than once fails with EBUSY.
Until that is fixed, btrfs is pretty much unusable for building
images as systemd-repart will fail to build btrfs images.

2 years agofedora: Remove keys for EOL releases 1304/head
Daan De Meyer [Thu, 12 Jan 2023 13:48:21 +0000 (14:48 +0100)] 
fedora: Remove keys for EOL releases

2 years agocentos: Fix rpmdb location
Daan De Meyer [Thu, 12 Jan 2023 13:47:06 +0000 (14:47 +0100)] 
centos: Fix rpmdb location

The previous logic was not working correctly. Let's simplify the
logic by only executing it for centos and only working in one
direction, if the rpmdb is written to /usr/lib/sysimage/rpm, let's
move it back to /var/lib/rpm on CentOS.

2 years ago[gentoo] merge usrmerge
Paymon MARANDI [Mon, 5 Sep 2022 21:39:04 +0000 (17:39 -0400)] 
[gentoo] merge usrmerge

upstream finally has merged-usr profiles/stage3s [1].
this makes `no-multilib/systemd/merged-usr`, and related stage3, default
for us.

[1] https://bugs.gentoo.org/843818#c2

Signed-off-by: Paymon MARANDI <darwinskernel@gmail.com>
2 years agocentos: Stop installing systemd-boot on CentOS Stream 9
Daan De Meyer [Tue, 10 Jan 2023 14:58:03 +0000 (15:58 +0100)] 
centos: Stop installing systemd-boot on CentOS Stream 9

With CentOS Stream 9 moving to systemd v252, systemd-boot has been
added back to the systemd-udev package, so we don't need to install
it from EPEL anymore.

2 years agoRemove --qemu-boot option
Daan De Meyer [Tue, 10 Jan 2023 14:33:45 +0000 (15:33 +0100)] 
Remove --qemu-boot option

Given that we're standardizing more and more on UEFI and unified
kernel images, let's drop support for qemu direct linux boot, to
drop yet another seldomly exercised codepath.

2 years agoRemove annotations import from __future__
Joerg Behrmann [Wed, 11 Jan 2023 09:32:33 +0000 (10:32 +0100)] 
Remove annotations import from __future__

PEP 563 is a PEP that stringifies type annotations. The feature was made
available as opt in. It is still very much in flux or under consideration
upstream and has fallen so much out of favour that the Python steering council
added the note [1]

    PEP 563 Postponed Evaluation of Annotations (the from __future__ import
    annotations future statement) that was originally planned for release in
    Python 3.10 has been put on hold indefinitely. See this message from the
    Steering Council for more information.

in the release notes of CPython 3.11 after punting on accepting the PEP for two
releases. The import does a lot more, but we only use the type
stringification. There is little gain from using this, but with one of the main
features of the import indefinitely on hold, it seems prudent not to use it.

With Python 3.11 the PEP 673 Self type was introduced [2], that will solve this
problem for us, once we move on to 3.11.

[1] https://docs.python.org/3.11/whatsnew/3.11.html#pep-563-may-not-be-the-future
[2] https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-pep673

2 years agoAdd __init__.py to resources/repart
Daan De Meyer [Tue, 10 Jan 2023 11:49:43 +0000 (12:49 +0100)] 
Add __init__.py to resources/repart

This makes sure the repart/ directory in resources is included as
well.

2 years agoAdd --credential option to set systemd credentials
Daan De Meyer [Mon, 9 Jan 2023 15:40:56 +0000 (16:40 +0100)] 
Add --credential option to set systemd credentials

2 years agoidmap: fix kernel version comparison
Quentin Deslandes [Thu, 5 Jan 2023 17:39:31 +0000 (18:39 +0100)] 
idmap: fix kernel version comparison

packaging.version.parse() would create a Version object for "5.12" and a
LegacyVersion object for versions like "6.0.8-200.fc36.x86_64". This
leads to failed comparison (such as "6.0.8-200.fc36.x86_64 >= 5.12").

Use `systemd-analyze compare-versions` instead, which produce the
expected behaviour. This brings mkosi more in line with systemd
ecosystem when it comes to version strings parsing.

2 years agoMigrate to ukify
Daan De Meyer [Wed, 21 Dec 2022 15:04:02 +0000 (16:04 +0100)] 
Migrate to ukify

Let's start using ukify to generate unified kernel images instead
of implementing the logic ourselves. This also fixes issues with
overlapping PE sections.

2 years agofix invalid cross-device link
Benedict Schlueter [Fri, 23 Dec 2022 15:41:50 +0000 (16:41 +0100)] 
fix invalid cross-device link

when the workspace directory is on another filesystem (i.e. /tmp) mkosi
fails.
replace os.rename with shutil.move when we may cross filesystem
boundaries. Furthermore, chown the resulting files if the flag is set
accordingly.

2 years agofix "qemu-img convert" error
Benedict Schlueter [Fri, 23 Dec 2022 11:47:16 +0000 (12:47 +0100)] 
fix "qemu-img convert" error

the same path was used as in and output for qemu-img, this results in an
error. Use another path as output and rename the output afterward.

2 years agoMerge pull request #1276 from DaanDeMeyer/repart
Daan De Meyer [Wed, 21 Dec 2022 13:44:51 +0000 (14:44 +0100)] 
Merge pull request #1276 from DaanDeMeyer/repart

Migrate disk image building to systemd-repart

2 years agoMigrate disk image building to systemd-repart 1276/head
Daan De Meyer [Mon, 28 Nov 2022 14:45:31 +0000 (15:45 +0100)] 
Migrate disk image building to systemd-repart

Let's switch to systemd-repart to build disk images. systemd-repart
allows building disk images declaratively. repart will assemble a
disk image according to a set of partition definition files, which
it will search for in a set of predefined locations or in the locations
provided via the --definitions option. Partition definition files are
defined in the usual systemd ini style and define a single partition
each. Many aspects of the partition can be configured, including its
size, type, and how it should be populated.

Of note should be the CopyFiles= setting that allows providing a set
of files/directories from which the partition should be populated. The
CopyFiles= setting takes a list of path pairs, where the first path in
a pair defines the source location, and the second path the destination
location in the partition. If combined with repart's --root or --image
options, the source path is resolved relative to the given root directory.

Along with switching to systemd-repart, we also rework how we build
images. Previously, we first provisioned the disk image with all its
partitions, then mounted the disk image and finally populated it with
contents. Now, we provision to a regular directory on the host filesystem
first, followed by creating the disk image with systemd-repart. The partition
definition files can be supplied via the --repart-directory option or
in the mkosi.repart/ directory. If not provided, a default configuration
consisting of an automatically sized root partition and an ESP partition of
256M is used.

repart's --root switch is used so that the partition definition files
don't need to encode the full path to the root directory of the image
we're building. For example, to copy the root directory to a root
partition, it's sufficient to specify "CopyFiles=/:/" in the definition
file.

If we're building non-bootable images, any ESP partition definitions
are excluded. To allow building UKIs with an embedded roothash cmdline
parameter, we run repart twice, first to populate all partitions except
the ESP/XBOOTLDR partitions, and again to populate the ESP/XBOOTLDR
partitions including any UKIs with embedded roothash cmdline parameter
(which we determined when running repart the first time).

Because we don't know up-front anymore where the ESP partition will be
mounted, all boot loader files are installed to /boot. So to populate
an ESP partition, you'd use "CopyFiles=/boot:/" in the partition
definition file of the ESP partition.

Also, since we don't know up-front anymore which filesystem we'll be
building for, we stop installing filesystem related packages by default.
Users will be required to add the necessary filesystem packages themselves.
Similarly, we also stop installing cryptsetup and device-mapper by default
since we don't know upfront anymore whether partitions will be verity
protected or encrypted.

By switching to systemd-repart, we also set ourselves up for building
images without needing root privileges or loop devices. systemd-repart
is fully capable (from v253 onwards) of building disk images without
needing root privileges or loop devices. After we switch to
systemd-repart, we'll only need root privileges to be able to run
systemd-nspawn (which should not be necessary in the future anymore).

This PR also removes all the option related to disk image building that
can now be specified in repart definition files instead. This includes:

- Format=gpt_xxx options are replaced with a single "disk" options.
Filesystem can now be specified with repart's Format= option
- Format=plain_squashfs (Can be reproduced by a single repart squashfs
root partition combined with SplitArtifacts=yes)
- Verity= (Replaced by repart's Verity= options)
- Encrypt= (Replaced by repart's Encrypt= option)
- RootSize=, HomeSize=, VarSize=, TmpSize=, ESPSize=, SwapSize=, SrvSize=
(Replaced by repart's size options)
- UsrOnly= (replaced with `CopyFiles=/:/usr` in a usr partition definition)
- OutputSplitRoot=, OutputSplitVerity=, (Replaced by repart's SplitName= option)
- OutputSplitKernel= (UKI is now always written to its own output file)
- GPTFirstLBA (Removed, no equivalent in repart)
- ReadOnly= (Replaced by repart's ReadOnly= option per partition)
- Minimize= (Replaced by repart's Minimize= option per partition)
- CompressFs= (No equivalent in repart, can be replicated by replacing mkfs.<fs>
in $PATH with a script that adds the necessary command line option)
- MkSquashfs= (Can be replaced with a script in $PATH that invokes
the correct binary)

We also remove the WithoutUnifiedKernelImages= switch as building unified
kernel images is trivial and fast these days.

2 years agomypy: Fix version comparison
Daan De Meyer [Thu, 15 Dec 2022 14:54:34 +0000 (14:54 +0000)] 
mypy: Fix version comparison

2 years agoMake config.build_sources non-optional
Daan De Meyer [Tue, 13 Dec 2022 19:29:33 +0000 (19:29 +0000)] 
Make config.build_sources non-optional

It already was non-optional in practice, let's encode this in the
type.

2 years agoci: Rework integration tests
Daan De Meyer [Mon, 28 Nov 2022 14:42:13 +0000 (15:42 +0100)] 
ci: Rework integration tests

The current approach where we build the image as part of the integration
test is the wrong approach. Instead, we'll move to integration tests that
are integrated with a build system where building images and using them
in integration tests are separate steps. Building an image for use in an
integration test will be a regular target (custom_target()) in a build
system. Building an image that's not intended to be used in any other test
will be a regular test.

Because this model is going to be substantially different from what we have
now, let's get rid of the integration test machinery we added and temporarily
switch to the basic approach that's also used in the systemd repo for integration
tests.

2 years agoBump alma/rocky default release to "9"
Daan De Meyer [Fri, 25 Nov 2022 20:19:18 +0000 (21:19 +0100)] 
Bump alma/rocky default release to "9"

2 years agoDrop HostonlyInitrd
Daan De Meyer [Fri, 18 Nov 2022 10:07:27 +0000 (11:07 +0100)] 
Drop HostonlyInitrd

Adding this option was a mistake (mea culpa), we should limit host
impact on image builds as much as possible so let's drop this option
that makes the initrd generated by dracut host specific. This will
slow down initrd generation but once we switch to generating initrds
with mkosi we'll have a proper fix for that.

2 years agoAllow for UID mapping to be disabled
Quentin Deslandes [Wed, 16 Nov 2022 12:03:28 +0000 (13:03 +0100)] 
Allow for UID mapping to be disabled

By default, mkosi would bind mount directories with nspawn's rootidmap
option to provide consistent files ownership. If the system doesn't
support ID mapping, mkosi would fail.

Add --idmap option, default to True, to allow users to disabled UID
mapping (--idmap=no).

2 years agoRename --no-chown option to --chown
Quentin Deslandes [Wed, 16 Nov 2022 12:22:08 +0000 (13:22 +0100)] 
Rename --no-chown option to --chown

Rename --no-chown to --chown and defaults to true. This will make it
easier to reason on the code behaviour when this option is used.

2 years agoFix qemu tpm device name on aarch64
Daan De Meyer [Tue, 13 Dec 2022 12:51:48 +0000 (12:51 +0000)] 
Fix qemu tpm device name on aarch64

2 years agoidmap: also check for kernel version
Luca Boccassi [Mon, 12 Dec 2022 23:59:00 +0000 (23:59 +0000)] 
idmap: also check for kernel version

Not only nspawn 252 is required, but also kernel 5.12 for id-mapped mounts
to be available

2 years agoMerge pull request #1282 from wally-mageia/main
Daan De Meyer [Mon, 5 Dec 2022 08:12:24 +0000 (09:12 +0100)] 
Merge pull request #1282 from wally-mageia/main

Update Mageia DistributionInstaller

2 years agomageia: use release where applicable instead of state.config.release for consistency 1282/head
Jani Välimaa [Sun, 4 Dec 2022 16:35:16 +0000 (18:35 +0200)] 
mageia: use release where applicable instead of state.config.release for consistency

2 years agomageia: don't add update repo for cauldron
Jani Välimaa [Sun, 4 Dec 2022 11:00:05 +0000 (13:00 +0200)] 
mageia: don't add update repo for cauldron

2 years agomageia: add release version to repo name
Jani Välimaa [Sun, 4 Dec 2022 10:57:58 +0000 (12:57 +0200)] 
mageia: add release version to repo name

2 years agomageia: don't hardcode x86_64 arch to mirror urls
Jani Välimaa [Sun, 4 Dec 2022 10:35:09 +0000 (12:35 +0200)] 
mageia: don't hardcode x86_64 arch to mirror urls

2 years agoMerge pull request #1217 from behrmann/split4
Daan De Meyer [Tue, 29 Nov 2022 10:41:34 +0000 (11:41 +0100)] 
Merge pull request #1217 from behrmann/split4

Split v4

2 years agoRemove scaffolding for DistributionInstaller possibly being None 1217/head
Joerg Behrmann [Thu, 24 Nov 2022 16:14:40 +0000 (17:14 +0100)] 
Remove scaffolding for DistributionInstaller possibly being None

2 years agoSplit Alma and Rocky out of Centos
Joerg Behrmann [Thu, 24 Nov 2022 15:57:56 +0000 (16:57 +0100)] 
Split Alma and Rocky out of Centos

2 years agoRemove unused code
Joerg Behrmann [Thu, 24 Nov 2022 14:48:03 +0000 (15:48 +0100)] 
Remove unused code

2 years agoMove CentOS family to DistributionInstaller
Joerg Behrmann [Thu, 24 Nov 2022 13:54:35 +0000 (14:54 +0100)] 
Move CentOS family to DistributionInstaller

2 years agoMove OpenMandriva to DistributionInstaller
Joerg Behrmann [Thu, 24 Nov 2022 13:17:09 +0000 (14:17 +0100)] 
Move OpenMandriva to DistributionInstaller

2 years agoMove Mageia to DistributionInstaller
Joerg Behrmann [Thu, 24 Nov 2022 12:02:56 +0000 (13:02 +0100)] 
Move Mageia to DistributionInstaller

2 years agoMove Fedora to DistributionInstaller
Joerg Behrmann [Thu, 24 Nov 2022 11:54:34 +0000 (12:54 +0100)] 
Move Fedora to DistributionInstaller

This doubles basically all rpm/dnf functions with copies in
mkosi.distributions.fedora, but this let's us keep the split bisectable without
having to do a big refactor of what these functions look like.

2 years agoMove detect_distribution and dependents to mkosi.backend
Joerg Behrmann [Thu, 24 Nov 2022 11:52:52 +0000 (12:52 +0100)] 
Move detect_distribution and dependents to mkosi.backend

2 years agoMove unlink_try_hard and dependents into mkosi.remove
Joerg Behrmann [Thu, 24 Nov 2022 11:50:24 +0000 (12:50 +0100)] 
Move unlink_try_hard and dependents into mkosi.remove

Similar to mkosi.install but for removing things.

2 years agotests: appease pyright
Joerg Behrmann [Thu, 24 Nov 2022 11:09:20 +0000 (12:09 +0100)] 
tests: appease pyright

2 years agoMove Gentoo to DistributionInstaller
Joerg Behrmann [Wed, 23 Nov 2022 13:57:06 +0000 (14:57 +0100)] 
Move Gentoo to DistributionInstaller

2 years agoci: drop pyright version restriction
Joerg Behrmann [Tue, 22 Nov 2022 16:57:35 +0000 (17:57 +0100)] 
ci: drop pyright version restriction

2 years agoMove OpenSuse to DistributionInstaller
Joerg Behrmann [Tue, 22 Nov 2022 16:15:38 +0000 (17:15 +0100)] 
Move OpenSuse to DistributionInstaller

2 years agoMake all imports absolute
Joerg Behrmann [Tue, 22 Nov 2022 15:47:27 +0000 (16:47 +0100)] 
Make all imports absolute

2 years agoMove Debian and Ubuntu to DistributionInstaller
Joerg Behrmann [Tue, 4 Oct 2022 16:06:38 +0000 (18:06 +0200)] 
Move Debian and Ubuntu to DistributionInstaller

2 years agoMake install_skeleton_tree independent of Distribution enum
Joerg Behrmann [Tue, 4 Oct 2022 15:57:51 +0000 (17:57 +0200)] 
Make install_skeleton_tree independent of Distribution enum

Note for bisecting: This breaks skeleton tree on Debian-based distributions.

2 years agoAdd remove_packages method to DistributionInstaller
Joerg Behrmann [Tue, 4 Oct 2022 15:51:30 +0000 (17:51 +0200)] 
Add remove_packages method to DistributionInstaller

This should probably live in PackageType, but there is a strong dependence
between package type and distribution and I haven't figured out a good way to do
this without cyclical imports.

2 years agoStart moving functions that copy files into the image into a new install module
Joerg Behrmann [Sun, 18 Sep 2022 15:20:54 +0000 (17:20 +0200)] 
Start moving functions that copy files into the image into a new install module

2 years agoMove Arch install functions to distributions.arch
Joerg Behrmann [Tue, 4 Oct 2022 15:38:03 +0000 (17:38 +0200)] 
Move Arch install functions to distributions.arch

2 years agoMove functions out off __init__
Joerg Behrmann [Fri, 16 Sep 2022 17:30:13 +0000 (19:30 +0200)] 
Move functions out off __init__

Some are moved to backend for lack of a better place for now, most mount-related
functions are moved to a new mounts module, though some are left in __init__ for
later, when the dust settles and cyclic imports may become easier to avoid.

2 years agoHook up DistributionInstaller
Joerg Behrmann [Fri, 16 Sep 2022 16:33:33 +0000 (18:33 +0200)] 
Hook up DistributionInstaller

2 years agoAdd DistributionInstaller and hook it into MkosiState
Joerg Behrmann [Tue, 4 Oct 2022 14:52:44 +0000 (16:52 +0200)] 
Add DistributionInstaller and hook it into MkosiState

2 years agocli: say "(default)" not "default"
Zbigniew Jędrzejewski-Szmek [Tue, 22 Nov 2022 12:12:02 +0000 (13:12 +0100)] 
cli: say "(default)" not "default"

For partitions we use "(disabled)" so let's match the style.

2 years agoMake Distribution enum string-based
Joerg Behrmann [Tue, 4 Oct 2022 14:51:00 +0000 (16:51 +0200)] 
Make Distribution enum string-based

2 years agoMerge pull request #1249 from keszybz/verb-parameters
Jörg Behrmann [Mon, 21 Nov 2022 10:15:10 +0000 (11:15 +0100)] 
Merge pull request #1249 from keszybz/verb-parameters

Add missing descriptions of verbs which take parameters

2 years agomkosi: rework --help to print command syntax 1249/head
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2022 16:46:13 +0000 (18:46 +0200)] 
mkosi: rework --help to print command syntax

Command list and syntax is the most interesting part of the output.
But because of how argparse works, we were showing this part very
briefly and buried in other options. Instead of relying on the autogenerated
description, let's reuse the list from the man page.
Because a literal text is added, the lines for verbs and --help
and --version are suppressed.

I changed "Distribution" to "Distribution options" and so on for each
option group. The additional word connects the synopsis (which says
"[options…]" with the list below.

Output:
$ bin/mkosi --help| head -n 20
usage:
       mkosi [options...] summary
       mkosi [options...] build [script parameters...]
       mkosi [options...] shell [command line...]
       mkosi [options...] boot [nspawn settings...]
       mkosi [options...] qemu [qemu parameters...]
       mkosi [options...] ssh [command line...]
       mkosi [options...] clean
       mkosi [options...] serve
       mkosi [options...] bump
       mkosi [options...] genkey
       mkosi [options...] help
       mkosi -h | --help
       mkosi --version

Build Bespoke OS Images

Distribution options:
  -d, --distribution {fedora,debian,...

When printed on the console, summary/build/shell/… are bold.

2 years agomkosi: drop ArgumentParserMkosi.fromfile_prefix_chars
Zbigniew Jędrzejewski-Szmek [Wed, 2 Nov 2022 14:03:42 +0000 (15:03 +0100)] 
mkosi: drop ArgumentParserMkosi.fromfile_prefix_chars

mkosi is not usable as a library (all APIs are internal). So there is no need
to use a global variable for this. If we ever want to change it (and it's unlikely
that we ever would), we can just replace the character in the few places. The
code is much more readable without the indirection.

2 years agoAdd missing documentation about cmdlines for various verbs
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2022 16:27:38 +0000 (18:27 +0200)] 
Add missing documentation about cmdlines for various verbs

The error message is changed to be more direct. If somebody doesn't know that
the parameters are passed to the command, "additional" would be unclear.

In the man page the verbs are listed by the order one would normally use them,
i.e. summary, then build, then qmeu/shell/boot/…, then clean, and the less
frequently used verbs last.

Descriptions are added to the commands which take parameters that they do that
and how those parameters are interpreted. In paricular, for 'boot' we accept
kernel commandline options, and for 'qemu' we only take qemu options. (Which is
understandable, given that we don't do a direct kernel boot, but not obvious.)

Fixes #1210.

2 years agoman: regenerate man page
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2022 16:22:06 +0000 (18:22 +0200)] 
man: regenerate man page

2 years agodebian/ubuntu: Configure apt chroot with APT_CONFIG
Georges Discry [Tue, 15 Nov 2022 10:19:42 +0000 (11:19 +0100)] 
debian/ubuntu: Configure apt chroot with APT_CONFIG

When invoking apt switched from running inside the container to running
on the host, apt stopped reading the configuration files present in the
container. Because of this, it is not possible anymore to configure apt
by dropping a file in `mkosi.skeleton/etc/apt/apt.conf.d/`.

apt first loads its configuration files and then parse the command-line
options (so that they can override the options set in the files). While
setting `-o Dir=<container-root>` on the command-line has some impact on
the configuration of apt, it will not read the files in
`<container-root>/etc/apt/apt.conf.d/`, as apt has already read its
configuration files from the host with the configuration `Dir "/"`.

Rather than using the command-line, the APT_CONFIG environment variable
should be used to point to a file with the chroot configuration. When
set, that file is processed before anything else. By setting `Dir` this
way, apt will read the configuration files from the container and not
from the host.

As the host configuration is not read anymore, there is no more need to
mask `/etc/apt` on the host by bind-mounting an empty directory over it.

2 years agoUse the right python when mkosi is a symlink
Georges Discry [Tue, 15 Nov 2022 11:22:31 +0000 (12:22 +0100)] 
Use the right python when mkosi is a symlink

When the `mkosi` on the `PATH` is a symlink to the script installed
inside a virtualenv, the script fails to find the python executable
inside the virtualenv and falls back to the main python3. This is
notably the case when installing mkosi with pipx.

By first following the symlink inside the virtualenv, the script can
find the corresponding python executable.

2 years agoMerge pull request #1267 from DaanDeMeyer/fix-passing-nspawn-args
Daan De Meyer [Mon, 14 Nov 2022 17:24:04 +0000 (18:24 +0100)] 
Merge pull request #1267 from DaanDeMeyer/fix-passing-nspawn-args

Fix passing extra options to systemd-nspawn

2 years agoLook in both the config file and the cwd for dropin files 1267/head
Daan De Meyer [Mon, 14 Nov 2022 15:18:39 +0000 (16:18 +0100)] 
Look in both the config file and the cwd for dropin files

A project might have multiple config files in subdirectories that
they use with --default but have shared configuration in the root
of the repository. When loading such a config file with --default,
we should still load shared dropins from the shared location.

2 years agoFix reading dropin files
fedora Cloud User [Mon, 14 Nov 2022 15:27:38 +0000 (15:27 +0000)] 
Fix reading dropin files

When using iterdir() we don't have to join the paths anymore

2 years agoFix passing extra options to systemd-nspawn
Daan De Meyer [Mon, 14 Nov 2022 15:10:25 +0000 (16:10 +0100)] 
Fix passing extra options to systemd-nspawn

systemd-nspawn ignores all options after the first argument so when
we're passing kernel command line arguments, we need to make sure
we pass the nspawn options first, otherwise they'll get ignored.

2 years agoImplement --repository-key-check=no for dnf-based distros
reuben olinsky [Mon, 14 Nov 2022 07:10:00 +0000 (23:10 -0800)] 
Implement --repository-key-check=no for dnf-based distros

2 years agoPass KERNEL_INSTALL_BYPASS through to the places where it is used
Joerg Behrmann [Tue, 8 Nov 2022 12:46:04 +0000 (13:46 +0100)] 
Pass KERNEL_INSTALL_BYPASS through to the places where it is used

The idea of using KERNEL_INSTALL_BYPASS is to not run kernel-install twice
unnecessarily, since we run it later anyway, but a user reported a regression of
kernel-install not being run at all, although it apparently was in
earlier. Passing the environment variable through will at most run
kernel-install twice, this might be a workaround.

Fixes: #1263
2 years agoMake sure parse_args_file_group() looks in the right directory
Daan De Meyer [Mon, 7 Nov 2022 10:32:12 +0000 (11:32 +0100)] 
Make sure parse_args_file_group() looks in the right directory

We should look for dropins in the same directory as where we look
for the main config file.

2 years agoImplement clean_package_manager_metadata for pacman
LaserEyess [Sun, 6 Nov 2022 17:09:08 +0000 (12:09 -0500)] 
Implement clean_package_manager_metadata for pacman

2 years agoFlush files after copying
reuben olinsky [Thu, 3 Nov 2022 15:55:04 +0000 (08:55 -0700)] 
Flush files after copying

This resolves an issue where qemu sees an incomplete image when
--ephemeral is used.

2 years agoFix path traversal in tar extraction
Joerg Behrmann [Mon, 31 Oct 2022 09:40:58 +0000 (10:40 +0100)] 
Fix path traversal in tar extraction

This fixes CVE-2007-4559 [1], which was reported in an automated closing
campaign in PR #1253.

Crafted members of a tarfile with .. in their paths could resolve to paths
outside of the target directory to which the members would be extracted to.

[1] https://github.com/advisories/GHSA-gw9q-c7gh-j9vm

Closes: #1253
2 years agoAllow uncompressed squashfs images
reuben olinsky [Fri, 28 Oct 2022 02:51:41 +0000 (19:51 -0700)] 
Allow uncompressed squashfs images

The argument parsing was blocking this but the logic invoking
mksquashfs already supported it.

2 years agoFix input check for valid base image
Michael A Cassaniti [Tue, 1 Nov 2022 06:51:50 +0000 (17:51 +1100)] 
Fix input check for valid base image

2 years agotests: do not hardcode x86_64 as the architecture
Luca Boccassi [Sun, 30 Oct 2022 11:17:13 +0000 (11:17 +0000)] 
tests: do not hardcode x86_64 as the architecture

Otherwise tests will fail when run on other architectures.

2 years agoAdd more Debian architecture mappings
Luca Boccassi [Sat, 29 Oct 2022 13:50:41 +0000 (14:50 +0100)] 
Add more Debian architecture mappings

2 years agoMerge pull request #1246 from keszybz/print-summary-to-stdout,use-colour
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2022 15:22:42 +0000 (17:22 +0200)] 
Merge pull request #1246 from keszybz/print-summary-to-stdout,use-colour

Print summary to stdout, use colour