Commit graph

1848 commits

Author SHA1 Message Date
Christian Kellner
26a250ca6e test/data: don't write cmdline in grub2
In the fedora-boot manifest, do not write the kernel command line
to the `grubenv` file.
2022-01-06 15:09:33 +00:00
Christian Kellner
ee96b11faf stages/grub2: ability to not write kernel cmdline
Currently we always write the kernel command line to the `grubenv`
file, if only to include the root device. Starting with Fedora 33
and thus RHEL 9, the kernel command line included statically in
the BLS snippets and the grubenv `kernelopts` variable not used.
Instead one of the {/usr/lib,/etc}/kernel/cmdline files is read
and the parameters in them used during the creation of the BLS
snippets.
Therefore we add a new `write_cmdline` option that, if set to
FALSE, will prevent us from writing the kernel command line.
2022-01-06 15:09:33 +00:00
Christian Kellner
d4f275e024 stages/grub2: fix whitespace in docstring
For you, David.
2022-01-06 15:09:33 +00:00
Christian Kellner
7a2b8ac107 stages/grub2: extract uuid js schema definition
The uuid schema is duplicated in a few places. Extract it and use
references to it instead.
2022-01-06 15:09:33 +00:00
Christian Kellner
94e9f62f63 test/osbuild: check devices, mounts schema
Also check that the schema is valid for devices and mounts.
2022-01-06 15:09:33 +00:00
Jelle van der Waa
e3515caf01 stages: Remove excess whitespace between words 2022-01-06 16:01:26 +01:00
Jelle van der Waa
3d4be5f059 stages/org.osbuild.pacman: Make /dev/stdin available
Installing the mkinitcpio kernel preset's requires /dev/stdin to be
available for calling install.
2022-01-06 16:01:26 +01:00
Jelle van der Waa
97202e53b0 stages: Respect grub_home for grub legacy boot
Additionally add a new QEMU image output target for testing
grub2/mkinitcpio stages.
2022-01-06 16:01:26 +01:00
Ondřej Budai
dccbfb5916 schutzbot: remove ssh keys of team member that left us
bye 😢

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-01-06 09:18:17 +01:00
Ondřej Budai
0b8dbd4bc3 stages/kickstart: ensure a newline at the end of the file
To simplify extending of the kickstart file.

Fixes: rhbz#2036971
2022-01-04 18:36:37 +01:00
Ondřej Budai
fe379b631b stages/kickstart: remove dead code
post nor anaconda wasn't ever set to something truthy, let's just remove them
2022-01-04 18:36:37 +01:00
Tomas Hozza
a9e1070ce2 Fix typo in tar stage schema option enum
Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-22 11:50:08 +01:00
Jelle van der Waa
0cbd7898c7 Add mkinitcpio stage
This stage generates the initrd for Arch Linux and derivates.
2021-12-21 10:44:55 +01:00
Tomas Hozza
9786d1f0d6 stages: allow using sysconfig stage multiple times.
The sysconfig stage currently does not produce expected results when
used multiple times within the same pipeline. Specifically, the stage
always truncates respective configuration files for properties `kernel`
and `network`, if if these are not set in the stage options. Due to this
reason, the outcome of the image builds may depend on the order of
multiple occurrences of the sysconfig stage.

The following two pipeline snippets would produce different
configuration files content:

Configuration files are truncated:
```
{
  "type": "org.osbuild.sysconfig",
  "options": {
    "kernel": {
      "update_default": true,
      "default_kernel": "kernel"
    },
    "network": {
      "networking": true,
      "no_zero_conf": true
    }
  }
},
{
  "type": "org.osbuild.sysconfig",
  "options": {
    "network-scripts": {
      "ifcfg": {
        "eth0": {
          "bootproto": "dhcp",
          "device": "eth0",
          "ipv6init": false,
          "onboot": true,
          "peerdns": true,
          "type": "Ethernet",
          "userctl": true
        }
      }
    }
  }
},
```

No configuration files are truncated:
```
{
  "type": "org.osbuild.sysconfig",
  "options": {
    "network-scripts": {
      "ifcfg": {
        "eth0": {
          "bootproto": "dhcp",
          "device": "eth0",
          "ipv6init": false,
          "onboot": true,
          "peerdns": true,
          "type": "Ethernet",
          "userctl": true
        }
      }
    }
  }
},
{
  "type": "org.osbuild.sysconfig",
  "options": {
    "kernel": {
      "update_default": true,
      "default_kernel": "kernel"
    },
    "network": {
      "networking": true,
      "no_zero_conf": true
    }
  }
},
```

