Commit graph

2078 commits

Author SHA1 Message Date
Christian Kellner
5570e2a92e manifests: upgrade ostree commit, image to F36
Fedora 34 is end of life and we ought to be testing with newer
releases so that we catch issues like the authselect one, that
is detailed in "stages/rpm: support marking install as ostree".
2022-08-13 19:21:52 +01:00
Christian Kellner
899fdcd5d9 manifests: set rpm/ostree_booted for commit
See "stages/rpm: support marking install as ostree" for more
information why this is needed on Fedora 36 and newer.
2022-08-13 19:21:52 +01:00
Christian Kellner
10255dbdcc test/manifests: base ostree image on commit
Instead of re-defining the ostree-commit in the ostree-image.mpp
file, import the needed pipelines to build the commit and use
that.
2022-08-13 19:21:52 +01:00
Christian Kellner
d2bcaffbdc test/manifests: add update repos in ostree-commit
Include modular and updates repositories for ostree commit and the
new build manifest.
2022-08-13 19:21:52 +01:00
Christian Kellner
073359166d test/manifests: add generic fedora build manifest
Basically a copy of f34-build-v2 but uses variables. Use it form
fedora-ostree-commit.
2022-08-13 19:21:52 +01:00
Christian Kellner
056a33041b manifests: use variables in ostree-commit
Instead of hard-coding the release and the snapshot, use variables,
which should help updating to newer releases and snapshots.
2022-08-13 19:21:52 +01:00
Christian Kellner
4b11989ce3 manifests: convert ostree commit to format v2
Convert the manifest to use version 2 format. Version 1 is really
not used much anymore because composer was completely ported to
using v2. Welcome to the future, ostree commit.
2022-08-13 19:21:52 +01:00
Christian Kellner
c3b172e16b manifests/ostree-commit: update package list
Include cryptsetup and lvm2 so that commit can be deployed to
images that are encrypted and have lvm2 layout. Additionally,
include greenboot. Remove the explicit dependency on ostree
and systemd-udev, which are automatically pulled in.
2022-08-13 19:21:52 +01:00
Christian Kellner
16f1c560cc stages/rpm: support marking install as ostree
An ostree system can be identified as such by the presence of a
marker file: /run/ostree-booted. The `rpm-ostree` tool also
creates this marker during the _installation_ of the system[1,2].
Recently, starting with F36, the authselect package has taken
has become mandatory[3] and is now owning the nsswitch config.
An rpm-ostree system, which has parts of the user database in
/usr, release on the nss-altfiles to read these databases. The
necessary entries are added during the post-processing, which
is called in our `org.osbuild.ostree.preptree` stage[4]. This
installation is skipped though if the nsswitch is the file is
a symlink, indicating that it is owned by some other package,
like authselect. So the F36 authselect change first broke rpm-
ostree[6]. The fix was to check for `/run/ostree-booted` in
the authselect scriptlet and special case this situation[7,8].
Now, our `org.osbuild.rpm` stage does not yet have the ability
to pretend it is a running ostree system and thus we did not
get the special treatment resulting in nss-altfiles not being
enabled in our ostree commits. Therefore the passwd database in
/usr was not read and a lot of daemons and programs without a
valid user, like e.g. `sshd`.
This change introduces a new option, `ostree_booted` that if
set, will create the `/run/ostree-booted` marker and thus our
installation phase will get the same treatments from packages
as rpm-ostree. Hopefully.

