Commit graph

2624 commits

Author SHA1 Message Date
Alexander Larsson
69028fc016 org.osbuild.systemd: Support masking generators
This adds a new key masked_generators, similar to masked_services,
which masks systemd generators from running at boot, by creating
symlinks to /dev/null in /etc/systemd/systemd-generators, as
described in:
 https://www.freedesktop.org/software/systemd/man/latest/systemd.generator.html#Description

This will be useful for the automotive project, as it allows disabling
of unsupported things like sysv or rc.local legacy support, while
improving boot performance.
2023-12-15 10:01:00 -08:00
Dusty Mabe
dfd59a38d9 osbuild/mounts: adjust the source path to use when mounting devices
Adjust the source path to just have /dev in front (i.e. /dev/loop0)
and not be a path to the temporary dev directory that was prepared.
We do this because some tools (like grub2-install) consult
mountinfo to try to canonicalize paths for mounts.

Fixes https://github.com/osbuild/osbuild/issues/1492
2023-12-15 09:54:29 -05:00
Michael Vogt
b830c80a3f stages(mkfs.ext4): add basic unit test 2023-12-15 09:16:57 +01:00
schutzbot
05c0fd319d schutzfile: Update snapshots to 20231201 2023-12-13 17:12:54 +01:00
Gianluca Zuccarelli
2ec88bdb32 sources/skopeo: check containers-storage
Update the skopeo sources stage to check other container-transports [1]
for downloading container images. This commit adds a transport for
`containers-storage` in addition to the existing `docker://`
transport.

Jira: https://issues.redhat.com/browse/HMS-3235

[1] CONTAINERS-TRANSPORTS(5)
2023-12-12 14:09:10 -08:00
Simon de Vlieger
2141168e44 test(stages/skopeo): schema validation
Minor schema validation test.
2023-12-12 23:08:19 +01:00
Ondřej Budai
852a76cc5c stages/skopeo: document the defaults in the schema 2023-12-12 23:08:19 +01:00
Ondřej Budai
9e612822d0 stages/skopeo: add support for OCI destination
The skopeo stage is updated to accommodate two types of
destinations: 'containers-storage' and 'oci'. Now, it can
copy a container image to either a container store or
a directory as per 'Open Container Image Layout
Specification'.
2023-12-12 23:08:19 +01:00
Michael Vogt
4e3fc6a625 osbuild: pytoml is deprecated, replace with toml
Pytoml is no longer being maintained: https://github.com/avakar/pytoml
The author suggest switching to toml.

We already use the
```
try:
    import toml
except ModuleNotFoundError:
    import pytoml as toml
```
pattern in stages/org.osbuild.containers.storage.conf so use it in the tests too to prefer "toml" instead of pytoml.
2023-12-12 14:06:50 -08:00
Michael Vogt
caddf0adfb fscache: add new FsCache._last_used() helper
This helper can be used to implement a strategy to find the oldest
cache entries and evict them when the cache is full.

The implementation uses the `atime` of the per object `cache.lock`
file and ensures in `load()` that it's actually updated.
2023-12-12 22:57:21 +01:00
Michael Vogt
f52cabc3c1 osutil: add Libc.futimens() wrapper for futimens() call
Python has no wrapper for a futime*() call so we need to implement
it in the `util.linux` package.
2023-12-12 22:57:21 +01:00
Michael Vogt
ca9f4038c8 util: add test that validates cache update strategy 2023-12-12 22:57:21 +01:00
Brian C. Lane
77d775b2ba test: Add a test for the org.osbuild.zstd stage 2023-12-12 19:45:04 +01:00
Brian C. Lane
5dd6fb7c4c test: Add a test for the org.osbuild.xz stage 2023-12-12 19:45:04 +01:00
Brian C. Lane
9eb9f7f7f2 test: Move make_fake_input_tree to testutil
This is useful for other stage tests, move it and add a test.
2023-12-12 19:45:04 +01:00
Michael Vogt
5416028f2d osbuild: include std{out,err} in FileSystemMountService.mount() errors
This commit adds mount output to the error raised by
FileSystemMountService.mount(). This is useful when running into
mount failures during osbuild runs.

