Commit graph

1177 commits

Author SHA1 Message Date
Christian Kellner
94dc11a910 meta: require name to match module in schema
When generating the schema information for a Stage, Assemgbler,
ensure that `name` is actually the one that matches the module.
2021-02-12 15:55:43 +01:00
Christian Kellner
48418be8de buildroot: rename path argument to rundir
This matches the internal, "private", property and better
describes what the variable is for. Additionally, make it
into a proper keyword argument.
2021-02-11 23:49:18 +01:00
Christian Kellner
749f59cc9a buildroot: make var a positional argument
Commit d028ea5b16 introduced bug when introducing the `store`
argument to `Stage.run`, instead of passing `var=var`, i.e.
`var` is being passed as keyword argument, it is now being
passed as a positional one. Since the `path=/run/osbuild`
keyword argument comes before the `var=/var/tmp` argument,
`var` is now being passed as `path` instead of var.
Since `var` is always being passed in throughout the entire
codebase, make it a positional argument, and move it before
`path`.
Adapt the tests to pass `var` as positional argument.
2021-02-11 23:49:18 +01:00
Christian Kellner
dd50387bbc inputs/tree: remove trailing whitespace
This one is for David. And pylint, but mostly David.
2021-02-11 23:49:18 +01:00
Christian Kellner
68f5c38e61 main: print all pipeline names and ids
Instead of printing the tree_id and output_id, which are format
dependent, print all pipelines, with their name and ids.
2021-02-10 17:50:41 +01:00
Christian Kellner
931eac23c3 sources: introduce source items
All sources fetch various types of `items`, the specific nature
of which is dependent on the source type, but they are all
identifyable by a opaque identifier. In order for osbuild to
check that all the inputs that a stage needs are are indeed
contained in the manifest description, osbuild must learn what
ids are fetched by what source. This is done by standarzing
the common "items" part, i.e. the "id" -> "options for that id"
mapping that is common to all sources.
For the version 1 of the format, extract the files and ostree
the item information from the respective options.
Adapt the sources (files, ostree) so that they use the new items
information, but also fall back to the old style; the latter is
needed since the sources tests still uses the SourceServer.
2021-02-10 15:44:24 +01:00
Christian Kellner
3b7141417c formats/v1: extract source loading code
Extract the code that loads individual source into its own
function.
2021-02-10 15:44:24 +01:00
Christian Kellner
598cfd0d76 test/fmt_v1: add format info checks
Add basic checks to make sure the format version 1 is detected
for manifest of version 1.
2021-02-09 13:08:24 +01:00
Christian Kellner
6d674a0970 main_cli: detect format
Now that meta.Index provides a way to detect the format given the
input data, use that method instead of the hard-coded use of the
version 1 format via the input. This should make the main entry
point format independent.
2021-02-09 13:08:24 +01:00
Christian Kellner
8f97c13dda formats/v1: specify format version
Specify the version, i.e. "1", that this format is able to read
and write. Additionally add a proper doc string describing the
format.
2021-02-09 13:08:24 +01:00
Christian Kellner
7e2c0c7000 meta: introduce format information
Introdcue a `FormatInfo` class that, very much like `ModuleInfo`
can be used to obtain meta information about a format. Methods
are added to `Index` to allow the enumeration of available formats,
getting the `FormatInfo` for a format given its name and to detect
a format via the manifest description data.

