Commit graph

109 commits

Author SHA1 Message Date
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
Achilleas Koutsou
bef387848f osbuild-mpp: Add support for a pacman resolver
This introduces a new dependency resolver to osbuild-mpp for Arch Linux
which uses the pacman package manager. The used solver is determined by
the `solver` field in the `mpp-depsolve` object inside the manifest
file, if it does not exists it falls back to the DepSolver for dnf/rpm.

Co-Authored-By: Jelle van der Waa <jvanderwaa@redhat.com>
2021-12-15 23:22:15 +01:00
Jelle van der Waa
76c1b5cf25 osbuild-mpp: ConstructorError was undefined
ConstructorError is part of the yaml.constructor module.
2021-12-02 17:33:46 +01:00
Jelle van der Waa
03af8c632a osbuild-mpp: Apply autopep8
Make the code confirm to PEP8.
2021-12-02 17:33:46 +01:00
Alexander Larsson
eefc52333e osbuild-mpp: Allow mpp-define-image nodes to use formating
We just process the formats after removing the mpp node, just like
we do in e.g. mpp-depsolv.
2021-11-26 11:51:42 +00:00
Alexander Larsson
4901e97236 osbuild-mpp: Allow included files to define partitions too 2021-11-26 11:51:42 +00:00
Alexander Larsson
ba8bc3a60a osbuild-mpp: Support nested includes
This moves the handling of includes to the manifest loader, thus
supporting nested includes. search_dirs is moved to a property of the
Manifest so that it can be tracked during loads.

In addition we need to fix Manifest.path to the actual path that was
loaded instead of whatever the parent include said, so that relative
includes are handled from the proper location of the loaded manifest.
2021-11-26 11:51:42 +00:00
Alexander Larsson
12335f9e5f osbuild-mpp: Be more careful about keys existing
In process_embed_files(), it assumed that a stage had a "type" field,
which breaks if a stage is e.g. a `mpp-if` node, so use .get() instead
of raw dict lookups.
2021-11-26 11:51:42 +00:00
Alexander Larsson
bfa619f1a2 osbuild-mpp: Fix default value for ManifestV2.pipelines
This should be [], not {}. This  was probably from copying the V1
value which is {} (for `pipeline`).
2021-11-26 11:51:42 +00:00
Alexander Larsson
29ecb1df67 osbuild-mpp: Support mpp-pipelines to include all or a subset of the pipelines
This makes a lot of sense, as some include could be built in a way the
includer doesn't know about that requires sub-pipelines.
2021-11-26 11:51:42 +00:00
Alexander Larsson
52c3cb12ba osbuild-mpp: Support loading yaml as well as json files
yaml files are essentially compatible with json files, although
they have some advantages, like allowing comments and being easier
for humans to read/write.

This changes the reading of the file to use a yaml parser instead of
a json parser, but still produces json at the end. I tried manually
converting a json file to yaml and running osbuild-mpp, and it produced
an identical file.

By default the yaml parser doesn't respect order so i had to tweak
the loader a bit to use OrderedDict.
2021-11-19 13:35:12 +01:00
Alexander Larsson
10333fa8ba osbuild-mpp: Report the path of the json file when parsing fails
This makes it a lot easier to understand failures when files are
including other files.
2021-11-18 21:00:13 +01:00
Christian Kellner
15759dd205 tools/osbuild-mpp: add ability to embed data
Add a new pre-processor directive to MPP that allows to define
`org.osbuild.inline` sources on the fly by embedding data or
files into the manifest.
2021-11-18 13:41:06 +01:00
Christian Kellner
22e670050f osbuild-mpp: extract finding files and opening
Extract the code that finds a file and opens it from the existing
method that find manifests and opens them. This is so that the
former code can be re-used.
2021-11-18 13:41:06 +01:00
Alexander Larsson
ffdbdf6235 osbuild-mpp: Support mpp-if
This allows optional manifest json values like "if blah, add stage foo",
or selecting between possible nodes, "if blah, stage is foo, else bar".
2021-11-18 11:33:57 +01:00
Alexander Larsson
04d880852a osbuild-mpp: Break out helper function
This breaks out the fakeroot handling used to rewrite a single node.
We'll use this in some new cases later.
2021-11-18 11:33:57 +01:00
Christian Kellner
c42c19356c mpp: fix long options
The correct way to specify long options is as separate arguments,
not as one argument separated by comma.
2021-10-25 18:01:25 +02:00
Alexander Larsson
611b6846e8 osbuild-mpp: Set the "arch" variable to the current rpm arch 2021-10-25 15:17:04 +02:00
Alexander Larsson
1425f66449 osbuild-mpp: Better handling of variable defaults and propagation
We now allow there to be default variables (none so far) which gets
installed as the initial value of manifest.vars.

Additionally, when including a file the default comes from the current
state of the including manifest, allowing the included manifest to use
variables from the base file.
2021-10-25 15:17:04 +02:00