Commit graph

2969 commits

Author SHA1 Message Date
Gianluca Zuccarelli
26aac90eb4 util/containers: read host config
Add utility function to read the host's container storage config.
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
462c498dcf util/mnt: add explicit rw option
Under certain conditions a bind mount without a specified `rw` or `ro`
option gets mounted read-only.  We need a way to be explicit about
needing a rw mount.  We might want to change this in the future to be a
single option (mode optional?) with valid values "rw", "ro".

It's not entirely clear what the conditions are but it occurs when bind
mounting the containers storage into the osbuild store, which we will
need for the next few commits.
2024-02-21 17:55:37 +01:00
Tomáš Hozza
92e75c375c Stages/grub2.legacy: make config options a subset of grub2 stage
While integrating the changes to grub2 config stage options in the
`osbuild/images` repository, I noticed that the code for grub2.legacy
is embedding the grub2 stage config options struct in its own config
options struct [1]. However, the grub2 stage options contain also the
`default` entry, while the grub2.legacy stage does not allow this option
in its stage options.

This change fixes that and ensures that the grub2 stage options config
section is a subset of the grub2.legacy stage options config section.

[1] d5644f3115/pkg/osbuild/grub2_legacy_stage.go (L85)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-21 17:51:28 +01:00
Eric Curtin
134a4cca26 stages/dracut: Add functionality to build initoverlayfs with dracut
As an alternative to just initramfs. Upstream initoverlayfs project:

https://github.com/containers/initoverlayfs

Signed-off-by: Eric Curtin <ecurtin@redhat.com>
2024-02-21 11:53:48 +01:00
Adam Williamson
044d651b5a Fix developer guide link in README.md
Signed-off-by: Adam Williamson <awilliam@redhat.com>
2024-02-20 23:45:20 -08:00
Michael Vogt
efcecd3867 tools: make osbuild-depsolve-dnf5 pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
d4831a8924 tools: make osbuild-mpp pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
a2bb687d54 tools: make gen-stage-test-diff pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
2290aff94d check-snapshots: add log info when a download fails
When a requests.get() fails the exact nature of the error is
currently discarded. This commit adds a small print() to show
what exactly went wrong.
2024-02-20 14:52:23 -08:00
Michael Vogt
34cda2e1e3 check-snapshots: make exception for snapshot cache more targeted
The code in `check-snapshots` will print "No snapshots cache found
at ..." regardless of the error that happens when trying to open
the file. This can be misleading if e.g. the issue is permissions
to open the file or the file is corrupted. So make the exception
more targeted and only catch FileNotFound error and let python
how the full error for the other cases. Obviously this can be
done in many ways so I'm happy to tweak and e.g. keep catching
all exception but print the value etc.
2024-02-20 14:52:23 -08:00
Michael Vogt
2c86e90d05 tools: make check-snapshots pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
5c47be179c tox: add all non shell file in tools/ to lintables
Right now the tools directory is not checked by pylint because
it will not auto-detect what files are python files and instead
just skip the dir if it does not have a __init__.py.

This commit uses `tox-backticks` to run a custom find to ensure
the python files are explicitely added. I'm not sure we can
use tox-backticks or we need it packages for fedora/rhel?

If we cannot use it we need to look into either a custom tox
plugin to support more rich globbing or just move out
`tools/set-env-variables.sh` as it's the only non-python code
in the repo and it will trip up pylint (syntax error).
2024-02-20 14:52:23 -08:00
Tomáš Hozza
be1ba5be08 Stages/grub2: extend default config options
Extend the stage to allow explicitly configuring more grub2 default
config options. Preserve the defaults for options which were previously
hard-coded.

Extend the stage unit test to verify setting of the new grub2 default
config options.

Related to https://issues.redhat.com/browse/RHEL-19583

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
84fc4c9903 Extend unit test for org.osbuild.grub2 stage
Test the content of the /etc/default/grub config file based on the
provided stage options.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
7895424b78 Stages/grub2.legacy: extend default config options
Extend the stage to allow explicitly configuring more grub2 default
config options. Preserve the defaults for options which were previously
hard-coded.

Extend the stage unit test to verify setting of the new grub2 default
config options.

Related to https://issues.redhat.com/browse/RHEL-19583

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
21ebed9305 Add unit test for org.osbuild.grub2.legacy
For now, test the content of /etc/default/grub configuration file.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Brian C. Lane
b131d3cf57 osbuild-depsolve-dnf5: Fix url substitutions
Substitutions should be set on Base, not per-repo. Discovered this
in lorax's dnf5 code so I am updating it here as well.
2024-02-20 09:42:01 +01:00
Brian C. Lane
4f83cdc434 osbuild-depsolve-dnf5: module_hotfixes wasn't really set
Typo in the previous change, wasn't setting `repo.module_hotfixes`
2024-02-20 09:32:43 +01:00
Michael Vogt
43c83c01e6 stages(org.osbuild.systemd.unit.create): add small unit test
Small unit test for the new `org.systemd.unit.create` stage. It
will do basic schema validation checks and ensures that a simple
service definition is correctly translated to a systemd unit.
2024-02-19 15:12:55 +01:00
Evgeny Kolesnikov
46e1bc1e2b stages/oscap.remediation: Mount host's /proc and /dev earlier
We need /dev/urandom for the first pass as well.
2024-02-17 02:10:58 +01:00
Michael Vogt
90193d007f stages/bootc.install-to-fs: fix root mount handling
The bootc.install-to-filesystem code needs to run against the
root directory of a mounted tree, i.e. with /boot, /boot/efi
mounted. So change the code so that the target dir is the
the "mounts" paths. This is similar to how bootupd works and
the caller need to arrange the right mount setup there.
2024-02-16 18:05:50 +01:00
Sayan Paul
e858dc72c3 stage/systemd-unit:stage to create systemd unit file
Add systemd unit files in osbuild stage