The issue was discovered while debugging a mount failure for
osbuild-composer PR#3820. Initially osbuild PR#1490 was meant
to fix it but it turned out there is a third mount helper in
the code that was originally overlooked (sorry for that!).
2023-12-12 16:25:35 +01:00
Alexander Larsson
891bbcec17 Add test for org.osbuild.containers.storage.conf stage 2023-12-12 09:54:38 +01:00
Alexander Larsson
eea81b660a testutils: Add assert_dict_has
This is a convenient way for tests to assert that some nested dicts
(like a parsed json) has a particular key/value somewhere in it.

For example:
  assert_dict_has(config, "toplevel.subitem.key", True)
2023-12-12 09:54:38 +01:00
Alexander Larsson
2d12ef478e org.osbuild.containers.storage.conf: Add pull_options
These are used to enable zstd::chunked and composefs, so they are important.
2023-12-12 09:54:38 +01:00
Alexander Larsson
4c3a81033f org.osbuild.containers.storage.conf: Add transient_store option
This is used by the automotive project, but is also useful for edge.
2023-12-12 09:54:38 +01:00
Alexander Larsson
c5a353b718 org.osbuild.containers.storage.conf: Use existing storage options definition
A bunch of the options in storage were not enabled because the
"storage" definition was not used.
2023-12-12 09:54:38 +01:00
Michael Vogt
4026d4dc10 test: add test that ensures mount output is part of the exception
While debugging a failure of osbuild-composer [0] on fc39 it was
noticed that a mount failure does not include the output of
the mount command:
```
  File "/usr/lib/python3.12/site-packages/osbuild/mounts.py", line 78, in mount
    path = client.call("mount", args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 348, in call
    ret, _ = self.call_with_fds(method, args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 384, in call_with_fds
    raise error
osbuild.host.RemoteError: CalledProcessError: Command '['mount', '-t', 'xfs', '-o', 'ro,norecovery', '--source', '/dev/rootvg/applv', '--target', '/tmp/tmpjtfmth56/app']' returned non-zero exit status 32.
   File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 268, in serve
    reply, reply_fds = self._handle_message(msg, fds)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 301, in _handle_message
    ret, fds = self.dispatch(name, args, fds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/osbuild/mounts.py", line 111, in dispatch
    r = self.mount(args)
        ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/osbuild/mounts.py", line 160, in mount
    subprocess.run(
  File "/usr/lib64/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
```
which makes diagnostic errors harder of course. This commit adds
a test that ensures that mount output is visbile and also changes
the code to include it.

