Commit graph

773 commits

Author SHA1 Message Date
David Rheinsberg
faaa6c1a6b modules: fix format-strings without interpolation
Fix all occurrences of format-strings without any interpolation. pylint
warns about those (and for some reason did not do so for our modules).
A followup will fix the pylint tests, so make sure all the warnings are
resolved.
2020-05-29 11:07:44 +02:00
David Rheinsberg
fe6e58aa12 pipeline: drop redundant default arg value
Drop the default argument value for `output_directory`, but use
type-annotations to make clear it can be optional.
2020-05-29 11:07:29 +02:00
David Rheinsberg
a300b755ab news: fix minor typos
Fix some minor typos in the v15 release notes:

   * `doing reading` -> `reading`
   * `the` -> `an`
   * `of the emitting` -> `of emitting`
   * `outpud_id` -> `output_id`
2020-05-29 11:07:29 +02:00
David Rheinsberg
13c0dec8ee util/jsoncomm: simplify condition
This reduces `if fds && len(fds) > 0:` to `if fds:`. In python, empty
collections are considered false, so the additional check is not needed.
2020-05-29 11:07:29 +02:00
Christian Kellner
2a9cdde5ec osbuild: refactor stage information
For all currently supported modules, i.e. stages and assemblers,
convert the STAGE_DESC and STAGE_INFO into a proper doc-string.
Rename the STAGE_OPTS into SCHEMA.
Refactor meta.ModuleInfo loading accordingly.

The script to be used for the conversion is:

  --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

import os
import sys

import osbuild
import osbuild.meta

from osbuild.meta import ModuleInfo

def find_line(lines, start):
    for i, l in enumerate(lines):
        if l.startswith(start):
            return i
    return None

def del_block(lines, prefix):
    start = find_line(lines, prefix)
    end = find_line(lines[start:], '"""')
    print(start, end)
    del lines[start:start+end+1]

def main():
    index = osbuild.meta.Index(os.curdir)

    modules = []
    for klass in ("Stage", "Assembler"):
        mods = index.list_modules_for_class(klass)
        modules += [(klass, module) for module in mods]

    for m in modules:
        print(m)
        klass, name = m
        info = ModuleInfo.load(os.curdir, klass, name)

        module_path = ModuleInfo.module_class_to_directory(klass)
        path = os.path.join(os.curdir, module_path, name)
        with open(path, "r") as f:
            data = list(f.readlines())

            i = find_line(data, "STAGE_DESC")
            print(i)
            del data[i]

            del_block(data, "STAGE_INFO")

            i = find_line(data, "STAGE_OPTS")
            data[i] = 'SCHEMA = """\n'

        docstr = '"""\n' + info.desc + "\n" + info.info + '"""\n'
        doclst = docstr.split("\n")
        doclst = [l + "\n" for l in doclst]
        data = [data[0]] + doclst + data[1:]

        with open(path, "w") as f:
            f.writelines(data)

if __name__ == "__main__":
    main()
2020-05-29 08:37:47 +02:00
Christian Kellner
131d0264a8 test/osbuild: use new list_modules_for_class
Convert our custom code to list modules to the new ModuleInfo
method list_modules_for_class that does the same thing. This
is then indeed also testing that new function.
2020-05-29 08:37:47 +02:00
Christian Kellner
dd00c4f478 meta: add method to list modules of a given class
New Index.list_modules_for_class method that will list the names
of all the modules of a certain class, like 'Stage' or 'Assembler'.
2020-05-29 08:37:47 +02:00
Christian Kellner
2d5ec8edad meta: extract module class to dir mapping
Make the mapping of module class to the corresponding directory
a method of the ModuleInfo class. This is so it can be re-used
by others in the future.
2020-05-29 08:37:47 +02:00
Christian Kellner
1718740c6c test: remove test_stageinfo.py
This was superseded by test_osbuild's test_moduleinfo. It also
seems to be non-functional do to assuming `properties` in all
the STAGE_OPTS. Removing this.
2020-05-29 08:37:47 +02:00
Christian Kellner
80858a492b meta: rename StageInfo → ModuleInfo
The are converging on a nomenclature where the sum of Stages,
Assemblers, Sources (and future entities like those) together
are called 'Modules'.
Thus rename StageInfo to ModuleInfo and the corresponding
variables and methods.
2020-05-29 08:37:47 +02:00
David Rheinsberg
867adc1596 pipeline: checkpoint assemblers just like stages
Change the assembler-commit to be conditional on checkpoints, just like
we already do for stages. This means, assembler output is not
automatically committed, but only if you requested so via a checkpoint.

