Commit graph

3368 commits

Author SHA1 Message Date
Brian C. Lane
3bed7c7ace grub2.inst: Add support for creating iso9660 boot image
Don't include the "location" offset, and use just a path for the prefix
section to set the path of the grub2 modules on the iso. eg.

{
    "filename": "eltorito.img",
    "platform": "i386-pc",
    "core": {
        "type": "mkimage",
        "partlabel": "gpt",
        "filesystem": "iso9660"
    },
    "prefix": {
        "path": "/boot/grub2/"
    }
}
2025-01-13 22:53:02 +01:00
Brian C. Lane
41c0550a1f tests: Add simple test for org.osuild.grub2.inst stage
Tests that grub2-mkimage ran without errors, and that the image file
actually has something written to it.
2025-01-13 22:53:02 +01:00
Achilleas Koutsou
67f344fa52 tools/osbuild-image-info: append mountpoint to mount ID
The mount ID must be unique.  So far, we were using the device as the ID
for the mount because that was unique to each mount.  With btrfs
subvolumes however, the device and partition are the same for all, so we
need another way to differentiate.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
30d1faabdd tools/osbuild-image-info: move fstab search to function 2025-01-10 17:18:05 +01:00
Achilleas Koutsou
e513820518 tools/osbuild-image-info: handle root on subvol
Btrfs volumes typically only contain subvolumes instead of (parts of)
the OS tree directly.  In our images in particular, this is always the
case.  When searching for root to find /etc/fstab, search through the
subvolumes on a btrfs volume for the file and return the path to the
root subvolume.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
a16582b8c7 tools/osbuild-image-info: Mount() with partition=None
Always set partition=None for the kwargs of the Mount() constructor.

The previous code was added for backwards compatibility with older
versions of the Mount() constructor that didn't include the 'partition
argument.  It's safe to remove now because:
1. It's been long enough that we wont run osbuild-image-info with an old
   version of osbuild.
2. The tool is packaged with osbuild so there is no version drift and no
   compatibility issues.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
10029167db tools/osbuild-image-info: fail early if fstab isn't found
When the fstab file isn't found, the root_tree will never be set after
being initialised to "" and an exception is raised "The root filesystem
tree is not mounted".  It's a lot clearer if the failure happens closer
to the root cause, which is that fstab wasn't found and there are no
fstab entries to iterate through and find the root filesystem.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
dc047513b7 tools/osbuild-image-info: skip swap partitions
When iterating partitions to mount, skip any with filesystem type
"swap".  This is done in two places:
1. When mounting partitions to find /etc/fstab.
2. When mounting partitions and volumes to analyse the tree.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
b9e84587ad tools/osbuild-image-info: store fstype when iterating parts
When iterating through partitions, store the fstype along with the other
information.  This will be useful for identifying btrfs partitions,
which we will need to scan for subvolumes, and for identifying swap
partitions, so we can avoid trying to mount them.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
fc4232af63 tools/osbuild-image-info: print fstype in error
Print the unrecognised fstype string when failing.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
0553465306 tools/osbuild-image-info: fix typos in docstrings and comments 2025-01-10 17:18:05 +01:00
Achilleas Koutsou
ac83e4541c tools/osbuild-image-info: code quality and style improvements
Run isort for imports.
Pylint: wrong-import-order / C0411
Solves the following linter warnings:
- standard import "pathlib" should be placed before third party import
  "yaml"
- standard import "collections.OrderedDict" should be placed before
  third party imports "yaml", "jsonschema"
- standard import "typing.Dict" should be placed before third party
  imports "yaml", "jsonschema"

Fix default arg values.
Pylint: dangerous-default-value / W0102
- Using mutable default values ([]) for function arguments is considered
  dangerous.

Rename format variable.
Pylint: redefined-builtin / W0622
- 'format' is a built-in function.

Use f-strings instead of formatting where possible.
Pylint: consider-using-f-string / C0209

Remove unnecessary else after returns.
Pylint: no-else-return / R1705

Remove unnecessary else after continue.
Pylint: no-else-continue / R1724

Set the encoding (utf-8) for all calls to open().
Pylint: unspecified-encoding / W1514

Disable the too-many-branches and too-many-statements warnings for
append_partitions() and append_filesystem().  We can refactor the
functions to make them smaller later, but for now we're addressing only
the simpler issues.

Initialise with dict literal instead of call to function.
Pylint: use-dict-literal / R1735

Use implicit truthiness for glob instead of len().
Pylint: use-implicit-booleaness-not-len / C1802

Rename ambiguous variable 'l' to 'line'.
pycodestyle: ambiguous-variable-name (E741)

Merge comparisons with 'in'.
Pylint: consider-using-in / R1714
2025-01-10 17:18:05 +01:00
Brian C. Lane
fd19ab41fb org.osbuild.xorriso: Add support for grub2 bootable iso
This creates an iso matching the current method used in Fedora where it
uses grub2 for BIOS and UEFI booting. Pass the path to the grub2 hybrid
mbr to the stage in the 'grub2mbr' field. eg.
    "grub2mbr": "/usr/lib/grub/i386-pc/boot_hybrid.img"