This stage creates systemd unit file in `/usr/lib/systemd/system/`.
The stage accepts filename which must end with `.service`.Section
`Unit` , `Service` , `Install` accepts various parameters as per
the systemd documentaion.`systemd-analyze verify` is be performed
after the .service file is created to check for potential errors.

Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
2024-02-16 11:55:11 +01:00
Achilleas Koutsou
f9e35c25da Schutzfile: Fedora-40 branched
Fedora 40 has branched.  Let's update the repo snapshots in the
Schutzfile.

xref https://github.com/osbuild/rpmrepo/pull/92
2024-02-16 11:55:11 +01:00
schutzbot
c164665db1 Post release version bump
[skip ci]
2024-02-14 08:13:58 +00:00
Michael Vogt
c3af3173eb stages(container-deploy): podman mount failure test/tweaks
This commit adds a test that ensures that the output of
podman mount is part of the error message. While writing
the test I also tweaked the code slightly so that we only
try to `podman umount` if we managed to successfully mount.
2024-02-12 17:41:21 -08:00
Michael Vogt
7b5d6e4bd9 testutil: add new mock_command context manager
The new `testutil.mock_command` context manager can be used to
mock commands in PATH and replace them with arbitrary shell
scripts. This is useful in testing to e.g. simulate exact error
conditions that would be hard to trigger otherwise or to replace
long running commands with faked results.

Example:
```
fake_cmd = textwrap.dedent("""\
do-something
""")
with mock_command("some-cmd", fake_cmd):
   your_code
```
2024-02-12 17:41:21 -08:00
Brian C. Lane
291f5cc29e Revert "osbuild-depsolve-dnf: port weak dependencies"
This reverts commit e023fdec1b.

Ends up this was based on an older version of dnf-json, the correct
behavior is to use the "install_weak_deps" bool.
2024-02-13 00:17:16 +01:00
Dusty Mabe
f334ca92c6 manifests: convert a few more ostree deployments
These were missed in the initial conversion.
2024-02-12 11:25:11 -05:00
Dusty Mabe
3fdb62e548 mount/ostree.deployment: Fix ostree deployment call
We need to pass in the root of the ostree deployment which can
be the tree or the mount. Fixes e1cbf92
2024-02-12 11:25:11 -05:00
Brian C. Lane
8389c6302e osbuild-depsolve-dnf5: Add module_hotfixes support 2024-02-12 17:08:32 +01:00
Simon Steinbeiss
c431e7e340 README: Add OSBuild's principles 2024-02-09 13:59:58 +01:00
Michael Vogt
c0f670f035 test: add manifests for bootc.install-to-filesystem
This commit adds example manifests for a bootc.install-to-filesystem
system. It does not do more with them because running a full test
requires a working podman which is difficult to use inside our
GH runners that are already running inside docker.
2024-02-09 12:03:09 +01:00
Michael Vogt
7dede7746d osbuild-mpp: add bootc.install-to-filesystem to process_containers 2024-02-09 12:03:09 +01:00
Michael Vogt
af360b0d71 stages: add test for bootc.install-to-filesystem 2024-02-09 12:03:09 +01:00
Ondřej Budai
226b50eba5 stages: add new org.osbuild.bootc.install-to-filesystem
Support the `boot install to-filesystem` capability to install a
bootc image to a filesystem.
2024-02-09 12:03:09 +01:00
schutzbot
a85b51bb2c Post release version bump
[skip ci]
2024-02-08 14:03:15 +00:00
Luke Yang
619a64f0bd stages/org.osbuild.qemu: make qcow2 compression optional
Modify the stages/org.osbuild.qemu stage such that compression is
optional. This resolves the image size differences between an image
built with coreos assember vs osbuild, as discussed in:
https://github.com/coreos/fedora-coreos-tracker/issues/1653#issuecomment-1928342241
2024-02-07 20:31:10 -05:00
Dusty Mabe
e1cbf92673 ostree: add convenience function for using default OSTree deployment
This adds a `default: true` option for all cases where OSTree
information is specified in schemas and allows for the information
to be picked up from the filesystem.

This is a safe operation because when building disk images there is
no known case where having two deployments makes sense. In the case
there ever were a case then the osname, ref, and serial options still
exist and can be used.