[1] 730bec87b1/rust/src/builtins/compose/mod.rs (L24)
[2] 6211d1452e/src/app/rpmostree-compose-builtin-tree.cxx (L501)
[3] https://fedoraproject.org/wiki/Changes/Make_Authselect_Mandatory
[4] 7993c6f565/rust/src/composepost.rs (L635)
[5] d614caeca1/f/0010-spec-fix-detection-of-ostree-system.patch
[6] https://bugzilla.redhat.com/show_bug.cgi?id=2034360
[7] https://src.fedoraproject.org/rpms/authselect/c/d614caeca1a68f55542aefd0d76bda2691c85d24?branch=f36
[8] https://github.com/authselect/authselect/issues/48
2022-08-13 19:21:52 +01:00
Christian Kellner
776bab46ae stages/rpm: convert the mount code to python
Convert the code that sets up the bind mounts to /dev, /sys/ and
/proc from a bash script to python by using the new mount helper
that were moved from the `objectstore`.
2022-08-13 19:21:52 +01:00
Christian Kellner
8f95154a8c stages/rpm: extract machine-id code into function
Extract the code that creates the fake machine id, if it does not
exist, into its own function. Also convert the shell code into
Python code.
2022-08-13 19:21:52 +01:00
Christian Kellner
2e09e7937c objectstore, move {u,}mount methods to util.mnt
Move the mount and umount helpers to the new mount utility module.
No semantic change in the function.
2022-08-13 19:21:52 +01:00
Christian Kellner
a43ea66be2 util/mnt: rename var to avoid future clash
Rename the local `mount` variable to `mnt` so that we can have
a top level `mount` function.
2022-08-13 19:21:52 +01:00
Christian Kellner
b49f3f91f9 util/mnt: extract MountGuard into new module
Extract the `MountGuard` class from all stages that defined it into
a new `mnt` utility module.
2022-08-13 19:21:52 +01: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
561122dd30 ci: add autopep8 check to checks.yml
Add to new autopep8 check to the checks suit. Ideally we would
move the `test.src` test over from tests.yml, but running that
in an updated container leads to a whole lot of new warnings,
most of them related to "unspecified encoding" in `open` calls.
2022-08-05 09:41:05 +02:00
Christian Kellner
5c8d11ebe1 test/pylint: check error code instead of exception
Instead of using `subprocess` with `check=True`, which will
echo the command used, including all the files it checked,
check the error code and if non-zero, fail the test with a
nice small error message.
2022-08-05 09:41:05 +02:00
Christian Kellner
cae23de605 test/pylint: add autopep8 test
Add a test to ensure our source code is PEP-8 compliant.
2022-08-05 09:41:05 +02:00
Christian Kellner
f05078f66e global: fix PEP-8 formatting
This patch was generated by running `autopep8 --diff` on the
source tree and then applying the diff.
2022-08-05 09:41:05 +02:00
Christian Kellner
bb644cdd07 test: add have_autopep8 method
Add a helper to check if the `autopep8` command is available.
2022-08-05 09:41:05 +02:00
Christian Kellner
620f7c0f3e test/pylint: extract source files into fixture
Extract the code that discovers the source files into a fixture;
this is done so that we can share that other future tests.
2022-08-05 09:41:05 +02:00
Christian Kellner
bf2789fd91 test/pylint: convert to pytest
Convert the test to using pytest instead of unittest.
2022-08-05 09:41:05 +02:00
Christian Kellner
a3bc5f7692 stages/gcp.guest-agent.conf: warning -> info
Inform when a new guest-agent configuration file is created,
but remove the warning prefix, since it is perfectly fine if
the file does not yet exist.
2022-08-04 08:08:02 +02:00
Christian Kellner
24ad788d3c stages/gcp.guest-agent.conf: specify encoding
When opening files, always specify the encoding as this will
become a linter warning in the near future.
2022-08-04 08:08:02 +02:00
Christian Kellner
cbffd9d104 stages/gcp.guest-agent.conf: add short header
Our format for the global module doc-string is usually:
"""
<short summary>

<longer description>
"""

Introduce the short summary and also reformat the rest of the
doc string a bit.
2022-08-04 08:08:02 +02:00
Christian Kellner
679688f66f stages/gcp.guest-agent.conf: fix some whitespaces
Be more PEP-8 (two lines between methods). Additionally, separate
the builtin imports from library imports and osbuild imports.
2022-08-04 08:08:02 +02:00
fkolwa
2bca7b07f3 stages: add instance_configs.cfg.distro
test/data: add instance_configs.cfg.distro test
2022-08-03 15:39:35 +02:00
schutzbot
f91bb0a24f Post release version bump
[skip ci]
2022-08-03 08:18:04 +00:00
Simon de Vlieger
f3e2c8d5e9 stage: add an rhsm.facts stage
This stage allows to manifests to define information to be put into a
built image. The information can then later be used by RHSM/Insights.

The facts are stored in `/usr/share/osbuild/rhsm.facts` and then
symlinked into `/etc/rhsm/facts/osbuild.facts`.
2022-08-03 08:54:51 +02:00
schutzbot
5fb7acc53e Post release version bump
[skip ci]
2022-07-27 09:06:45 +00:00
David Rheinsberg
376cbffd13 schemas/osbuild2: mark version as required
The v2 manifest requires the `version` key to be present to be
distinguishable from v1. While technically the manifest can be used
standalong without a `version` key, it does prevent us implementing the
manifest correctly in osbuild (i.e., we are unable to process a v2
manifest without the `version` key, because we are unable to autodetect
it then).

