Commit graph

2323 commits

Author SHA1 Message Date
Ondřej Budai
f60a4e3c84 stages/lorax-script: add missing type of path to the schema
`path` has to be a string, let's make it explicit in the schema.
2023-04-19 12:42:27 +02:00
Ondřej Budai
ce196f287c stages/lorax-script: add missing default basearch to the schema
The code uses x86_64 as a default, see:

basearch = options.get("basearch", "x86_64")

Let's declare that explicitly in the schema to prevent any confusion.
2023-04-19 12:42:27 +02:00
Tomáš Hozza
7cd36f9797 CI: delete duplicate source code check from GitHub action
The test case was testing a subset of the functionality, which is
already tested by test case in `tests.yml`. Delete it, since it does not
add any value.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
bbdb4fbc32 CI: use latest osbuild-ci container when regenerating test data
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
bf3e096735 Fix errors reported by new version of mypy
Fix the following errors:

```
osbuild/util/lvm2.py:117: error: Only instance methods can be decorated with @property
osbuild/api.py:50: error: Only instance methods can be decorated with @property
osbuild/sources.py:85: error: Only instance methods can be decorated with @property
```

Chaining of `@classmethod` and `@property` has been deprecated since
Python 3.11 with a note that chaining didn't work correctly in some
cases.

Relevant links:
https://github.com/python/mypy/issues/13746
https://docs.python.org/3.11/whatsnew/3.11.html#language-builtins

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
c59c5c31de Test: use osbuild-ci container with dosfstools
The `test_mount` test case requires dosfstools to create a FAT
filesystem in a testing image.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
56987fdda4 Test: make run/test_mount.py not depend on installed osbuild
Previously, the unit test depended on osbuild modules being installed on
the system. As a result, this made the test not work in CI where we do
not install osbuild when running unit tests. In addition, the stage
executed by the unit test would use different version of osbuild
internals than the version that is being tests, which could result in
issues or not testing the intended code.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
975965510b Test: handle non-existence of /run/osbuild in test/run/test_mount.py
The directory does not exist when the unit test is run in CI. Handle
this case by ensuring that parent directories are created as needed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
1a2776bf1b Test: run all tests from test/run in CI
In CI, we list specific tests from `test/run` to run them in parallel.
This is different than what we do with tests in `test/mod` and
`test/src`.

It seems that as a result, we did not run tests from the following
files in CI:
 - `test_devices.py`
 - `test_mount.py`

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
schutzbot
1df905222e Post release version bump
[skip ci]
2023-04-12 08:13:49 +00:00
Sanne Raymaekers
33597e82a3 test/data/stages: add wsl.conf test 2023-04-11 10:11:08 +02:00
Sanne Raymaekers
028bf67a1d stages/org.osbuild.wsl.conf: add stage to configure WSL settings 2023-04-11 10:11:08 +02:00
Sanne Raymaekers
5dbf596ffa .gitlab-ci: drop fedora-35 2023-04-06 14:49:23 +02:00
Sanne Raymaekers
72db212a61 .gitlab-ci: remove RHEL 8.6/9.0 ga runners 2023-04-05 18:03:48 +02:00
Simon de Vlieger
12e4e541c3 stage/systemd.preset: be able to write a preset file
The right way to enable services is to use a preset file instead of
writing directly into /etc. This adds a new stage called
`org.osbuild.systemd.preset` to do so.
2023-04-05 14:34:39 +02:00
Sanne Raymaekers
93f90b9443 .gitlab-ci: use RHEL 87/91 GA in rpmbuild and ostree test stages 2023-04-04 20:35:57 +02:00
Sanne Raymaekers
efa038197d stages/org.osbuild.ovf: support older python3 versions
The `capture_output` option was added in python3.7, yet el8 has
python3.6 by default.
2023-04-04 20:35:57 +02:00
Simon de Vlieger
76a80bd8c5 ci: remove codecov
`codecov` often reports weird diffs and we rarely take action on a
codecov failure in CI.

This closes #1263.
2023-04-01 15:12:58 +02:00
Achilleas Koutsou
532a4c1166 test: add manifest-list test for skopeo stage
Added another skopeo stage to skopeo/a.mpp.json with a skopeo source for
a container hosted on the osbuild-composer gitlab registry.  The name
points to a manifest list, which refers to two containers (amd64 and
arm64) that contain a single text file (README.md).  The `index` field
is enabled to include the manifest-list as an extra input to the stage.