Change the stage to not touch respective configuration files if the
`kernel` and `network` properties are not set in the stage options.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-17 08:44:54 +01:00
Tom Gundersen
e97f6ef34e objectstore: don't store objects by their treesum
The treesum of a filesystem tree is the content hash of all its
files, its directory structure and file metadata.

By storing trees by their treesum we avoid storing duplicates of
identical trees, at the cost of computing the hashes for every
commit to the store.

This has limited benefit as the likelihood of two trees being
identical is slim, in particular when we already have the ability
to cache based on pipeline/stage ID (i.e., we can avoid rebuilding
trees if the pipelines that built them were the same).

Drop the concept of a treesum entirely, even though I very much
liked the idea in theory...

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-12-16 16:44:07 +00:00
ochosi
bf3c80372a Post release version bump
[skip ci]
2021-12-16 09:12:49 +00:00
Jelle van der Waa
a60af1e205 ci: update osbuild-ci containers image with pacman 2021-12-15 23:22:15 +01:00
Achilleas Koutsou
646dd238fe stages: add new org.os.build.pacman and org.osbuild.pacman.conf stage
Pacman is the default package manager for Arch Linux and derivates, the
pacman.conf stage generate a valid pacman.conf configuration file.

Co-Authored-By: Jelle van der Waa <jvanderwaa@redhat.com>
2021-12-15 23:22:15 +01:00
Achilleas Koutsou
bef387848f osbuild-mpp: Add support for a pacman resolver
This introduces a new dependency resolver to osbuild-mpp for Arch Linux
which uses the pacman package manager. The used solver is determined by
the `solver` field in the `mpp-depsolve` object inside the manifest
file, if it does not exists it falls back to the DepSolver for dnf/rpm.

Co-Authored-By: Jelle van der Waa <jvanderwaa@redhat.com>
2021-12-15 23:22:15 +01:00
Tomas Hozza
d7989a5c26 Add new stage for configuring DNF Automatic
Add a new stage `org.osbuild.dnf-automatic.config` for configuring DNF
Automatic.

The stage changes persistent DNF Automatic configuration. Currently, only
a subset of options can be set:
  - 'commands' section
    - apply_updates
    - upgrade_type

Fix #908

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-15 18:49:13 +01:00
Simon Steinbeiss
37c57bf5c9 release-action: Send notification to our Slack channel
Passing the webhook URL is necessary because GH composite actions don't
support handling secrets.
See also osbuild/release-action#3

[skip ci]
2021-12-11 14:06:13 +01:00
Tomas Hozza
cd4ac1c75a Add new stage for creating YUM / DNF repo files
Add a new stage `org.osbuild.yum.repos` for creating YUM / DNF `.repo`
files in `/etc/yum.repos.d`. All repo-specific options are supported but
only a subset of options which can be set for a repo as well as in the
[main] section are supported.

Add unit test for the new stage.