Mark the key as required. It does kind of break backwards compatibility
of the schema, but at the same time we always treated it this way,
anyway. So this should be fine.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-25 16:01:48 +02:00
David Rheinsberg
10f076f34d schemas/osbuild2: drop trailing spaces
Drop trailing spaces from the schema.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-25 16:01:48 +02:00
David Rheinsberg
38662b22a6 meta: fix lookup of invalid schemata
We need to initialize `schema` to `None`, otherwise it will be an access
to an uninitialized variable when looking up invalid schemata:

    [...]
      File "[...]/osbuild/meta.py", line 583, in get_schema
        schema = Schema(schema, name or klass)
    UnboundLocalError: local variable 'schema' referenced before assignment

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-25 16:01:48 +02:00
David Rheinsberg
4a40b732ea meta: fix type annotation of schema input
The schema input of Schema.__init__ is a python-native representation
of a JSON object, so it can be any kind of dictionary. Furthermore, it
is optional.

Fix the type to be Optional[Dict].

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-25 16:01:48 +02:00
David Rheinsberg
b41e591b02 docs/osbuild-manifest.5: fix typo
Fix a missing space in:

    `whichproduce` -> `which produce`

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-25 16:01:48 +02:00
Alexander Todorov
4911ca5b65 tests: Update OSBUILD_COMPOSER_COMMIT for testing on Fedora 36 2022-07-25 15:58:43 +02:00
Alexander Todorov
40b76a6bb2 COMPOSER-1622: Enable testing on Fedora 36 2022-07-25 15:58:43 +02:00
Christian Kellner
9956f54c97 stages/containers.storage.conf: support pytoml
RHEL 8 only has the old pytoml library, so we need to support that
as well. Try falling back if importing `toml` fails.
2022-07-23 11:12:15 +02:00
Christian Kellner
184ed2d71b stages/containers.storage.conf: fix filename prop
The schema said `filename` but we were accessing `location`. Ups.
2022-07-22 20:02:24 +02:00
Christian Kellner
6fee1051c7 stages/container.storage.conf: restrict locations
Only allow the two known working locations as values for `filename`.
2022-07-22 20:02:24 +02:00
David Rheinsberg
d77e87f3c1 mounts/fat: Xfs -> Fat
Fix the wrong symbol prefixes for the Fat-Mounter. Looks like a
copy-paste from the Xfs-mounter.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-22 18:06:24 +02:00
David Rheinsberg
2544486332 mounts/noop: drop wrong host-command reference
The noop mount does not use FileSystemMountService, and as such never
calls into `mount(1)`. Drop this information from the documentation.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-07-22 18:06:24 +02:00
Ondřej Budai
092f886904 stages/users: support a dot inside a username
From IEEE Std 1003.1-2017:

 3.437 User Name:
A string that is used to identify a user; see also User Database. To be
portable across systems conforming to POSIX.1-2017, the value is composed
of characters from the portable filename character set. The <hyphen-minus>
character should not be used as the first character of a portable user name.

 3.282 Portable Filename Character Set
The set of characters from which portable filenames are constructed.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 . _ -

The last three characters are the <period>, <underscore>, and <hyphen-minus>
characters, respectively.

---

The regex checking the username in org.osbuild.users stage omitted the
<period> character before. This commit adds it and modifies the stage
test in order to cover this change.

Fixes: rhbz#2104464
2022-07-21 14:52:57 +02:00
schutzbot
7dcc7d4499 Post release version bump
[skip ci]
2022-07-20 08:17:54 +00:00
Christian Kellner
51315a985a stages/skopeo: use extra intermediate download dir
Instead of downloading the image directly to the temporary directory
and then moving that temporary directory into the cache use one more
intermediate directory and move that into the cache. The reason is
that on Python 3.6 removing the temporary directory itself will make
Python crash like this:

Python 3.6.8 (default, Sep  9 2021, 07:49:02)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> with tempfile.TemporaryDirectory(prefix="tmp-download-") as tmpdir:
...     import os
...     os.rename(tmpdir, "/tmp/foo")

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib64/python3.6/tempfile.py", line 809, in __exit__
    self.cleanup()
  File "/usr/lib64/python3.6/tempfile.py", line 813, in cleanup
    _shutil.rmtree(self.name)
  File "/usr/lib64/python3.6/shutil.py", line 477, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/lib64/python3.6/shutil.py", line 475, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp-download-adl86mwa'
2022-07-19 19:52:25 +02:00
Jakub Rusz
7cd4b4ea66 tests: run tests on RHEL-9.1 and 8.7 nightly 2022-07-16 18:59:06 +02:00
Christian Kellner
4647140808 source/skopeo: use subprocess.check_output
Use `subprocess.check_output` instead of `run(..., capture_output=True)`
since the latter only got added in Python 3.7 and our codebase needs to
be compatible with 3.6 due to RHEL 8.x.
2022-07-13 20:06:42 +02:00