Change the top-level documentation to reflect the changes. Also
remove an outdated section about validation of the schema; this
was moved to the format specific code some time ago.
2021-02-09 13:08:24 +01:00
Christian Kellner
7ffae5669c osbuild: convert ostree stage to inputs
Convert the `org.osbuild.ostree` stage to use inputs instead of
sources. In the format (version 1) loading code, convert the
stage to use an input based on the existing stage options.
2021-02-06 12:04:30 +01:00
Christian Kellner
17c6446a7c inputs: add org.osbuild.ostree input
Add a new input that can handle ostree commits. For source origins,
it will pull any number of commits specified via `references`. For
pipeline origins it will use the compose.json to obtain the commit
id and pull that. Either way the data passed onto the stage is a
dictionary of commit ids and commit metadata, such as the `ref`
that is an ostree ref that is optionally created in case the `ref`
option for that reference was specified.
2021-02-06 12:04:30 +01:00
Christian Kellner
0256396270 osbuild: convert rpm stage to use inputs
Convert the `org.osbuild.rpm` stage to use inputs instead of
sources. When loading v1 formats the input is generated from
the stage options.
2021-02-06 12:04:30 +01:00
Christian Kellner
1f89d2fd9d inputs: add files input
Create a new input for resources of the `org.osbuild.files` type,
i.e. individual files, addressed in the store via their content
hash.
2021-02-06 12:04:30 +01:00
Christian Kellner
57ccf403e1 formats/v1: use new Stage.add_input
Instead of manually constructing and appending the input for
stages (here the stages that replace the assembler), use the
new `Stage.add_input` method.
2021-02-06 12:04:30 +01:00
Christian Kellner
9e8b254687 stage: introduce add_input method
In much the same way has `Pipeline` has `add_stage` and `Manifest`
has `add_pipeline`, introduce an `add_input` method to `Stage` to
be able add `Inputs` to stages.
2021-02-06 12:04:30 +01:00
Christian Kellner
ad8baab819 inputs: remove type info for info param
The `info` parameter for Input constructor is of type `PModuleInfo`,
which is located in `meta`. This in turn imports jsonschema. Ergo,
importing importing `inputs` will create a dependency on jsonschema.
At the same time the `osbuild` package globally imports `Pipeline`,
via `__init__.py`, and `osbuild.api` is used in the runners and
stages, which are run inside the buildroot. If one now wanted to
use `inputs` from `Pipeline`, it would lead to jsonschema being
imported (via `meta`) which might not be available on the build-
root and it is a rather random dependency to have.
On obvious solution would be to use a construct with `TYPE_CHECKING`,
a la:
  if TYPE_CHECKING:
    from .meta import ModuleInfo
Sadly, pylint will now complain about it. This could be fixed with:
  if TYPE_CHECKING:
    from .meta import ModuleInfo
  else:
    ModuleInfo = "osbuild.meta.ModuleInfo"
But this is just gross. So we will have to accept that Python is,
well, Python und omit the type information for the `info` param.
2021-02-06 12:04:30 +01:00
Christian Kellner
ba7f6fe7c7 formats/v1: extract stage parsing into function
Extract the code that creates a stage given its description into
its own function.
2021-02-06 12:04:30 +01:00
Christian Kellner
aa9fee7b51 objectstore: add source method to api
Add a new jsoncomm rpc method call, `source`, that will return
the directory within the store where resources for that specific
type of resource, like e.g. tree, files, or ostree can be found
or stored.
2021-02-06 12:04:30 +01:00
Christian Kellner
eb1d17d8ac input: add references and origin
Currently all options for inputs are totally opaque to osbuild
itself. This is neat from a seperation of concerns point of view
but has one major downside: osbuild can not verify the integrity
of the pipeline graph, i.e. if all inputs that need pipelines or
sources do indeed exists. Therefore intrdouce two generic fields
for inputs: `origin` and `references`. The former can either be
a source or a pipeline. The latter is an array of identifiers or
a dictionary where the keys are the identifiers and the values
are additional options for that id. The identifiers then refer
to either resources obtained via a source or a pipeline that has
already been built.
2021-02-06 12:04:30 +01:00
Christian Kellner
f450338809 test/fmt_v1: schema validate the basic manifest
Incldue the basic test manifest in the schema validation test.
2021-02-06 12:04:30 +01:00
Christian Kellner
d3e85fe6a4 test/fmt_v1: use noop stages in test manifest
Instead of using `org.osbuild.test` stages, so `org.osbuild.noop`
stages so that the options we pass are actually valid and we can
use the manifest in schema validation checking.
2021-02-06 12:04:30 +01:00
Christian Kellner
ae1a1a140e test/fmt_v1: add sources to test manifest
Include two samples sources in the test manifest so that those
will be checked in the various tests as well.
2021-02-06 12:04:30 +01:00
Christian Kellner
12c9173faf manifest: use newly introduced Source class
Add a new `add_source` method that will add an individual `Source`
to a `Manifest` give its `ModuleInfo` and options. The dictionary
of source options in the manifest is replaced with a list of such
`Sources` and `add_source` will append to it. Adap the version 1
format code to use `add_source` and reconstruct the source options
from the list of source on `describe`.
Remove the `sources_options` constructor parameter for `Manifest`
and adapt all the source base for this.
2021-02-06 12:04:30 +01:00
Christian Kellner
8423da368a sources: introduce the Source class
Very much like, stages and inputs, a new `Source` calls represents
a source type with its options. A `download` method on the `Source`
class can be used to only donwload content to the cache.
2021-02-06 12:04:30 +01:00
Christian Kellner
ee9df25a02 sources/ostree: ability to only pull commits
Split the internal logic into two parts: 1) fetching the commit
into the internal cache repo and then 2) exporting that commit,
i.e. a local pull from the cache repo to the output directory.
If no `output` directory was specified, only fetch the commit,
do not attempt to export it.
NB: this commit changes at what point the gpg verification is
done. Previously the check was on export. Now, we are checking
the signature on import only. The export step will be replaced
by an ostree `Input` that will have the ability to verify
commits a second time.
2021-02-06 12:04:30 +01:00
Christian Kellner
127be09ba8 sources/files: ability to only download files
Split the internal logic of the stage in two parts: 1) downloading
files to the internal cache and 2) exporting the downloaded files
from said cache to the output directory. Additionally, ff no such
`output` directory was specified, i.e. it is empty or `None`, only
download files but do not attempt to export them.
2021-02-06 12:04:30 +01:00
Christian Kellner
5a6a53714a stages/copy: remove the stage
The stage was structured in a way so that it supports many different
inputs, like, `archive` and in the future maybe trees, git checkouts.
This does not fit very well into the new input model, where instead
seperate `copy.tree` and `copy.files` stages might make more sense.
Since the stage is not been used anywhere, and mainly got added
as a way to get the ignition dracut module via an archive of a git
repo, remove the stage for now. A replacement will be brought back
in the future.
2021-02-04 16:13:40 +00:00
Christian Kellner
20a142d8f9 24
This completes the development of osbuild version 24
2021-01-28 11:03:33 +01:00
Christian Kellner
78151752cf NEWS.md: update for osbuild version 24
Highlights are two new stages, a runner for Cent OS 8, various
fixes and improvements to the docs, testing and CI.
2021-01-28 11:03:33 +01:00
Jacob Kozol
b77ba2c5f6 stages: add org.osbuild.sysconfig stage
The sysconfig directory contains a variety of system configuration files. The
values found in each of the configuration files may need to be specified
before first boot.