With this in place we can start sharing caches in osbuild-composer. The
only thing in the cache will be sources as well as checkpointed stages.
We can start checkpointing known pipelines and thus make use of the
cache. Furthermore, we can cache sources, as long as we do not fetch an
unbound set of RPMs. However, our RPM set is currently static, so this
should not be an issue. Nevertheless, it is up to Composer to decide
when to enable the cache.
2020-05-28 14:55:00 +02:00
David Rheinsberg
9c982dc147 pipeline: fix pylint-warning triggered by rebase
Fix osbuild/pipeline.py unused import. We now trigger pylint warnings
alongside pylint errors, and a PR rebase did not consider this.
2020-05-28 12:29:53 +02:00
David Rheinsberg
4c0b169881 pipeline: drop tree_id from osbuild results
We no longer need the `tree_id` in the osbuild output. All callers have
been converted to use other means. Drop the ID from the output and
avoid exposing our internals.
2020-05-28 11:16:15 +02:00
David Rheinsberg
43ddcf895d pipeline: drop output_id and pull in output-directory
Now that no caller requires the "output_id" anymore, drop it from our
results-dictionary. Instead, pass the output-directory through and copy
outputs where we produce / fetch them.

This still uses `objectstore.resolve_ref()`, since we do not have the
outputs pinned at the places where we want to copy. This needs a little
bit more rework, but we might just delay that until we have the cache
rework landed.

This already simplifies the output-directory path and drops the slight
hack which checked very late for produced outputs.

Note that we must be careful not to copy things too early, because we
do not want remnants in the output-directory if we return failure.
Hence, keep the copy-operation close to the commit-operation on the
store.
2020-05-28 11:16:15 +02:00
David Rheinsberg
18b16acd3f pipeline: drop redundant shortcut
All callsites of `Pipeline.assemble()` already check early whether the
output-object exists in the store and then return it. Checking again in
`assemble()` will never catch anything (unless another stage would
happen to produce the same ID as the assembler as a side-effect).

It does seem useful to keep the shortcuts in `assemble()`, so other
callers would get the shortcut as well. However, this does not really
work well right now, since you want to skip the stage-compilation as
well, and `assemble()` is really just the last step of the job. Hence,
it really is the job of the pipeline-executor to check early.

With that in mind, lets drop this fast-path which has no effect in the
current setup.
2020-05-28 11:16:15 +02:00
David Rheinsberg
39e989245d test: enable pylint warnings
Make pylint complain about warnings, not just errors. There are lots of
useful warnings and we generally do adhere to the coding-styles.
2020-05-28 11:06:05 +02:00
David Rheinsberg
707ff8c988 sources: keep try-except block small
We used to have a try-except block to catch URL requests that are not in
`urls`. This block has since then grown way bigger than it should be. We
may now accidentally catch KeyError exceptions from lots of other
places.

This commit extracts the accessor of `urls[checksum]` and saves the
result in a local variable and makes the remainder use that variable.
2020-05-28 11:06:05 +02:00
David Rheinsberg
c337af6795 sources: fix indentation
Fix indentation to make pylint happy.
2020-05-28 11:06:05 +02:00
David Rheinsberg
84dcadc7d2 sources: convert f-string to normal string
Convert an f-string to a normal string, since we do not use any format
specifier in it.
2020-05-28 11:06:05 +02:00
David Rheinsberg
b659aa72ed test: fix wrong indentation
Fix a wrong intendation in TestBase. We used 8spaces instead of 4 in a
subprocess.run() call.
2020-05-28 11:06:05 +02:00
David Rheinsberg
086ad75ba4 test: mark static methods as @staticmethod
Turn some of our methods into static methods and mark them as such,
making pylint even happier.
2020-05-28 11:06:05 +02:00
David Rheinsberg
5d3679f85a test: avoid variable shadowing
Avoid shadowing `unittest` from the global imports. Use a different
identifier and make pylint happier.
2020-05-28 11:06:05 +02:00
David Rheinsberg
46526cf205 osbuild: avoid [] as default value
Using `[]` as default value for arguments makes `pylint` complain. The
reason is that it creates an array statically at the time the function
is parsed, rather than dynamically on invocation of the function. This
means, when you append to this array, you change the global instance and
every further invocation of that function works on this modified array.

