Commit graph

3077 commits

Author SHA1 Message Date
Michael Vogt
fe05b3084b sources: add regression test for issue##1693
There was a regression with the secrets adding of rhsm for the
curl source. This was my mistake (sorry!). Here is a regression
test that would have prevented this (if we have had it earlier).
2024-04-03 13:55:00 +02:00
Michael Vogt
1d4f2dc53b testutil: extract find_one_subclass_in_module() helper
A small refactor to avoid shipping this duplicated code (this
one is easy to extract/reuse).
2024-04-03 11:36:01 +02:00
Michael Vogt
79360b529a sources: add new sources_service fixture
Similar to the previous commit to include a `inputs_service` fixture
this does the same for `source.SourcesService` imports.

Note that we cannot easily share the helpers so we have to life with
a bit of very similar but duplicated code. To fix this we would have
to have a shared confftest.py that pytest can find. Which would mean
that we need to put the tests under a common dir that is reachable
via __init__.py files (which we currently not have because stages,
inputs etc do not have a __init__.py so python does not considers
them modules).
2024-04-03 11:36:01 +02:00
Michael Vogt
7c0e9cfcf7 inputs: add inputs_service fixture
This new fixture avoids some repetitivness when building tests
for input services.
2024-04-03 11:36:01 +02:00
Michael Vogt
5f31ccf9f2 test: add/use new testutil.make_fake_service_fd()
All inputs/sources tests need a fake service fd to instanciate
their services. Consolidate the creation in a single helper.
2024-04-03 11:36:01 +02:00
Pierre-Yves Chibon
cccdf8b784 osbuild-mpp: Expend information in PkgInfo
This way we can extract these information later on.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2024-04-03 10:29:49 +02:00
Ondřej Budai
dc85702553 Disable F40 CI (CVE-2024-3094 response) 2024-03-31 17:10:13 +02:00
Paweł Poławski
ae8f3f4a1e Stage: Schema migration to separated JSON files
In the past input schema for stages has been moved to standalone
JSON files. Looks like org.osbuild.tar was missed during the migration.
2024-03-30 11:03:29 +01:00
schutzbot
9a4f4552f5 Post release version bump
[skip ci]
2024-03-29 12:35:05 +00:00
Andre Marianiello
7e0e30fd8f curl: fix RHSM url retrieval 2024-03-29 13:02:11 +01:00
schutzbot
62e1570ef9 Post release version bump
[skip ci]
2024-03-27 08:18:03 +00:00
Michael Vogt
ec496769c5 stages: allow bootc.install-to-filesystem work without selinux
By default "bootc" will refuse to work on a non-selinux system if
the bootc container requires selinux. This is a sensible approach
in general but for us it's tricky because we want to be able to
generate images when running on developer machines or CI machines
that may not necessarily have selinux. So make bootc more relaxed.
2024-03-26 12:55:11 +01:00
Achilleas Koutsou
7f6dea860a github: add new workflow for checking json files
Reformat all json files in the repository and check that they're
formatted properly.
2024-03-26 01:20:37 +01:00
Achilleas Koutsou
0799328a6a devcontainer: fix json file
Fix the devcontainer.json (trailing comma).
2024-03-26 01:20:37 +01:00
Achilleas Koutsou
e837ebba76 schemas: reformat json files for consistencyo
Formatted with `js --indent 2 .`
2024-03-26 01:20:37 +01:00
Achilleas Koutsou
1366976dd8 test: reformat all json files
Reformat all test json files for consistency.

Formatted with `js --indent 2 .`
2024-03-26 01:20:37 +01:00
Achilleas Koutsou
fa0605b89f stages: reformat meta.json files
Reformat all meta.json files for consistency.