Co-authored-by: Luke Yang <luyang@redhat.com>
Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
2024-02-07 18:50:38 -05:00
Dusty Mabe
2021b915f1 stages(copy): allow copying from a mount or the tree
It seems like an artifical limitation to prevent copying from a mount
or from one location in the tree to another. It just so happens we need
this functionality when building CoreOS images because we want to take
a file embedded in the OSTree at a location and copy it to another
location in the tree. The particular example here is we want to copy
/usr/share/coreos-assembler/platforms.json -> /boot/coreos/platforms.json
See https://github.com/coreos/coreos-assembler/pull/3709

Allowing to copy from/to the tree we can now do something like:

```
- type: org.osbuild.copy
  options:
    paths:
      - from: tree:///usr/share/coreos-assembler/platforms.json
        to: tree:///boot/coreos/platforms.json
  mounts:
    - name: ostree.deployment
      type: org.osbuild.ostree.deployment
      options:
        deployment:
          ref: ostree/1/1/0
          osname:
            fedora-coreos
```
2024-02-07 18:38:03 -05:00
Diaa Sami
e023fdec1b osbuild-depsolve-dnf: port weak dependencies
ported from d48da99a12
2024-02-08 00:12:32 +01:00
Michael Vogt
705397e7f6 test: add simple zipl_inst tests
Co-authored-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2024-02-07 18:08:44 -05:00
Nikita Dubrovskii
e427289887 stages(zipl.inst): support appending kernel options
In some cases it could useful to add additional kernel options without
modifying BLS config, so any subsequent call to `zipl` would ignore them.
We are going to use this to append `ignition.firstboot` to kernel cmdline
for CoreOS on s390x.
2024-02-07 18:08:44 -05:00
Diaa Sami
c673eab2b5 osbuild-depsolve-dnf: port module_hotfixes support over
from 61e6f75281
2024-02-08 00:03:59 +01:00
Colin Walters
161c19601a container-deploy: Output stderr on failure
This stage was failing for me in bib, with this change I now
get more useful information from podman's stderr, e.g.:

```
RuntimeError: Failed to mount image (125): time="2024-02-06T14:23:06Z" level=error msg="Unmounting /var/lib/containers/storage/overlay/06456126e7c06cf1b21de024e08e64eddead2b8d03779be213e63aeeea9dec94/merged: invalid argument"
Error: creating overlay mount (...snip...)
fuse: device not found, try 'modprobe fuse' first
fuse-overlayfs: cannot mount: No such file or directory
```
2024-02-07 16:11:19 +01:00
Achilleas Koutsou
6e12f08a29 test: add bootupd.gen-metadata stage test
Since the stage depends on quite a specific tree state (ostree prepped
tree with boot files), we can't really unit test it any simpler than
generating a tree with and without running the stage and diffing the
tree.
2024-02-07 12:10:01 +01:00
Achilleas Koutsou
d75f43ff7b stages: add new org.osbuild.bootupd.gen-metadata stage
Runs bootupctl generate-update-metadata in the tree to transform
/usr/lib/ostree-boot into a bootupd-compatible update payload.

This stage should be run on the sysroot of an ostree deployment or
ostree-converted tree.
2024-02-07 12:10:01 +01:00
Dusty Mabe
011cf6851b stages(ostree.config): support setting sysroot.bootprefix
See https://github.com/ostreedev/ostree/pull/2705 and also
https://github.com/osbuild/osbuild/issues/1566.
2024-02-07 11:28:24 +01:00
Dusty Mabe
151b6e48ae stages(sgdisk): support label option
We only support `gpt` here so it would seem this option doesn't
make much sense to add, but it will make it so that the mpp-define-images
from osbuild-mpp can be passed in to `org.osbuild.sgdisk` just as it
can be passed in today to `org.osbuild.sfdisk`.
2024-02-06 17:44:31 +01:00
Nikita Dubrovskii
fc185dae8c support user-defined partition numbers for GPT disks
Partitions by default are indexed starting at 1, but in
some cases, such as CoreOS for IBM Z, it may be usefull
to set the 'partnum' for GPT disks explicitly, without
creating dummy partitions.

Now user can define an image:

```
    mpp-define-images:
      - id: image
        size: 10737418240
        table:
          uuid: 00000000-0000-4000-a000-000000000001
          label: gpt
          partitions:
            - name: boot
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 3
              size: 786432
            - name: root
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 4
              size: 4194304
```

So target disk would look like:

```
    Disklabel type: gpt
    Disk identifier: 00000000-0000-4000-A000-000000000001
    Device        Start     End Sectors  Size Type
    /dev/loop0p3   2048  788479  786432  384M Linux filesystem
    /dev/loop0p4 788480 4982783 4194304    2G Linux filesystem
```

This patch updates the osbuild-mpp tool and the sgdisk and sfdisk
stages to support this.

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
2024-02-06 17:44:31 +01:00
Michael Vogt
6b8c1872f6 fscache: use remove_lru() to reclaim space when the cache is full
This commit adds code that will remove the least recently used
entries when a store() operation does not succeeds because the
cache is full. To be more efficient it will try to free
twice the requested size (this can be configured in the code).
2024-02-06 17:16:48 +01:00