[0] https://github.com/osbuild/osbuild-composer/pull/3820
2023-12-11 11:24:17 +01:00
Simon de Vlieger
e73f4e57dd ci: update terraform hash
Some AMI went AWOL.
2023-12-08 14:29:52 +01:00
Simon de Vlieger
1b5ab0ee03 stages(kickstart): mutual exclusive ostree options
These options are mutually exclusive, this updates the schema and test
case to ensure this is detected at schema validation time.
2023-12-08 14:29:52 +01:00
Simon de Vlieger
20d8d3a9a8 stages(kickstart): add ostreecontainer
Add support for the `ostreecontainer` kickstart command, see:
https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#ostreecontainer
2023-12-08 14:29:52 +01:00
Jakub Rusz
36883654ce rpmbuild: add fedora-40 2023-12-06 10:11:32 +01:00
schutzbot
c53c60e694 Post release version bump
[skip ci]
2023-12-06 08:15:39 +00:00
Paweł Poławski
55a007a871 Readme: Update project build information
osbuild-composer project has build related section in the main README.
For the osbuild it was missing. Even if this is script-based project
external developers may not be aware of this just by looking at README.
Missing build related section has been added for consistency.
2023-12-05 11:46:16 +01:00
Paweł Poławski
12a9e65e2f Makefile: Update helper notes
Makefile has multiple test related targets.
* linter target has been added to the helper note.
* dead test-src target has been removed from Makefile
2023-12-05 11:46:16 +01:00
Michael Vogt
0767ebccc1 stages(autotailor): add small unit test
Small unit test for PR#1407.
2023-12-04 14:34:17 +01:00
Gianluca Zuccarelli
6d9c6e0bde stages:oscap.autotailor: add key/value overrides
This commit extends the current support for OpenSCAP
tailoring by accepting an array of key/value overrides.
Users will be able to specify override values for specific
rules that will update the value when remediating the
image.
2023-12-04 08:49:47 +01:00
Ondřej Budai
7882db2543 test/data/manifests: add erofs-utils to Fedora buildroot
The next commit will add a stage test that requires erofs-utils. Let's add it
into the buildroot in a separate commit, so the history is more readable.
2023-12-01 10:36:06 +01:00
Michael Vogt
627199543f test: add erofs stage test
Add a simple stage test for the erofs stage. It uses dump.erofs
instead of mounting the file because the kernel in the GH runners
do not support mounting erofs just yet.
2023-12-01 10:36:06 +01:00
Michael Vogt
d4a0837cf0 stages(erofs): add tests and fix small bug in options handling
This adds tests for the erofs stage. The tests are slightly different
from the existing tests that run the filesystem utils inside the
stages. Depending on what exactly we want to test we may still need
a run inside the stages. However running this inside a container
should be good enough if we just want to validate that the options
are passed correctly and the file is created.
2023-12-01 10:36:06 +01:00
Ondřej Budai
a2ea0b2265 stages: add org.osbuild.erofs
Erofs is "a lightweight read-only file system"[1]. Imagine squashfs, but with
faster reads.

This commit adds support for creating it. The new stage is heavily inspired by
the squashfs one. I've decided to add all features of mkfs.erofs that looked
useful: All compression types and most of extended options (excluding the
compatibility ones, we can always add them later).

[1]: https://en.wikipedia.org/wiki/EROFS
2023-12-01 10:36:06 +01:00
Tomáš Hozza
286b785af7 Packit: make COPR builds for new releases in a dedicated project
Add a new Packit "copr_build" job, which will build new upstream
releases in a dedicated COPR project "osbuild-stable". This will allow
people to consume stable builds of osbuild ASAP (including some
sub-packages on CS which are not part of the official distro builds).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-11-30 14:23:15 +01:00
Simon de Vlieger
b225d1cf04 osbuild-mpp: conditional losetup
`mpp-define-images` can create an image file, using `losetup` to deal
with non-standard sector sizes requires root. Not all users run
`osbuild-mpp` as root.

While I am not a fan of "suddenly sudo" based on the input manifest this
does alleviate builds breaking for manifests with default sector sizes
when non-root.
2023-11-30 14:16:57 +01:00
Michael Vogt
0a2e0bb3d2 stages: add org.osbuild.machine-id stage
This is a variation of PR https://github.com/osbuild/osbuild/pull/960
that put the machine-id handling into it's own stage and adds
explicit handling what should happen with it.

For machine-id(5) we essentially want the following three states
implemented:

1. `first-boot: yes` will ensure that /etc/machine-id is
   in the "uninitialized" state. This means on boot the systemd
   `ConditionFirstBoot` is triggered and a new id in `/etc/machine-id`
   is created. This will work for systemd v247+.
2. `first-boot: no` will ensure that /etc/machine-id exists but
   is empty. This will trigger the creation of a new machine-id but
   will *not* trigger `ConditionFirstBoot`.
3. `first-boot: preserve` will just keep the existing machine-id.
   Note that it will error if there is no /etc/machine-id

Note that the `org.osbuild.rpm` will also create a
`{tree}/etc/machine-id` while it runs to ensure that postinst
scripts will not fail that rely on this file. This is an
implementation detail but unfortunately the rpm stage will
leave an empty machine-id file if it was missing. So we cannot
just remove /etc/machine-id because any following rpm stage
would re-create it again (and we cannot change that without
breaking backward compatiblity). Thanks to the special semantic
that a missing /etc/machine-id and an /etc/machine-id with
the `uninitialized` string are equivalent we don't care.