Formatted with `jq --indent 2 .`
2024-03-26 01:20:37 +01:00
Paweł Poławski
fa7f26a229 test: Add stage test trigger to makefile
Stage tests are located in the other place than module or run tests.
For consistency separated target in makefile is added.
2024-03-25 18:39:09 +01:00
Michael Vogt
0a72145b13 stages(chattr): fix rebase artifact 2024-03-25 18:26:53 +01:00
Renata Ravanelli
a847e6314c util: Rename function
- Rename parse_mount to find_mount_root.
 - Address other small changes

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-03-25 18:26:53 +01:00
Michael Vogt
465e55a860 util: change "assert" to raising an exception with context in parse_location() 2024-03-25 18:26:53 +01:00
Michael Vogt
249107a028 stages,test: fix lint errors and add basic unit tests
Add very simple unit tests as a starting point for the new
parsing functions in `util/parsing.py`.
2024-03-25 18:26:53 +01:00
Renata Ravanelli
6d4d1962eb util: Consolidate parse functions into util
- Move functions to the 'util' to centralize common
functionality, reducing code duplication and improving
maintainability across the codebase.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-03-25 18:26:53 +01:00
Michael Vogt
4f8ff6bc99 workflows: improve speed of test_stages and test_assemblers
The other tests have concurrency issues at the moment.

It seems in https://github.com/osbuild/osbuild/pull/1655 we lost
parallel running. The issue seems to be that `env` does not
actually define a shell environment but only a github environment.

This sets commit sets the shell env explicitly to unbreak us
again.
2024-03-23 15:38:34 +01:00
Michael Vogt
c5655c9006 osbuild: make the entire /etc/selinux avaialble for the buildroot
When moving to `bootc install to-filesystem` we need more information
for bootc from /etc/selinux than our current /etc/selinux/targeted/contexts
policy.

This commit makes all of /etc/selinux available which unblocks
the bootc install.
2024-03-22 11:24:35 +01:00
Tom Koscielniak
f9eea44083 Update manifest-db dependency to remove failing tests 2024-03-21 15:46:48 +01:00
Tom Koscielniak
3b7a8aa728 Migrate manifest tests to new RHEL GA version 2024-03-21 15:46:48 +01:00
Michael Vogt
345516e867 osbuild: ensure /var/tmp is a real directory
This is a followup for https://github.com/osbuild/osbuild/pull/1649

Instead of symlinking /var/tmp to /tmp which may be on a tmpfs
this commit puts it on a real filesystem.

This should fix:
https://github.com/osbuild/bootc-image-builder/issues/285
2024-03-20 20:36:26 +01:00
Michael Vogt
0528ccc3f0 osbuild: add support to exclude_paths to setfiles()
This is needed because on a mounted `bootc` container `setfiles`
without excluding `/sysroot` will create many warnings like:
```
setfiles: conflicting specifications for /run/osbuild/tree/sysroot/ostree/repo/objects/00/0ef9ada2ee87792e8ba21afd65aa00d79a1253018832652b8694862fb80e84.file and /run/osbuild/tree/usr/lib/firmware/cirrus/cs35l41-dsp1-spk-prot-103c8b8f-r1.bin.xz, using system_u:object_r:lib_t:s0.
```
but simply excluding this dir fixes them.
2024-03-20 18:05:51 +01:00
Michael Vogt
ba08a524a4 github: add cache key to generate.yml flow
There are recent GH failures because the github cache action
complains:
```
Input required and not supplied: key
```
This is slightly odd as we did not provide a cache key before and
it was fine but *shrug*. We also don't really need a cache key,
we always get the same cache, osbuild is smart enough to figure
it out.
2024-03-20 14:20:43 +01:00
Simon de Vlieger
6b4bb850a7 meta: ensure caps always a set
When loaded directly from JSON the caps are a list while they're
expected to be a set.
2024-03-19 15:32:45 +01:00
Simon de Vlieger
adea7d2acd stage: schema allows for empty descriptions 2024-03-19 15:32:45 +01:00
Simon de Vlieger
8f7d029e9f stage: schema allows for any of schema/schema_2
Instead of requiring only one of the properties to be present require at
least one of them being present; some stages specify both schema
versions (`org.osbuild.rpm`)
2024-03-19 15:32:45 +01:00
Simon de Vlieger
a9f4024ded lint: fix up adjusted stages 2024-03-19 15:32:45 +01:00
Simon de Vlieger
bb58892571 stages: externalize schemas
Copy all schemas into the relevant `.meta.json` files instead of having
them contained inside the stages.
2024-03-19 15:32:45 +01:00
Simon de Vlieger
02b6d696ef stages: consistent docstrings
Make docstrings consistent across stages regarding whitespace and
summary line.
2024-03-19 15:32:45 +01:00
Michael Vogt
352bf5cd52 curl: rename "transform" to "amend_secrets"
The curl source is the only source left that uses "transform". And
here the name is very generic but in fact we only do a single thing:
we add secrets for subscriptions for for mtls to the download.

