Commit graph

277 commits

Author SHA1 Message Date
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
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
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
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
Michael Vogt
5c345fb3fa test,tools: use sys.executable instead of hardcoding python3
Thanks to Simon!
2023-11-14 20:34:50 +01:00
Michael Vogt
d801ef3958 tests: run osbuild as a python module in gen-stage-test-diff
Instead of running osbuild as a binary use `python3 -m osbuild`
(just like in `test/test.py:compile()`) so that it will use
osbuild fromgit and can be run from a checkout without the need
for an installed osbuild.
2023-11-14 20:34:50 +01:00
Michael Vogt
742291eac3 tools: fix cache-max-size defaults 2023-11-14 20:34:50 +01:00
Ondřej Budai
3bb5a00375 test/run/assemblers: convert to a v2 manifest
Instead of using the F34-based manifests, let's switch to F38. I tried my
best to import the vars into the new manifest, but I don't think that's
currently supported.
2023-11-14 10:45:44 -08:00
Michael Vogt
d52738d70c tools: add "tools" dir to LINTABLES and fix issues
The `./tools` dir was not part of the LINTABLES in the `tox.ini`
which meant that pep8/pylint etc checks were not run on the tools
there.

This commit adds it and fixes the issues that `make lint` found.
2023-11-13 10:10:12 +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
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
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
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
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
Brian C. Lane
68f4c5bd5f tests: Add a check for valid snapshot urls
This pulls the list of snapshots from the rpmrepo API, greps the
codebase for all uses of rpmrepo.osbuild.org that look like a snapshot
name, and then checks to make sure they are still valid.

This is the same script as osbuild-composer, except that it also skips
checking ./test/data/stages/ which has rpm urls that look like snapshot
urls.
2023-08-16 10:40:05 +02:00
Brian C. Lane
44c28c8c16 autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
Ondřej Budai
5045bde6b7 tools/tree-diff: make its output stable
I don't see a reason why not to make the default output from tree-diff always
stable.

The stage tests already do that before running the comparison.
2023-08-08 12:41:17 +02:00
Ondřej Budai
04c545c39c tools: introduce a tool for generating diffs for stage tests
There hasn't ever been an official tool for this and everyone was just using
the output from the test to generate the diff. This commit introduces a proper
tool for generating these files.
2023-08-08 12:41:17 +02:00
Simon de Vlieger
a7b75bea3b osbuild-dev: use sys.exit
For consistency with the rest of the codebase, switch `osbuild-dev` over
to use `sys.exit` instead of `SystemExit`.
2023-07-20 15:29:35 +02:00
Simon de Vlieger
b9876690f6 osbuild-dev: add --simple to diff
This option switches to `diff -u` instead of `vimdiff`.
2023-07-20 15:29:35 +02:00
Simon de Vlieger
dce36ab420 osbuild-dev: properly exit and validate manifest 2023-07-20 15:29:35 +02:00
Simon de Vlieger
9525655fb4 osbuild-dev: understand more input formats
The schemas allowed for `inputs` changed a while back; most new
manifests use a different format than what `osbuild-dev` initially
understood.

This adds all schemas.
2023-07-20 15:29:35 +02:00
Eric Chanudet
9a42ce04ac tools/osbuild-mpp: mpp-define-image sfdisk attrs
Add the translation logic to handle the attrs field of sfdisk as
supported by org.osbuild.sfdisk and documented in its schema. With the
schema taking an int array, some translation is required to populate the
sfdisk command appropriately.

