Commit graph

2504 commits

Author SHA1 Message Date
Paweł Poławski
cd1c5f04a3 tools: add Fedora 38 runner for OSTree image tests
OSTree tests are executed on RHEL 8, RHEL 9 and F37 runners.
This commit adds F38 to the runners list.
2023-11-06 13:44:43 +01:00
Brian C. Lane
73dc9fe50e tools: Add helper script to check Schutzfile and gitlab-ci.yml runners
This script reads the RUNNER entries from .gitlab-ci.yml and the
snapshot repo names from Schutzfile. It then prints which runners don't
have entries in Schutzfile and which Schutzfile entries don't have
runners.

This is slightly complicated by the fact that centos-stream reports
itself as centos. So when checking for missing entries they are
considered to be the same thing. eg. If centos is a RUNNER and
centos-stream is in Schutzfile it doesn't report anything missing.
2023-11-03 08:02:16 -07:00
Michael Vogt
1eefb9b55d tests: add kickstart stage test
This commits adds a stage based test for the `kickstart`
configuration.
2023-11-03 13:29:04 +01:00
Michael Vogt
a5ebd9a06f kickstart: add lang,keyboard,timezone to the supported options
This commit adds support for the following kickstart options:
- lang
- keyboard
- timezone
2023-11-03 13:29:04 +01:00
Tomáš Hozza
15c3c0a27e stage/copy: fix exception msg when parsing mounts and inputs
Functions for parsing mounts and inputs raise an exception if the
referenced entity can't be found in the stage options. However, the
exception message always included the value of the `root` variable,
which is `None` when an exception is risen. Instead of the `root`
value, the `name` variable with the entity name should be used.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-11-01 15:26:05 +01:00
schutzbot
49f987fe8e schutzfile: Update snapshots to 20231101 2023-11-01 10:30:11 +01:00
Jakub Rusz
fd29a31832 rpmbuild: build on RHEL-9.4 and RHEL-8.10 2023-10-31 12:50:03 +01:00
Tomáš Hozza
4b44fedbb9 Check: lint Packit configuration as part of CI
This will ensure that our Packit config stays valid.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-31 09:21:02 +01:00
Tomáš Hozza
1395c812ca Packit: handle only tags without a 'dot'
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-31 09:21:02 +01:00
Ondřej Budai
23de60cd23 stages/mkdir: fix its schema
The items of an array are defined under the `items` key, not under `paths`.
Let's fix this.

Btw, this is possible because JSON Schema itself doesn't use
additionalProperties = false. This allows extending the schemas easily, but
is sadly a bit error-prone.

Sadly, since this issue effectively disabled validation of the stage options,
we also need to relax the schema a bit:

We found out that there are manifests in the wild, that use relative paths,
instead of absolute ones. Thus, this commit changes the validation regex to
allow relative paths. However, this now emits a warning and it's strongly
discouraged. The associated stage test was modified to accommodate for this.

Co-authored-by: Tomáš Hozza <thozza@redhat.com>
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-30 13:31:15 +01:00
Alexander Larsson
0c144fc4aa Add selinux-label-version to the org.osbuild.ostree.commit stage
This is a feature that was added in rpm-ostree 2023.10 and is needed
for the new transient /etc feature to work. What it does is change the
labeling of /usr/etc to match those of /etc, so that /usr/etc can be used
directly as a bind-mount or an overlay mount when mounted on /etc.

See https://github.com/coreos/rpm-ostree/pull/4640 for details.
2023-10-28 15:37:56 -04:00
Simon de Vlieger
1542813296 depsolve-dnf: helpful exception for repo 2023-10-26 15:53:47 +02:00
Simon de Vlieger
f371651d66 depsolve-dnf: enable weak deps selection
The import of `dnf-json` came from `osbuild-composer`, as we sadly
have/had multiple copies this wasn't the *right* version as it was
lacking previous work to disable weak dependencies.
2023-10-26 15:11:24 +02:00
Dusty Mabe
d4b3e3655d objectstore: also mount /etc/containers for "host" buildroot
In the case we are not using a buildroot (i.e. we are using
the host as the buildroot) let's also mount in /etc/containers
into the environment. There are sometimes where software running
from /usr can't operate without configuration in /etc and this
will allow it to work.