To support systemd versions below v247 we could offer an option
to remove /etc/machine-id. But the downside of this is that
it would only work if the org.osbuild.machine-id stage is after
the rpm stage.

See also the discussion in PR#960.

Thanks to Tom, Christian for the PR and the background.
2023-11-30 13:30:32 +01:00
Dusty Mabe
e191dc1d0d tools/osbuild-mpp: set part ID from name if missing
For our Fedora CoreOS disk images we set the partition labels (name)
for the partitions. This is also supported using the primitives here
in OSBuild, but it wasn't obvious that I needed to set the name in
the mpp-define-images definition. Let's set the name there, but let's
also allow osbuild-mpp to set the `id`, which is what is used later
to access that partition from the `name` too if `id` isn't set.

This means we allow something like:

   - name: BIOS-BOOT
     type: 21686148-6449-6E6F-744E-656564454649
     bootable: true
     uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549
     size: 100

rather than requiring something like:

   - id: BIOS-BOOT
     name: BIOS-BOOT
     type: 21686148-6449-6E6F-744E-656564454649
     bootable: true
     uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549
     size: 100
2023-11-29 10:37:08 +01:00
Dusty Mabe
5ad3f968e1 manifests: add example metal4k disk image for Fedora CoreOS
The created disk image would be written to 4k native disks.
2023-11-29 10:37:08 +01:00
Dusty Mabe
28c2772d42 tools/osbuild-mpp: add sector size support for image layouts
Now you can specify a sector_size in `mpp-define-images` to support
creating a 4k native disk image (sector_size=4096).

This does use a loopback device, which means osbuild-mpp also needs
to run as root, when previously that wasn't necessary.
2023-11-29 10:37:08 +01:00
Dusty Mabe
2e1f6e2553 tools/osbuild-mpp: support defining multiple image layouts
Right now you can only define a single image, lets add mpp-define-images
and accept a list.
2023-11-29 10:37:08 +01:00
Dusty Mabe
b824e1e57a manifests: fedora-coreos-container: human friendly partitioning
Let's define the partitioning for the example here in a more human
friendly way using GiB and MiB terms. This yields no change in the
generated json.
2023-11-29 10:37:08 +01:00
Dusty Mabe
5207e92cab tools/osbuild-mpp: handle corner case in mpp-format-int
If you do math in mpp-format-int it could end up getting converted
to a float. Of course if you end up with a decimal value that isn't
`.0` that's a problem for an int, but if it is `.0` let's handle it
gracefully.

For example, math like this could end up with a value with `.0`:

  mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / sector_size_bytes}"
2023-11-29 10:37:08 +01:00
Dusty Mabe
0770eb0090 devices/loopback: make setting sector_size meaningful
For the org.osbuild.loopback the user can set the sector size, but
it had no effect on the underlying loopback device. Let's make it
meaningful by passing along the given value to the underlying code.
2023-11-29 10:37:08 +01:00
Alexander Larsson
677a874115 osbuild-mpp: Print better errors if eval fails
I'm trying to debug some failures, and having no feedback as to
what file we're parsing or what code is evaluated when something
fails makes it hard to debug manifests.

This adds some nice error messages that will help.
2023-11-28 18:03:05 +01:00
Miguel Martín
bc04bfc366 runners: clean up temp files before exiting the runner
Clean up created temp files before exiting the runner.
2023-11-28 11:50:31 +01:00
Miguel Martín
99af178c6d runners: create fake machine id when needed
Create fake machine before executing the runner command to
avoid the "Failed to resolve specifiers in '/var/log/journal/%m'"
errors.
2023-11-28 11:50:31 +01:00
Michael Vogt
b3c6366135 osbuild: improve monitor docstrings/signatures
This is a split out from the work around json
progress in [1].

[1] https://github.com/osbuild/osbuild/compare/main...mvo5:osbuild:json-progress-mvo?expand=1
2023-11-28 09:56:56 +01:00
Michael Vogt
3b7471ab7c stages(kickstart): add validation for the hostname
The hostname is validated according to the rules of `hostname(7)`
and tests are added to validate them.
2023-11-27 15:10:29 +01:00