Amend the example schema to reflect the change.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
2023-05-25 14:57:28 +02:00
Tomáš Hozza
b92168bc16 tools/tree-diff: don't pass file descriptor to os.scandir()
`os.scandir()` can accept file descriptors only since Python 3.7. The
tool would previously fail with exception when run using Python 3.6.
The solution is to provide a path, which is done using a symlink in
procfs (this is already used within the tool).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-28 22:02:35 +02:00
Tomáš Hozza
eb427e2513 Don't use capture_output=True with subprocess.run()
The `capture_output` argument does not exist on Python 3.6 used by
default on RHEL-8.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-26 11:43:13 +02:00
Achilleas Koutsou
3e94088e1f tools/osbuild-mpp: resolve manifest lists
Add support for resolving manifest lists in osbuild-mpp.
Adds an `index` boolean field to the container image struct for
mpp-resolve-images.  When enabled, the preprocessor will also store the
manifest-list digest as a separate skopeo-index source and add it to the
skopeo stage under the `manifest-lists` input.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
b83fd8650c osbuild-mpp: extract is_manifest_list() function
Extract the is_manifest_list() function from the ImageManifest object in
osbuild-mpp into a util function to be reused by the skopeo source.
2023-03-31 14:57:26 +02:00
Ygal Blum
6cdc27366b osbuild-mpp: recognize manifest without mediaType and with manifests fields as a list
According to the OCI Image Index specification the mediaType field is not mandatory
Assume that it is a list if mediaType is not set while manifests field is

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-11-08 11:25:25 +01:00
Simon de Vlieger
3421826d2f osbuild-dev: a new tool to help with manifests 2022-11-02 17:55:13 +01:00
David Rheinsberg
2d6d902428 tree: pep8 + linter fixes
For some reasons I forgot to fix those in the previous runs. Fix a
linter and pep8 warning.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-23 12:08:10 +02:00
David Rheinsberg
a65cf82b5e osbuild-mpp: fix pylint warnings
Fix a bunch of pylint warnings about coding-style. Nothing really major.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 17:41:27 +02:00
David Rheinsberg
73ad1a3eac osbuild-mpp: avoid symbol shadowing
Avoid using `os` or `input` as symbol names, since they shadow
previously defined symbols.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 17:41:27 +02:00
David Rheinsberg
0f49ed9f98 osbuild-mpp: implement virtual functions
Make sure to correctly implement virtual functions and raise
NotImplementedError, as suggested by the standard library. Pylint will
otherwise complain about unavailable functions being accessed.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 17:41:27 +02:00
David Rheinsberg
0471c646a8 osbuild-mpp: fix YAMLError.problem accessors
The `problem` member is only defined if a problem-mark is present. If
the mark is not set, we get no details on the error whatsoever and have
to just print a generic error message.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 17:41:27 +02:00
David Rheinsberg
8c6049f197 osbuild-mpp: fix PartitionTable.__getitem__() bail-out
The __getitem__() function incorrectly returns `None` if the
partition-type is not found. Make sure to always return IndexError if
the requested value is outside the supported range.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 17:41:27 +02:00
Simon de Vlieger
ea6085fae6 osbuild: run isort on all files 2022-09-12 13:32:51 +02:00
Ygal Blum
42552e0436 osbuild-mpp: Add url option to mpp-embed
Allow the user to pass a URL to be embeded as org.osbuild.curl input

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-09-06 14:28:06 +03:00
Alexander Larsson
7c0f0c1052 osbuild-mpp: Add comment detailing the stage formating 2022-08-08 14:21:13 +02:00
Alexander Larsson
24e48d2f71 osbuild-mpp: Use empty string for pipeline name if missing
This matches what we did before last commit.
2022-08-08 14:21:13 +02:00
Alexander Larsson
fc2697927a osbuild-mpp: Allow use of mpp-* operations for stages
This mergest the handling of process_stages() and process_format() into
just one process_format(), which incrementally tracks the call stack
of the formating, which allows it to detect when it is hitting a stage
and can call _process_stage().

This means it is possible to mix things like mpp-if and mpp-join with
stages.

For example, you can do complex combinations like:

pipelines:
- name: rootfs
  stages:
    mpp-join:
      - - type: org.ostree.foo
        - mpp-if: use_bar
          then:
            type: org.osbuild.bar
      - mpp-if: use_extra_stages
        then:
          mpp-eval: extra_stages

This is particularly useful if you included something and you want
to mpp-join something that was set in a variable.
2022-08-08 14:21:13 +02:00
Alexander Larsson
ed99aa4bfa osbuild-mpp: Store solver_factory in manifest
We do this instead of passing it around to simplify the APIs so
we don't have to track it. This will help for later changes.
2022-08-08 14:21:13 +02:00
Christian Kellner
219d7469cb osbuild-mpp: small python cleanups
Remove an unused variable and annotate static methods as such.
2022-06-27 10:22:25 +02:00
Jakub Rusz
62f2bf608c tools: add set-env-variables.sh
Very simple script to set env variables.
2022-04-13 14:57:27 +02:00
Alexander Larsson
dbaed75b46 osbuild-mpp: Support mpp-resolve-image for container images 2022-02-10 14:43:17 +01:00
Alexander Larsson
66cc2900c9 obuild-mpp: Add process_stage() helper
Both file embedding and depsolves start by iterating over all stages,
and we want to add another similar one for container installs, so
break out the iteration over the containers so that it is done in
one place only.
2022-02-10 14:43:17 +01:00