The diff is updated with the new expected file list.
The containers were created with buildah:

  amd=$(buildah from --arch=amd64 scratch)
  arm=$(buildah from --arch=arm64 scratch)
  buildah config --created-by "Achilleas Koutsou" "${amd}"
  buildah config --created-by "Achilleas Koutsou" "${arm}"
  buildah copy "${amd}" README.md
  buildah copy "${arm}" README.md
  amdid=$(buildah commit --format=docker --rm "${amd}")
  armid=$(buildah commit --format=docker --rm "${arm}")
  name="registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/manifest-list-test"
  buildah manifest create "${name}" "${amdid}" "${armid}"

  podman manifest push --all "${name}" dir:container
2023-03-31 14:57:26 +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
ac2f140d4c stages/skopeo: merge manifest into image directory
When a manifest list is matched with a container image, the skopeo
stage will merge the specified manifest into the container image dir
before copying it to the registry in the OS tree.

If there is no manifest to merge, we maintain the old behaviour of
symlinking the source to work around the ":" in filename issue.
Otherwise, we copy the container directory so that we can merge the
manifest in the new location.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
dd902311c2 stages/skopeo: add manifest-lists input
Add an extra optional input type to the skopeo stage called
`manifest-lists`.  This is a list of file-type inputs that must be a
list of manifest lists, downloaded by the skopeo-index source.

The manifests are parsed and automatically associated with an image from
the required `images` inputs.  If any manifest list is specified and not
used, this is an error.

Adding manifest-lists currently has no effect.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
3a717e170a sources: add org.osbuild.skopeo-index source
A new source module that can download a multi-image manifest list from a
container registry.  This module is very similar to the skopeo source,
but instead downloads a manifest list with `--multi-arch=index-only`.
The checksum of the source object must be the digest of the manifest
list that will be stored and the manifest that is downloaded must be a
manifest-list.
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
Achilleas Koutsou
ce29a4af73 sources/skopeo: change local container format
Change the local storage format for containers to the `dir` format.
The `dir` format will be used to retain signatures and manifests.

The remove-signatures option is removed since the storage format now
supports them.

The final move (os.rename()) at the end of the fetch_one() method now
creates the checksum directory if it doesn't exist and moves the child
archive into it, adding to any existing archives that might exist in
other formats (from a previous version downloading a `docker-archive`).

Dropped the .tar suffix from the symlink in the skopeo stage since it's
not necessary and the target of the link might be a directory now.

The parent class exists() method checks if there is a *file* in the
sources cache that matches the checksum.  For containers, this used to
be a file called container-image.tar under a directory that matches the
checksum, so for containers it always returned False.  Added an override
for the skopeo source that checks for the new directory archive.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
be76d6f355 sources/skopeo: fix comment typo 2023-03-31 14:57:26 +02:00
Achilleas Koutsou
5f76ec03a7 inputs/containers: change archive format to dir
The format so far was assumed to be `docker-archive` if the container
was coming from a source and `oci-archive` if it was coming from a
pipeline.  The source format will now be changed to `dir` instead of
`docker-archive`.  The pipeline format remains `oci-archive`.

With the new archive format being `dir`, the source can't be linked into
the build root and is bind mounted instead with the use of a MountGuard
created with the instance of the service, and torn down when the service
is stopped.

The _data field is removed from the map functions.  It was unused and
these functions aren't part of the abstract class so they don't need to
have consistent signatures.