An example of software hitting this problem is skopeo. With a
simple config like:

```
version: '2'
mpp-vars:
  release: 38
pipelines:
  - name: skopeo-tree
    # build: name:build
    source-epoch: 1659397331
    stages:
      - type: org.osbuild.skopeo
        inputs:
          images:
            type: org.osbuild.containers
            origin: org.osbuild.source
            mpp-resolve-images:
              images:
                - source: quay.io/fedora/fedora-coreos
                  tag: stable
                  name: localhost/fcos
        options:
          destination:
            type: containers-storage
            storage-path: /usr/share/containers/storage
```

We end up hitting an error like this:

```
time="2023-10-24T18:27:14Z" level=fatal msg="Error loading trust policy: open /etc/containers/policy.json: no such file or directory"
Traceback (most recent call last):
  File "/run/osbuild/bin/org.osbuild.skopeo", line 90, in <module>
    r = main(args["inputs"], args["tree"], args["options"])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/osbuild/bin/org.osbuild.skopeo", line 73, in main
    subprocess.run(["skopeo", "copy", image_source, dest], check=True)
  File "/usr/lib64/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['skopeo', 'copy', 'dir:/tmp/tmp5_qcng99/image', 'containers-storage:[overlay@/run/osbuild/tree/usr/share/containers/storage+/run/containers/storage]localhost/fcos']' returned non-zero exit status 1.
```

This PR adds in a mount for /etc/containers from the host so that
/etc/containers/policy.json can be accessed.
2023-10-25 22:05:54 +02:00
schutzbot
5579257c65 Post release version bump
[skip ci]
2023-10-25 08:14:34 +00:00
Dusty Mabe
41652343a4 manifests: add fedora-coreos-container example/test
This example shows how to build a qcow2 very similar to the one
delivered by Fedora CoreOS. It uses an input container that has
the Fedora CoreOS OSTree already baked into it, which means that
the OSTree isn't built using this manifest, but taken as an input
from a remote registry.
2023-10-24 13:46:10 -04:00
Dusty Mabe
da07300f38 stages/ostree.deploy: create ostree_commit_deploy function
This drains some of the logic out of `main()` into a
`ostree_commit_deploy()` function. Doing this will make it easier
to diff this stage with the recently added `ostree.deploy.container`
stage.

This commit also changes the `ref` in the schema to be optional,
which is a fixup for 3cc733d. We need to make the ref optional because
the ref could come from the user in the toplevel schema or it could
come from input commit in the schema.
2023-10-24 13:46:10 -04:00
Luke Yang
f9a039d068 stages: add ostree.deploy.container stage
This stage is similar to ostree.deploy, but deploys from a container
image rather than from an OSTree commit by using the `ostree container
image deploy` command. An example stage definition could look like:

```
  - type: org.osbuild.ostree.deploy.container
    options:
      osname: fedora-coreos
      target_imgref: ostree-remote-registry:fedora:quay.io/fedora/fedora-coreos:stable
      mounts:
	- /boot
	- /boot/efi
      kernel_opts:
	- rw
	- console=tty0
	- console=ttyS0
	- ignition.platform.id=qemu
	- '$ignition_firstboot'
    inputs:
      images:
	type: org.osbuild.containers
	origin: org.osbuild.source
	mpp-resolve-images:
	  images:
	    - source: quay.io/fedora/fedora-coreos
	      tag: stable
```

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
2023-10-24 13:46:10 -04:00
Dusty Mabe
49acf488af stages/ostree.deploy: add description for commits input 2023-10-24 13:46:10 -04:00
Achilleas Koutsou
dd2aa57987 test: update stage diffs
Diffs for stage tests have changed after the sources were updated.
Update them to match expected behaviour.
2023-10-21 07:34:32 +02:00
Dusty Mabe
ca3b831c29 manifests/fedora-vars: bump snapshot date
This should correspond to the snapshots from 6b85149.
2023-10-21 07:34:32 +02:00
Evgeny Kolesnikov
c4de5389e7 stages/oscap.remediation: Properly utilize offline capabilities
The scanner will now properly react to the chroot environment. Also,
there are some optimizations to logs and results.
2023-10-19 12:43:57 +02:00
Dusty Mabe
b32ddc4136 tools/osbuild-mpp: include container tag in default name
In case the tag was something other than `:latest` let's include the
tag in the default name.
2023-10-18 19:55:26 +02:00
Michael Ho
258735d8a6 test/stages/users: make test data date agnostic
The test for this stage is failing because etc/shadow changes content
depending on the date that it runs on (due to the "date of last password
change" field). This causes the checksums to not be constant for our
tests and depends on the date.

This commit removes the checksums for etc/shadow from the test so that
they are not checked as part of the test. This worksaround the test
failure issue for now until a solution to the dynamic contents is
determined.

Signed-off-by: Michael Ho <michael.ho@ieee.org>
2023-10-18 13:56:20 +02:00
Alexander Larsson
745f86c94c tools/osbuild-mpp: Really fix empty ostree commit object in deploy stage
The fix in 980ca03685 ensured that
no empty commit object was changed, but it still created an (empty)
input object, which causes failures, like:
 https://gitlab.com/CentOS/automotive/sample-images/-/merge_requests/388

We need to move the check before the line that adds the empty default
input object.
2023-10-17 14:02:39 +02:00
Simon de Vlieger
7c35b945ee depsolve: import dnf-json
Import the `dnf-json` Python script that is included in the "images" and
"osbuild-composer" repository into "osbuild".

`dnf-json` provides dependency solving capabilities by taking in some
JSON and then outputting the package set that JSON resolves to. Since it
is a Python script it moves into a subpackage of `osbuild`.

The script is renamed to `osbuild-depsolve-dnf`.
2023-10-16 20:47:17 +02:00
Luke Yang
980ca03685 tools/osbuild-mpp: Fix empty ostree commit object in deploy stage
This adds an early return to the `_process_ostree_commits` function to
prevent an empty ostree commit object from being created in the deploy
stage which causes violations to the deploy stage input schema.
2023-10-16 20:26:10 +02:00
Dusty Mabe
ecc997a81a tools/osbuild-mpp: add mpp-resolve-ostree-commits helper
This will make it easier to resolve OSTree refs into commits similar
to how mpp-resolve-images works for container image references to
SHA256 digests.
2023-10-16 20:26:10 +02:00
Dusty Mabe
8844bc260e osbuild/util/ostree: create setup_remote function
This moves the setup_remote function from the ostree source into
util/ostree. This is prep for sharing this function with an mpp
helper in the future.
2023-10-16 20:26:10 +02:00
Dusty Mabe
f4ab2f43e2 sources/ostree: leverage util/ostree library code
Similar to the cleanups in 4e99e80, let's start using the library
code for the calls to ostree here.
2023-10-16 20:26:10 +02:00
Dusty Mabe
7de357f1a9 inputs/ostree: leverage util/ostree library code
Similar to the cleanups in 4e99e80, let's start using the library
code for the calls to ostree here.
2023-10-16 20:26:10 +02:00
Achilleas Koutsou
cf14de3558 test/stages/users: extend to add ssh keys
Added three users to the test to test all combinations of ssh key
definitions:
- a user called `onekey` that has a single key defined in the `key`
  option.
- a user called `multikey` that has a multiple keys defined in the
  `keys` array.
- a user called `bothy` that defines both a single key in the `key`
  option and two other keys in the `keys` array.
2023-10-16 18:05:27 +02:00
Michael Ho
21054b181c stages/org.osbuild.users: support multiple SSH keys
Add a new attribute, "keys", to allow specifying multiple public SSH
keys to install to a users authorized_keys file.

This maintains backwards compatibility with the existing "key" attribute
that can only specify a single SSH key to install into the file (without
using some newline hacks).

Signed-off-by: Michael Ho <michael.ho@ieee.org>
2023-10-16 18:05:27 +02:00
schutzbot
6b851493c1 schutzfile: Update snapshots to 20231015 2023-10-16 14:49:34 +02:00
schutzbot
d66d58ae8a schutzfile: Update snapshots to 20231012 2023-10-13 00:20:46 +02:00
schutzbot
f0982873e2 Post release version bump
[skip ci]
2023-10-11 08:14:13 +00:00
Dusty Mabe
3cc733d7cd stages/ostree.deploy: support an ostree input
This will allow a user to specify an input directly to the deploy
stage rather than requiring a ostree.pull stage to be called first.

Adding inputs will also be useful when we soon add support for
deploying from a container rather than just deploying from an existing
ostree commit in a repo.
2023-10-06 15:55:26 +02:00
Dusty Mabe
c6c9454f6f osbuild/util: create pull_local function in util/ostree
This is prep for sharing this functionality with other stages than
the ostree.pull stage.
2023-10-06 15:55:26 +02:00
Dusty Mabe
4e99e80c4a osbuild/util: hoist ostree code into util/ostree
Prep for sharing with other stages later.
2023-10-06 15:55:26 +02:00
Dusty Mabe
34d3471fdd stages/ostree.passwd: delete dead code ostree function
As far as I can tell this is unused in this file.
2023-10-06 15:55:26 +02:00
Dusty Mabe
0f477889be stages/ostree: add deprecation notice/warning
I've been informed that this stage is old and shouldn't be used for
newly created manifests. Let's add a comment to the top for future
explorers of this code base.
2023-10-06 15:55:26 +02:00
Maxime Ripard
7af2f1a5c1 Create additional option to setup FS geometry
Some platforms like the TI AM62 require a particular FAT geometry for
their CPU to read the file system (and thus the bootloader). Failing
that the CPU will simply not boot and keep looking for a bootloader.

Let's add some options to enforce a particular filesystem geometry
through the -g option of mkfs.fat.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
2023-10-05 20:17:40 +02:00
Maxime Ripard
e58fc3d289 Consolidate the options setup for mkfs.fat
The current options building code for mkfs.fat prevents to have multiple
options at a time since it will assign the opts list to either the label
or fatsize options.

If both are set, only the last one, fatsize, will be set.

Use the occasion to rewrite the code a bit and limit the number of
lists concatenation.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
2023-10-05 20:17:40 +02:00
Dusty Mabe
4e5de3808e osbuild/util: add containers_source helper
This will hoist even more code into util out of the skopeo stage.
Now a caller can call:

    with containers.container_source(image) as (image_name, image_source):
        print(f"{image_name}, {image_source}")

to process containers inputs.
2023-09-30 02:29:05 +02:00
Dusty Mabe
4cd9af47d0 osbuild/util: hoist container handling code into util/containers
This hoists container handling code from the skopeo stage into
util/containers. It is prep for adding another stage that accepts
containers as an input. The code is common so we should share it
amongst all stages that use containers as input.
2023-09-30 02:29:05 +02:00
Otto Fowler
cfe7818771 fix link to developer guide 2023-09-29 07:01:56 -07:00
Dusty Mabe
c88b3982e8 stages/ostree.deploy: switch to v2 schema
Prep for possibly adding inputs to the ostree.deploy stage in the
future.
2023-09-28 21:38:58 +02:00
Achilleas Koutsou
7b359e3ecd Update Fedora 39 x86_64 runner 2023-09-28 09:15:53 -07:00
schutzbot
ad2fed1a3b Post release version bump
[skip ci]
2023-09-27 08:13:30 +00:00
Michael Vogt
e48360e01c docs: update the samples used in osbuild.1.rst
The file `./samples/base-qcow2.json` used in the osbuild.1.rst
man-page does no longer exists. It was removed in e92b409 and
`samples` is now a symlink into the test data. The closest in
the test data to the original `base-qcow2.json` seems to be
the `fedora-boot.json` so this is now used in the examples
section.

This removes the references to `./samples/base-rpm-qcow2.json`
which was remove in fe95d93. Here `fedora-boot.json` is also
used.
2023-09-18 22:13:09 +02:00