Fix #907

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-09 18:51:51 +01:00
Jelle van der Waa
f965ca8510 stages/users: Explicitly create a home directory
On distributions such as Arch Linux the home directory is not created by
default.
2021-12-09 16:48:31 +01:00
Sanne Raymaekers
5b3ebd7912 stages/org.osbuild.dnf.config: Edit /etc/dnf/dnf.conf
Fixes #906
2021-12-09 15:53:57 +01:00
Christian Kellner
c825c7e4fa buildroot: set container env variable
Set the container environment variable to indicate to programs
inside the build root that they are indeed running inside a
container (see also https://systemd.io/CONTAINER_INTERFACE/).
2021-12-09 13:14:27 +01:00
Christian Kellner
0c71289067 buildroot: isolate environment from the host
Create a well-defined environment with and use that for the build
root. It is not desirable to have the host's environment leak
into the container. Add a test to ensure that this works.
NB: This was probably an oversight when we switched from systemd-
nspawn to bubblewrap.
2021-12-09 13:14:27 +01:00
Christian Kellner
969a523058 test: capture full log in compile
Use the new `--monitor` and `--monitor-fd` mechanism to capture
the full log and print it as well in case of errors.
2021-12-09 00:44:21 +00:00
Christian Kellner
d050c77bfb osbuild: make monitor configurable via comandline
Introduce two new command line arguments, which can be used to
specify which monitor class to use (`--monitor`) and what file
descriptor to use for monitoring (`--monitor-fd`). The latter
defaults to standard out. The monitor class, if not specified,
is depended on the `--json` argument.
2021-12-09 00:44:21 +00:00
Christian Kellner
e62133a334 manifests/ostree-image: convert to LUKS
Wrap the LVM volume group in a LUKS container with the passphrase
`osbuild` (yes, really, super secure). NB: the kernel command line
is changed to include `luks.uuid` which is needed so that dracut
will attempt to open the luks container. This corresponds to an
crypttab entry `luks-uuid UUID`. We cannot use the /etc/crypttab
for ostree based images because the initrd is created at commit
time but they luks volume is created at deployment time, we have
to use the kernel command line instead. See the man page for the
systemd-cryptsetup-generator(8) for more information.

The `cryptsetup` package is included in the build root since it is
needed by the `org.osbuild.luks2.format` stage. All manifests that
are using the `f34-build-v2` build root change as a result.
2021-12-09 00:44:21 +00:00
Christian Kellner
0aea72e44e ci: run ostree image tests via Schutbot
OSTree tests, especially the fedora-ostree-image one, will soon
need the tight integration with the host for LVM2/LUKS support.
This we cannot run them in github action containers. Move them
to Schutzbot.
Explicitly install the new sub-package until composer gains the
needed requirement.
2021-12-09 00:44:21 +00:00
Christian Kellner
9f8c7f3ad9 devices/loopback: inhibit udev rules by default
Use the new udev inhibitor mechanism to suppress the processing of
problematic rules by default.
2021-12-09 00:44:21 +00:00
Christian Kellner
f280cfff18 devices/loopback: better log message
It is more interesting which loopback device was used by which
host service instead of the file descriptor. Log that instead.
2021-12-09 00:44:21 +00:00
Christian Kellner
b26d33910a loop: add setup callback to loop_for_fd
Add a new callback parameter to `LoopControl` that, if specified,
will be invoked after the loop device is opened but before any
other operation is done, like setting the backing file. Can be
used to perform custom setup tasks.
2021-12-09 00:44:21 +00:00
Christian Kellner
568a4ad97a loop: add new on_close callback to Loop
Add a new signal like callback to the `Loop` class which will be
invoked before the actual loop device is closed, i.e. the loop
device has an open file descriptor to the device node and it is
being closed. Can be used to perform custom cleanup tasks.
2021-12-09 00:44:21 +00:00
Christian Kellner
bd1343004b spec: split out luks2 support into sub-package
As with ostree and lvm2 support, split out the stages and host
device services needed to build images with LUKS2 support into
its own sub-package since not everyone that uses osbuild might
want the additional cryptsetup dependency.
2021-12-09 00:44:21 +00:00
Christian Kellner
4676c701b7 devices: add new org.osbuild.luks2
This is the corresponding device for LUKS containers created via the
new `org.osbuild.luks2.format` stage. Needed information are the
parent device and the passphrase used to create the container.
NB: this device always uses the new custom block device udev rule
inhibitor facility.
2021-12-09 00:44:21 +00:00
Christian Kellner
dbd8035881 devices/lvm2.lv: initialize fullname member
This gets set in `open` and used in `close` but if the former
fails the latter will explode if we do not properly initialize
it. Also, we should always properly initialize things.
2021-12-09 00:44:21 +00:00
Christian Kellner
7e2bb524a4 devices: add custom udev rule inhibitor mechanism
Certain udev rules for block devices are problematic for osbuild.
One prominent example is LVM2 related rules that would trigger
a scan and auto-activation of logical volumes. This rules are
triggered for new block devices or when the backing file of an
loop devices changes. The rules will lead to a `lvm pvscan
--cache --activate ay` via the `lvm2-pvscan@.service` systemd
service. This will auto-activate all LVM2 logical volumes and
thus interfering with our own device handling in `devices/
org.osbuild.lvm2.lv`, where we only want to activate a single
logical volume.
Also, if the lvm2 devices get activated after the manual metadata
change done in `org.osbuild.lvm2.metadata` the volume group names
might conflict which results in all lvm2 based tooling to be very,
ver sad and also said stage to hang since the loopback device can
not be detached since the activate logical volumes keep it open.

To work-around this we therefore implement a udev rule inhibition
mechanism: on the osbuild side a lock file is created via the new
class called `UdevInhibitor` in `utils/udev.py`. A custom set of
udev rules in `10-osbuild-inhibitor.rules` is then acting on the
existence of that lock file and if present will opt-out of certain
further processing. See the udev rules file for more details.

In fact, we want this custom inhibition mechanism, for all block
devices that are under osbuild's control, since these rules are
there to provide automatisms and integrations with the host,
something we never want.

NB: this should not affect the detection of devices, since lvm2
does do a scan of devices when we call `lvdisplay` in `lvm2.lv`.
The call chain as of lvm2 git rev f773040:

  _lvdisplay_single           [tools/lvdisplay.c
    process_each_lv           [tools/toollib.c
      lvmcache_label_scan     [lib/cache/lvmcache.c
        label_scan            [ibidem, here is the device detection!
      lvdisplay_full          [lib/display/display.c
2021-12-09 00:44:21 +00:00
Christian Kellner
d8a4f9d063 stages: add new org.osbuild.crypttab stage
New stage to configure /etc/crypttab to setup encrypted block devices.
See the documentation of the stage for more information.
2021-12-09 00:44:21 +00:00
Christian Kellner
2801c17730 stages: add new luks2 stage
New stage to initialize LUKS2 container on a given device, usually a
loopback device bound to a partition. The passphrase and uuid of the
container need to be specified. Optionally the cipher, label, sector
size and sub-label can be specified. Requires the cryptsetup binary
to be install in the build root.
2021-12-09 00:44:21 +00:00
Christian Kellner
0261b96e55 spec: split out lvm2 support into sub-package
The LVM2 support bits, especially the host service, depend on lvm2
tooling. Since not every user of osbuild may want to build images
with LVM2 split that out into its own sub-package and have that it
depend on LVM2.
2021-12-09 00:44:21 +00:00
Christian Kellner
4d9a0b3e9f [skip ci] ci: remove automerge again
Didn't work as expected. :(
2021-12-08 23:02:27 +01:00
Christian Kellner
f26ee9b7dd [skip ci] ci: do not require label for rebase
Allow automerge to update the PR without any labels present.
2021-12-08 16:56:20 +01:00
Christian Kellner
1a4d80447c make: require clean git for make make
Unexpected results otherwise.
2021-12-08 14:22:12 +01:00
Christian Kellner
6066407a89 [skip ci] ci: switch to using automerge
Instead of using merify which seems to not do what we want, use
a combination of mergify and automerge. We let mergify review
dependabot PRs. We let mergify dismiss reviews on updates but
exclude those from Schutzbot. We then let Schutzbot update and
merge the PRs via automerge if the `ci:automerge` label is set.
2021-12-08 14:13:43 +01:00
Christian Kellner
055b0203a0 [skip ci] ci: preserve reviews across rebase
Re-review the PR after rebasing it. Leave a message to make it
clear that it was not the impersonated person but mergify that
did it.
Ideally, if we had premium, we would impersonate Schutzbot so
it is clear who did it and then use mergify to dismiss reviews
on changes but not for Schutzbot.
2021-12-08 12:38:28 +01:00
Christian Kellner
eaa00884be [skip ci] ci: review PRs for dependabot
Instead of directly queuing it, just add an auto-review for
dependabot and then let the normal PR condition do its job.
2021-12-08 12:38:28 +01:00
Tomas Hozza
0df902d6bb sshd.config stage: support PermitRootLogin option
Add support for `PermitRootLogin` option in the
`org.osbuild.sshd.config` stage.

I kept the "yes" and "no" values for consistency with other stage
options. While it will make the implementation in osbuild-composer
harder, it won't be impossible as we already have a precedence for doing
it this way (e.g. in the `org.osbuild.pam.limits.conf`).

Modify the stage unit tests to check the new option.

Remove the empty `org.osbuild.sshd.config` stage from `a.mpp.json`
since it does not add any value and it actually made the `tree-diff`
tool provide a weird tree diff results.

Fix #910

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-07 15:20:50 +00:00
Christian Kellner
60066ee927 main_cli: refine the --stage-timeout help text
Clarify this timeout is per stage, not per image.
2021-12-07 09:47:01 +00:00
Christian Kellner
bd5b60a857 stages: remove org.osbuild.test.timeout
Was only used in `test_buildroot` and got replaced with a direct
call to `sleep`.
2021-12-07 09:47:01 +00:00