While our use-cases are safe, this is indeed a common pitfall. Lets
avoid using this and resort to `None` instead.

This silences a lot of warnings from pylint about "dangerous use of []".
2020-05-28 11:06:05 +02:00
David Rheinsberg
14ada360bd meta: avoid static assertion
Avoid raising a static assertion, but use `raise AssertionError()`
instead. This silences a complaint from pylint about static parameters
to `assert`.
2020-05-28 11:06:05 +02:00
David Rheinsberg
dfec7aca9d buildroot: convert unused format-string
Convert the `f""` into a `""`, since no format identifier is used. This
makes pylint happier!
2020-05-28 11:06:05 +02:00
David Rheinsberg
451ec33d9e test: turn test-doc into test-comment
We use comments in all other tests, rather than doc-strings. Convert the
os-release test to do the same. If we wanted doc-strings, we can convert
all tests over. This commit just tries to keep the tests in-sync.

Note that doc-strings cause `unittest` to print the doc-strings to
stdout during test-execution, making it overly verbose (especially for
multiline docs). By converting it to comments, this behavior is
suppressed.
2020-05-28 11:06:05 +02:00
David Rheinsberg
fdff00d039 test: drop unused osbuildtest.py
This is no longer used. All tests were converted to the new OSBuild
Executor. Drop the remainings.
2020-05-28 11:06:05 +02:00
Christian Kellner
1fe1840c2b tests: add test for the new copy stage
Add a test for the new org.osbuild.copy. Fetch a tarball from the
osbuild github repository and copy two files over to the tree.
2020-05-28 10:42:18 +02:00
Christian Kellner
07c5fdb650 stages: add org.osbuild.copy stage
Copies files obtained via a `source` to the tree. Multiple files or
directories can be copied by specifying multiple entries in `paths`.
If no paths are specified the whole contents of `source` is copied.
The source and the target path for each individual path entry might
optionally be specified via `from` and `to`, respectively; if no
path is given for any of the two, the root `/` is assumed.

Currently only an 'archive' 'source' is supported that in turn uses
the existing 'org.osbuild.files' source to fetch an archive (tarball)
and extracts it to a temporary directory.
2020-05-28 10:42:18 +02:00
Major Hayden
73429035bc CI: Use RHEL 8 CDN image
Now that we have a fully subscribed RHEL 8 image, let's use that instead
of RHEL 8.2 nightlies.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-28 07:00:00 +02:00
Jacob Kozol
9cbedc0496 sources: fix break when secrets is None
When the urls' secrets field is not set, an error is thrown when trying
to get the name of the secrets. The secrets now have a default value of
{} when they are checked for the name.
2020-05-24 11:08:05 +02:00
Major Hayden
89b9e541e2
Add sudo to dnf list command
Bringing over the fix from ansible-osbuild
2020-05-22 14:04:26 -05:00
Major Hayden
0640610f54 Remove RPM builds in GitHub Workflows
We are now building RPMs via mock in Jenkins, so we don't need these RPM
build jobs in GitHub Workflows.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 09:00:01 -05:00
Major Hayden
d8c43bc0e7 Build in a mock chroot first
Build the RPMs in a mock using a simple script so that ansible-osbuild
can focus fully on deployment rather than compiling RPMs.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 10:41:10 +02:00
Major Hayden
53ba692dbe GH Actions: Use upstream Fedora containers
Work around the quay.io issues by using the standard Fedora containers.
Also, make most of the dnf operations a little quieter to make it easier
to find problems.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 10:39:51 +02:00
Christian Kellner
2fa594f334 15
This completes the development of osbuild version 15.
2020-05-20 21:44:58 +02:00
Christian Kellner
b696eba640 NEWS.md: update for osbuild version 15
Major changes are the new assembler, support for passing client
certificates to access Red Hat content in the files source and
the shiny new ManifestPreProcessor.
2020-05-20 21:44:58 +02:00
Christian Kellner
7c9b44ce88 assemblers: add new org.osbuild.oci-archive
Add a new assembler that takes a tree and creates a Open Container
Initiative[2] image according to the OCI image format[2]. The final
result is a tarball, aka a "orci-archive", that can be pulled into
podman with `podman pull oci-archive:<archive>`. Currently the only
required options are `filename` and `architecture`.