Currently, only the kernel and network configs can be modified and will
override existing files.
2021-01-27 17:39:54 +01:00
Christian Kellner
05e5a5596f assembers/tar: add acls, selinux, xattrs options
Add the ability to opt out of preserving the ACLs, SELinux
contexts and extended attributes. It is opt out instead of
opt in since the assembler by default tries to preserve as
much as possible.
2021-01-26 12:09:23 +01:00
Christian Kellner
94d40da5cb assemblers/tar: small description cleanup
Replace the short and redundant first line of the description with
the more detailed following header line.
2021-01-26 12:09:23 +01:00
Christian Kellner
89c3df8de4 test/assembler: verify the tar'ed content
In the test case for the tar assembler, actually verify the
content by un-tar-ing the result again and comparing it to
the tree. This would have spotted missing SELinux labels.
2021-01-26 12:09:23 +01:00
Christian Kellner
920f46880b assemblers/tar: include selinux, acls and xattrs
All of these options, i.e. SELinux labels, ACLs and extended
attributes (xattrs), are opt-in and thus were currently ignored.
This lead to trees that had their selinux labels missing and
were thus incorrect.
2021-01-26 12:09:23 +01:00
Christian Kellner
33283853e9 tree-diff: properly detect missing selinux labels
Detect the case that one file has a SELinux label but the other
file does not have any label at all. This was currently not
possible to detect because both calls to get the labels were
wrapped in one try-except block and any failure in one of the
two calls, like a missing label, would lead to an early return
of the function, with a success value.
2021-01-26 12:09:23 +01:00
Christian Kellner
ee1d860755 sources: drop dnf stage
This source has been declared obsolete some time ago and is not
support anymore. We wont support it in the upcoming new manifest
format, therefore drop it now.
2021-01-22 17:17:54 +01:00
Christian Kellner
0fba88d7a9 stage: include inputs in id calculation
Include all inputs of a stage during the calculation of its id,
since they determine, very much like options, the content the
stage produces; thus different inputs should lead to different
ids.
2021-01-22 15:03:19 +01:00
Christian Kellner
684c408914 inputs: add an id property
Add an `id` property that, like `Stage.id`, can be used to uniquely
identify an input based on its name and options. Two stages with
the same name and options will have the same `id`.
2021-01-22 15:03:19 +01:00
Christian Kellner
9f4861e58f inputs: properly mark name as a property
It was meant to be a property not a function.
2021-01-22 15:03:19 +01:00
Christian Kellner
c6432d0adb pipeline: replace tree_id with id
Now that `Pipelines` have no assemblers anymore and thus only one
identifier, i.e. the one corresponding to the tree (`tree_id`),
the `id` and `tree_id` are now the same. Therefore replace the
usage of `tree_id` with `id` and drop the former. Add some extra
documentation including some caveats about the uniquness of `id`.
2021-01-22 15:03:19 +01:00
Christian Kellner
53e9ec850b osbuild: assemblers are pipelines now
Convert the assembler phase of the main pipeline in the old format
into a new Pipeline that as the assembler as a stage, where the
input of that stage is the main pipeline. This removes the need of
having "assemblers" as special concepts and thus the corresponding
code in `Pipeline` is removed. The new assembler pipeline is marked
as exported, but the pipeline that builds the tree is not anymore.
Adapt the `describe` and `output` functions of the `v1` format to
handle the assembler pipeline. Also change the tests accordingly.