So rename to make it clear what this is all about.
2024-03-19 14:21:57 +01:00
Michael Vogt
1fc7ead2f4 sources: transform() is only used in the curl sources, remove from ABC 2024-03-19 14:21:57 +01:00
Michael Vogt
7431653882 test: add (trivial) test for ConditionPathIsDirectory 2024-03-19 10:19:26 +01:00
Sayan Paul
548d2a51ea stage/unit-create:new systemd unit config params
Added new systemd unit config : ConditionPathIsDirectory

Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
2024-03-19 10:19:26 +01:00
Michael Vogt
155e24e4cb stage: user test that tests adduser is called the right way
The issue with mocking subprocess.call() is that we will not
catch if arguments are passed as eg. integers. So instead use
the `mock_command()` helper so that a real binary is called.
2024-03-18 20:37:21 +01:00
Michael Vogt
9393211b8a testutil: tweak mock_command to write a call_log
Instead of just mocking the binary also write a log of the way
it got called so that tests can use this to check if the right
options are passed.

Note that the API should be improved here, instead of returning
a "naked" path to the calllog file there should be a class wrapping
it. And of course there should be tests.
2024-03-18 20:37:21 +01:00
Michael Vogt
fd0167f130 test: return container_id in make_container
The current `make_container()` helper is a bit silly (which is
entirely my fault). It requires a container tag as input but all
tests end up creating a random number for this input. So instead
just remove the input and return the container_id from the podman
build in the contextmanager and use that.
2024-03-18 20:36:19 +01:00
Michael Vogt
df224fb32b stages: add support for kernel-options to bootc-install-to-fs
This commit adds support to use the `--kopt` arguments to
`bootc install to-filesystems`. It is not strictly needed right
now though.
2024-03-14 15:07:05 +01:00
Michael Vogt
626077ffc0 stages: add root ssh options to bootc.install-to-filesystem
To start using the `bootc.instal-to-filesystem` stage we need
to be able to test the generated images. This requires a login
on the disk. Traditionally we did that via the `users` stage.

But on a bootc system we do not want to modify the disk after
bootc did the install to avoid messing with things like the
selinux labels or (future) fsverity setups.

So for now we will use the `--root-ssh-authorized-keys` feature
to inject support for login.

So this commit adds a new option to the stage called
`root-ssh-authorized-keys`.
2024-03-14 15:07:05 +01:00
Michael Vogt
a7b4565445 meta: add tests for invalid python json/schema parsing
Based on the feedback from Tomáš in [0] this commit adds tests
that ensure consistent behavior between the python and the json
loader.

It's not 100% because the python is extremly leaniant and does
not even check if the required pieces of the json are there.
I.e. it will load a module without a SCHEMA or SCHEMA_2 variable
and the json loader code will warn about the issue but not
raise an error.

Fwiw, I have no strong opinion here but I do lean slightly towards
staying close to the original code (but both approaches of failing
with an exectption and continue with a warning have good arguments).

[0] https://github.com/osbuild/osbuild/pull/1618#discussion_r1521141148
2024-03-14 13:37:57 +01:00
Michael Vogt
9af7c9b279 meta: add .meta.json schema validation 2024-03-14 13:37:57 +01:00
Michael Vogt
3e11b57815 meta: rename -meta.json to .meta.json
With `.meta.json` it's two "real" file extension. The `-meta.json`
feels less clear.
2024-03-14 13:37:57 +01:00
Michael Vogt
16d30254c4 tox,osbuild: deal with stages that have external json data
Some existing code/test assumes that anything in `stages/` is
executable. This commit fixes this and excludes e.g. json from
lintables.
2024-03-14 13:37:57 +01:00
Michael Vogt
9b09ed9eb4 osbuild: allow json data to come from a {stage}-meta.json file
Instead of always parsing the python stage to load meta information
allow the user of a new `{stage}-meta.json` file. This is a first
step towards allowing modules to be written in a different language
than python. It also has some practical advantages:
- slightly faster as it avoids calling python to output the schemas
- easier to write schemas as this can be done in a real json editor
  now
- more extensible in a future where stages maybe binaries with
  shlib dependencies that are only satisfied in the buildroot
  but not on the host
2024-03-14 13:37:57 +01:00