[1] https://www.opencontainers.org/
[2 ]https://github.com/opencontainers/image-spec/
2020-05-20 20:05:22 +02:00
Christian Kellner
869973dc68 pipeline: drop {tree, output}_id from --inspect js
We want to get rid of `tree_id` and `output_id` because the they
are now considered internals of the store and clients should not
use them directly. NB: they are still there indirectly as the id
of the last stage and the assembler.
Also, the `output_id` was never correct here, because it was the
`tree_id` as well. Ups.
2020-05-20 18:54:56 +02:00
David Rheinsberg
7dcc946fe2 test: add F32 manifests and a manifest-preprocessor
This adds F32 manifests in ./test/data/. To avoid magically deducing the
package list out of the void, this adds a ManifestPreProcessor (MPP)
called `./tools/mpp-depsolve.py`. What this does is it takes a manifest
on stdin, modifies it, and produces a manifest on stdout.

The `mpp-depsolve.py` preprocessor takes a manifest and modifies all the
`org.osbuild.rpm` stages. It parses a new option to that stage called
`mpp-depsolve`, which contains a package-list, a repo-list, and dnf
metadata. It then drops this `mpp-depsolve` option (since it would be an
invalid manifest otherwise), depsolves the packages, inserts a proper
"packages" option as well as appends the correct paths to the sources
entry.

With this in place, this adds `mpp-f32-base.json` and
`mpp-f32-build.json` in ./test/data/manifests/. These will then be used
as base F32 manifests for our test-suite.

Lastly, this adds `./test/data/README.md` as a place to document the
files we place in `./test/data/`, since most of the files do not allow
for comments.
2020-05-20 18:54:38 +02:00
David Rheinsberg
0ffae822ce ci: run test-src with ghci
Use the GHCI image to run `make test-src`. This makes sure all our
dependencies are available (including `dnf`, `hawkey`, and other python
packages).
2020-05-20 18:54:38 +02:00
Jacob Kozol
372b1174f2 sources: add rhsm secret support to files
When osbuild is given a manifest, the sources' urls can contain fields
for both a url path and a secret for that url. If the secret is
org.osbuild.rhsm the system's rhsm certificates are retrieved. These
certs are included when the files are curled.
2020-05-20 18:52:35 +02:00
Jacob Kozol
2309b54eb3 sources: reduce whitespace in files cp command 2020-05-20 18:52:35 +02:00
Christian Kellner
192430bd30 assemblers/ostree.commit: support archiving
Introduce a new `tar` option, which when given together with the
required `tar.filename` option, will result in the output of the
assembler being a tarball that contains the repo and the compose
information (`compose.json`).
Requires the `tar` command to be present in the build root. Modify
the sample to use that option and include the tar for the build
pipeline.
2020-05-20 14:47:40 +02:00
David Rheinsberg
c84f5280c1 test: convert to new osbuild executor
Convert the pipeline tests to the new osbuild executor. This will remove
the last users of the "output_id" and "tree_id" identifiers from
osbuild.
2020-05-20 14:44:43 +02:00
David Rheinsberg
845148993c test: add tree-diff accessor
The `tree-diff` tool currently requires access to our local checkout,
since we do not install the tool. Provide accessors in `TestBase` so we
do not hard-code the path everywhere.
2020-05-20 14:44:43 +02:00
David Rheinsberg
20beabf431 test: add new osbuild executor
Add a new OSBuild class to `./test/test.py`. This class is an extension
of `./test/osbuildtest.py`, but no longer requires the `output_id` and
`tree_id` identifiers of osbuild.

Furthermore, this new executor uses context-managers to make sure any
temporary object is only accessed for a contained time-frame.
2020-05-20 14:44:43 +02:00
David Rheinsberg
9dfa0e8a61 pipeline: only copy output if there is any
Make sure to verify that the pipeline actually produced any output
before attempting to copy it out. This fixes osbuild running with
`--output-directory` but without assembler.
2020-05-20 14:44:43 +02:00
Christian Kellner
1896047bae sources: pass the library dir to the sources
The idea is that source can themselves spawn other modules, esp.
new secrets modules. For this they need to know the library dir,
aka 'libdir' throughout the osbuild source. Therefore change the
SourceServer to directly get the library directory instead of
just the sub-directory to the sources. Then pass the library
directory to via the JSON API to the source.
Adjust all usage of the SourceServer, including the tests.
2020-05-20 14:43:33 +02:00
Major Hayden
5620d5080a CI: Remove old jenkins.osbuild.org configuation
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-18 09:30:39 -05:00