2025-01-06 21:23:23 +01:00
Tomáš Hozza
2f82179268 test_util_path: extend test coverage of join_abs()
Add additional test cases for the `join_abs()` function based on a
suggestion from the PR review.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
6a4a7c31c6 Stages/test/tuned: handle "improved" jsonschema messages
python-jsonschema improved the error messages for some special cases
since v4.21.0 [0], which means that we need to handle multiple versions
of the error message in unit tests.

[0] 8875c2ecb1 (diff-c21226b904760a669a70785494cd8ecf5fb1e7415fd25765dd02f0ad00394099R231)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
806f949e8c Stages/dnf5.sbom.spdx: don't use format strings for constructing paths
Use the new helper function `osbuild.util.path.join_abs()` for
constructing paths.

Fix #1964

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
b6dd45af4d Stages/dnf4.sbom.spdx: don't use format strings for constructing paths
Use the new helper function `osbuild.util.path.join_abs()` for
constructing paths.

Fix #1964

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
89f94af60d Stages/tuned: don't use format strings for constructing paths
Use the new helper function `osbuild.util.path.join_abs()` for
constructing paths.

Fix #1941

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
8463394d2c util/path: add join_abs() to join potentially absolute paths
It turned out that in many cases, stages need to join two absolute
paths, the pipeline tree path and the path on a booted system. However,
the standard `os.path.join()` function can't handle such situation as
just prepending the root to the subsequent paths.

Add a new helper function, which is able to join any paths together,
regardless if any of them is absolute or not. If the root is not
absolute, the result will be made absolute to the filesystem root `/`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
67d9663c83 Stages/tuned: skip non-existing profile directories
Previously, the stage would try to call `os.scandir()` on non-existing
profile directories, which results in an exception. While the
directories that it scans are currently created by the TuneD RPM package
when installed, it it much nicer to gracefully handle their potential
non-existence, than to fail with an exception.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
350ae9ed40 Stages/tuned: require profile to be non-empty string
The stage schema previously accepted an empty string as a profile name.
This would not work in practice, therefore extend the schema to require
non-empty strings.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
d7d41b477b Stages/tuned: add unit tests for the stage.
Fix #1941

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
f173efea56 Stages/dnf*.sbom.spdx: explicitly mention DNF version in the summary
Explicitly mention the used DNF version in the stage summary.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
Tomáš Hozza
ee3f0ab59a tools/osbuild-image-info: make read_boot_entries() more robust
`read_boot_entries()` could previously fail when trying to split lines
in bootloader entries, which contained only "\n" and became empty
string after stripping whitespace characters. This is the case e.g. on
F41 images.

Moreover, bootloader entries can contain comments as lines starting with
"#", which were previously not ignored by the function and would end up
in the parsed entry and could potentially fail to be split.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-04 10:37:05 +01:00
Tomáš Hozza
2c3f528488 Test: add unit test for osbuild-image-info's read_boot_entries()
Add unit test for osbuild-image-info's `read_boot_entries()` function,
to ensure that it can handle various situations that can happen in the
real world.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-04 10:37:05 +01:00
Brian C. Lane
902c4f7d71 erofs: Add ability to set the cluster size
`cluster-size` sets the maximum size of compress physical cluster size
in bytes.
2025-01-03 12:05:56 +01:00
Brian C. Lane
1ab098fbf9 erofs: Add zstd to the list of supported compression algorithms
This is supported in erofs-utils 1.8 and later.
2025-01-03 12:05:56 +01:00
schutzbot
51116309ad schutzfile: Update snapshots to 20250101 2025-01-03 11:56:01 +01:00
Tomáš Hozza
8924392db3 Schutzbot: update terraform ref
This should fix the F39 runner bootstrapping issues.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-03 11:15:25 +01:00
Achilleas Koutsou
63358b131d schutzbot: update Achilleas' ssh keys 2025-01-02 18:36:05 +01:00
Colin Walters
fcb93bde01 kickstart: Drop ostree signature verification flag
It's a no-op nowadays, we dropped support for the custom
ostree-container signature verification status.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-18 16:34:30 -08:00
schutzbot
08d0b657ee Post release version bump
[skip ci]
2024-12-18 20:00:01 +00:00
Dusty Mabe
cd19587464 stages/coreos.live-artifacts: move rename of vendor dir
Seems more appropriate in copy_configs_and_init_kargs_json() since this
is where files were originally copied in.
2024-12-18 11:09:29 -05:00
Dusty Mabe
d5aff7b1af stages/coreos.live-artifacts: drop usage of dir fd
Rework rename of vendor directory to not use dfd APIs.

This was requested in code review.

Also added comments since I now understand it better.
2024-12-18 11:09:29 -05:00
Dusty Mabe
45583720af stages/coreos.live-artifacts: stop chmod initrd.img
The initramfs.img in Fedora and RHEL CoreOS images is already 644
so this isn't needed.
2024-12-18 11:09:29 -05:00
Dusty Mabe
b8d986b51c stages/coreos.live-artifacts: drop kernel rename for s390x
The rename to get file names + suffix with < 8 characters
was done in [1] when our initramfs was named initramfs.img.
It was subsequently renamed to initrd.img in [2] and the
rename of the initramfs was dropped but the rename of the
kernel was never dropped. Since vmlinuz is already < 8
characters let's just drop the rename here too.