Update the skopeo stage with support for the newly supported `dir`
format.
2023-03-31 14:57:26 +02:00
SchutzBot
998f640387 schutzfile: update manifest-db ref 2023-03-20 2023-03-31 13:28:32 +02:00
schutzbot
7f68136324 Post release version bump
[skip ci]
2023-03-29 08:14:39 +00:00
Sanne Raymaekers
bae4f77661 stages: add ovf stage
This stage generates an ovf descriptor and a manifest intended for
vSphere. The resulting artifacts can be tarred together with the vmdk
into an ova.
2023-03-28 23:07:38 +02:00
Jakub Rusz
cfed69adca CI: update fedora-38 images 2023-03-28 10:02:53 +02:00
Jakub Rusz
4d5715faf1 rpmbuild: build on fedora-38 2023-03-27 14:31:52 +03:00
Simon de Vlieger
162587724a test: this test requires to be able to bindmount 2023-03-20 16:32:47 +01:00
Thomas Lavocat
2848867434 ci: update manifest tests
Manifest-db is finally unblocked and we can update the reference commit.
Done manually this time to speed up the process.
I'm also updating the set of distributions we are testing on, upgrading
it to what's is generated on manifest db.
2023-03-15 10:34:09 +01:00
Thomas Lavocat
ceb4b946dd pkg: osbuild should depend on skopeo
fixes 1105
2023-03-15 10:34:09 +01:00
schutzbot
36341203a1 Post release version bump
[skip ci]
2023-02-27 16:41:44 +00:00
Antonio Murdaca
345b2a5997 stages/ignition: support multi kargs in network kcmdline
As of today the functionality is broken if somebody passes more than one
karg as the join would simply unify the strings but
ignition_network_kcmdline is unquoted and results in just the very first
karg to be consumed by the set command.

Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-27 17:39:14 +01:00
Thomas Lavocat
996c1ca889 ci: update terraform reference
To stop leaking CI resources, we need to be above commit sha 89fb25d15.
Update to latest reference
2023-02-23 12:48:45 +01:00
schutzbot
b5b3a5ba8c Post release version bump
[skip ci]
2023-02-20 14:37:54 +00:00
Tomáš Hozza
200c2b0129 stages/copy: add option to remove destination before copying
Extend the copy stage to optionally allow removing the destination
before copying. This allows one to not follow symlinks if the
destination is a symlink to a file. By default, `cp` would change
the file pointed to by the destination if it is symlink.

Extend the stage doc text to cover the behavior with regard to
destination being a symlink.

Add unit tests for the copy stage to also test the newly added option.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-20 10:31:06 +01:00
Achilleas Koutsou
d3229dc929 stages/shell.init: add top-level files property
Add a top level property "files" to the schema and move the rest of the
existing schema one level down.  This way we can support adding global
properties in the future if we ever need to expand the scope of the
stage.
2023-02-15 18:14:01 +01:00
Achilleas Koutsou
eb903a9596 stages/shell.init: restrict filename pattern
Old filename pattern was too wide and contained a bug in the form of
.-_, which defined a range instead of three characters.
2023-02-15 18:14:01 +01:00
Achilleas Koutsou
b848e5d9df stages/shell.init: add pattern for env var names
Pattern for valid environment variable names as defined in
The Open Group Base Specifications Issue 7, 2018 edition
IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008)

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

Updated tests to match UPPERCASE ONLY var names.
2023-02-15 18:14:01 +01:00
schutzbot
291726a83b Post release version bump
[skip ci]
2023-02-15 08:15:11 +00:00
Thomas Lavocat
5eefdc1e9a mounts: add possiblity to use norecovery with ro
To avoid kernel panics if the kernel attempts to recover the filesystem
when it's mounted as readonly. Offer the possiblity to use the
norecovery option for journaling file systems (Xfs, Ext4, Btrfs).
2023-02-10 14:09:03 +01:00
Achilleas Koutsou
d5701dac28 test: add unit test for org.osbuild.shell.init 2023-02-08 13:30:39 +01:00
Achilleas Koutsou
03b467da72 stages: add shell.init stage
New stage for writing shell init files in /etc/profile.d.
Currently only supports writing environment variables as key-value
pairs.
2023-02-08 13:30:39 +01:00
schutzbot
ab2d48350a Post release version bump
[skip ci]
2023-02-07 15:51:39 +00:00
Tomáš Hozza
16063fff57 Add org.osbuild.chown stage
Add a new `org.osbuild.chown` stage for setting user and group ownershop
of files. The stage runs the `chown` from the image using `chroot` to
enable it to use users and groups that exist only in the (image) tree.

Add unit test testing the stage in various scenarios.

Co-authored-by: Janine Olear <pninak@web.de>
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-07 12:14:01 +01:00
Thomas Lavocat
b97b78382f mounts: add a default value for readonly
To clarify the behavior of the mounters, specify that by default it's
not gonna mount as readonly.
2023-02-01 12:29:58 +01:00