NB: The id reported for the assembler via `--inspect` and the result
will change as a result of this, since the assembler stage is now
the first and only stage of a new pipeline and thus has no base
anymore.
2021-01-22 15:03:19 +01:00
Christian Kellner
289d943d94 test/fmt_v1: checks for nested build pipelines
Add a level of nesting for build pipelines, which will test the
loading but also the output and results for nested build pipelines
in the old format.
2021-01-22 15:03:19 +01:00
Christian Kellner
949f63d760 test/osbuild: basic checks for manifest
Build a simple pipeline and check that the order of the pipelines
is correct and all the accessor methods and iteration is working
as expected.
2021-01-22 15:03:19 +01:00
Christian Kellner
91aa0c6e88 manifest: add __contains__ method
Since `__iter__` is return an iterator over the `Pipeline` objects,
the `"name" in manifest` check would not work for name or ids. Thus
provide an implemention of `__contains__` that does exactly that.
2021-01-22 15:03:19 +01:00
Christian Kellner
18671686ee manifest: add get method to lookup pipelines
Add a new helper helper, `Manfifest.get` that will return a
pipeline give a name or an id or `None` if no pipeline could
be found with either. The implementation is taken from the
existing `__getitem__` method and the latter as now based on
the new `get` method.
2021-01-22 15:03:19 +01:00
Christian Kellner
569345cc72 pipeline: identify pipelines by name
Every pipeline that gets added to the `Manifest` now need to have
a unique name by which it can be identified. The version 1 format
loader is changed so that the main pipeline that builds the tree
is always called `tree`. The build pipeline for it will be called
`build` and further recursive build pipelines `build-build`, where
the number of repetitions of `build` corresponds to their level of
nesting. An assembler, if it exists, will be added as `assembler`.
The `Manifest.__getitem__` helper is changed so it will first try
to access pipeline via its name and then fall back to an id based
search. NB: in the degenrate case of multiple pipelines that have
exactly the same `id`, i.e. same stages, with the same options and
same build pipeline, only the first one will be return; but only
the first one here will be built as well, so this is in practice
not a problem.
The formatter uses this helper to get the tree pipeline  via its
name wherever it is needed.
This also adds an `__iter__` method `Manifest` to ease iterating
over just the pipeline values, a la `for pipeline in manifet`.
2021-01-22 15:03:19 +01:00
Christian Kellner
88acd7bb00 pipeline: make them "exportable"
Add a new `export` property to the `Pipeline` object that indicates
whether a the result, i.e. the tree after the pipelines has been
built, should be exported, i.e. copied to the output directory.
In the current format (v1), the main pipeline, gets marked as such
by the corresponding loader.
2021-01-22 15:03:19 +01:00
Christian Kellner
42dd3c1e2d manifest: add and use add_pipeline method
Instead of passing all pre-created pipelines to the Manifest
constructor, add a `add_pipeline` method, analogous to the
existing `Pipeline.add_{stage, assembler}` methods. Convert
the format loading code to use that and remove the constructor
parameter.
2021-01-22 15:03:19 +01:00