[1] 60400910bb
[2] 6f533ef55e
2024-12-18 11:09:29 -05:00
Michael Vogt
af710ee740 stage: add test for core live-artifacts stage
This commit adds some unit tests around the coreos live-artifcats
mono stage.

- test/coreos_live_artifacts: add test for align_initrd()
- test/coreos_live_artifacts: add test for extend_initramfs()
    - This actually tests the mkinitrd_pipe() function, which
      extend_initramfs() calls after opening the file.
- test/coreos_live_artifacts: add test for make_stream_hash()
- test/coreos_live_artifacts: add test for make_efi_bootfile()

Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
2024-12-18 11:09:29 -05:00
Achilleas Koutsou
4e93a66311 stages/coreos.live-artifacts: refactor into more functions
This improves the readability and maintainability of the code to
have it split into smaller pieces.

Co-Authored-by: Dusty Mabe <dusty@dustymabe.com>
2024-12-18 11:09:29 -05:00
Jonathan Lebon
0331e6f313 stages: add coreos.live-artifacts.mono stage
This adds a new `org.osbuild.coreos.live-artifacts.mono` stage to build
CoreOS Live ISO/PXE artifacts. The code is heavily based on the
`cmd-buildextend-live` script from coreos-assembler [1], but a lot of
things had to be adapted:
- the stage is provided the deployed oscontainer tree, metal, and
  metal4k images as inputs
- we use chroot instead of supermin to execute some commands in the
  context of the target oscontainer
- a bunch of calls that were wrapped by libguestfs for us (e.g.
  mkfs.vfat, mksquashfs), we now have to call ourselves; to retain
  maximum compatibility, we ensured that we still effectively use the
  same args that libguestfs passed

And various other minor adjustments.

Of course, this is not really in line with the OSBuild philosophy
of having smaller-scoped stages. We have labeled this with a .mono
suffix to denote it is monolithic, similar to the existing
`org.osbuild.bootiso.mono` stage today.

Eventually we may be able to break this stage down if we find it worth
the effort. Alternatively the need for it may go away as we align more
with Image Mode.

[1] 43a9c80e1f/src/cmd-buildextend-live

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
Co-authored-by: Renata Ravanelli <renata.ravanelli@gmail.com>
2024-12-18 11:09:29 -05:00
Dusty Mabe
b7e3268ef0 manifests: updates for FCOS manifest
There have been a lot of changes to the CoreOS definitions in [1].
Let's update the test manifest here to more closely match what is
running in the field there.

[1] dcd60cfe01/src/osbuild-manifests
2024-12-18 11:09:29 -05:00
Dusty Mabe
aa11ec1ec1 test: add podman to fedora-build-v2 manifest
The org.osbuild.container-deploy stage uses podman. Including it
in the build here will allow that stage to be used with this
pipeline as the buildroot.

Include a workaround here for what I consider to be a bug [1] in that
`podman` will create `/etc/containers/networks` on first run if it
doesn't exist. That dir should just be created by an RPM. If we
don't include this workaround then the stage will fail when `podman`
attempts the `mkdir` because `/etc/containers` is mounted in from
the buildroot readonly.

[1] https://github.com/containers/common/pull/2265
2024-12-18 11:09:29 -05:00
Tomáš Hozza
139837f628 manifest_tests.py: use osbuild-image-info from osbuild package
Modify the test case to not use the image-info copy from manifest-db.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
503cfb0936 CI: move the manifest_tests.sh from schutzbot/ to test/cases/
The test script should have been in the test/cases/ directory in the
first place.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
e90a74f088 SELinux: apply osbuild_exec_t to /usr/bin/osbuild-image-info
This is needed, for the tool to be able to read SELinux labels from the
inspected image, which are not known to the host on which it is running.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
6738679f2e SPEC: include osbuild-image-info in the -tools subpackage
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
dde7da1528 setup.py: install tools/osbuild-image-info
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
bced04b57d tools/osbuild-image-info: fix issues reported by autopep8
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
0f99200ba1 tools: add image-info tool as osbuild-image-info
Add the image-info tool as osbuild-image-info from the manifest-db
repository [0]. This is an exact copy without any changes.

[0] 8e05a898d4/tools/image-info

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 12:50:32 +01:00
Tomáš Hozza
7699f8134f Add org.osbuild.dnf5.sbom.spdx stage
Add DNF5 version of the `sbom.spdx` stage, which generates an SPDX SBOM
document from a given FS tree using libdnf5 API.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-18 05:46:45 +01:00
Simon Steinbeiss
cdf8856f19 github/actions: Enable /jira-epic slash commands
This change allows for using the command to create Jira Tasks under a
given Epic both in a pull request comment or in the pull request
description.
2024-12-16 11:02:34 +01:00