Commit graph

1943 commits

Author SHA1 Message Date
Christian Kellner
0c8f5c7ef0 pipeline: drop CAP_{NET_ADMIN,SYS_PTRACE} caps
Drop CAP_{NET_ADMIN,SYS_PTRACE} from the default capabilities which
are only needed to run bwrap from inside a stage which is done by
the `ostree.commit` and `ostree.preptree` stages, so retain them
directly there.
2022-04-27 23:05:11 +01:00
Christian Kellner
d14e5f3ee8 meta: ability to specify capabilities for stages
Add new stage metadata `CAPABILITIES` where stages can request
additional capabilities that are not in the default set.
Currently this is not used by any stage since the default set
contains the sum of all needed capabilities.
2022-04-27 23:05:11 +01:00
Christian Kellner
bdcc9ea218 pipeline: retain minimal required capabilities
Drop all capabilities that are not required by any of the stages.
N.B. at least one stage (`ostree.preptree`) itself executes bwrap
itself, which in turn needs `CAP_SYS_PTRACE` and `CAP_NET_ADMIN`.
2022-04-27 23:05:11 +01:00
Christian Kellner
4ac62abbc3 buildroot: ability to drop capabilities
Add a new member variable `caps` that if not `None` indicates the
capabilities to retain, i.e. all other capabilities not specified
will be dropped via `bubblewrap` (`--cap-drop`).
Add corresponding tests.
2022-04-27 23:05:11 +01:00
Christian Kellner
1874c71920 util/linux: add capability utilities 2022-04-27 23:05:11 +01:00
Christian Kellner
46fd8958bb test/util: convert util_linux to pytest
Convert the test from `unittest` to `pytest`. No semantic change.
2022-04-27 23:05:11 +01:00
Christian Kellner
4055774c7b test: remove old pipelines directory
Left over from the conversion of pipeline tests to test/data/manifests
and MPP via commits 7dcc946 and 020e78d.
2022-04-27 23:01:26 +01:00
schutzbot
d6b8839f39 Post release version bump
[skip ci]
2022-04-27 13:30:13 +00:00
Christian Kellner
090f768544 devices/lvm2.lv: add support for lvm devices files
LVM2 introduced system.devices as an alternative way to filter
devices. Since we create devices in a stage the devices won't be
added to the /etc/lvm/devices/system.devices file since /etc/ is
inside the container. As a result the we can't see these devices
and will fail with "Could not find parent device".
Therefore we add support for managing our own per-service devices
file, iff a `system.devices` is present.
2022-04-25 20:38:02 +02:00
Christian Kellner
99abc1373d inputs: support array of objects references
This extends the possible ways of passing references to inputs. The
current ways possible are:
 1) "plain references", an array of strings:
    ["ref1", "ref2", ...]
 2) "object references", a mapping of keys to objects:
    {"ref1": { <options> }, "ref2": { <options> }, ...}

This patch adds a new way:
  3) "array of object references":
    [{"id": "ref1", "options": { ... }}, {"id": ... }, ]

While osbuild promises to preserves the order for "object references"
not all JSON serialization libraries preserve the order since the
JSON specification does leave this up to the implementation.

The new "array of object references" thus allows for specifying the
references together with reference specific options and this in a
specific order.

Additionally this paves the way for specifying the same input twice,
e.g. in the case of the `org.osbuild.files` input where a pipeline
could then be specified twice with different files. This needs core
rework though, since internally we use dictionaries right now.
2022-04-21 16:39:58 +02:00
Christian Kellner
0fe7196c7a inputs/ostree: extract per-ref options schema
Extract the schema for the per-reference options, which in this case
confusingly is the single property "ref".
2022-04-21 16:39:58 +02:00
Christian Kellner
c25857020d test/fmt_v2: add simple check for input references
Specifically this test checks that the order given in the manifest is
preserved when loaded, i.e. the internal dict has the keys ordered in
the same way, independently in which way they were specified -- list
or object.
2022-04-21 16:39:58 +02:00
Christian Kellner
df91d8916d inputs/tree: enforce constraints for plain refs
When using "plain refs", that is, when using an array of strings,
we did not enforce the constraints of exactly one reference. This
was done for dictionary references.
2022-04-21 16:39:58 +02:00
Christian Kellner
ae7ab67cfa inputs/ostree: fix typo
Lets put the `a` back in `dictionaries`.
2022-04-21 16:39:58 +02:00
Christian Kellner
bc99cd9c19 inputs/container: prefix unused arguments with _
The `data` argument is not used, prefix it with `_` so that pylint
knows this is intentional.
2022-04-21 16:39:58 +02:00
Christian Kellner
3e1ecf15b6 inputs/containers: remove unneeded input
The `pathlib` is not used, remove it.
2022-04-21 16:39:58 +02:00
Christian Kellner
136e13eca1 buildroot: don't explicitly add CAP_MAC_ADMIN
This is a left-over from the time when `systemd-nspawn` was used,
which only retained a limited set of capabilities which did not
include `CAP_MAC_ADMIN`[1]. Bubblewrap, on the other hand, retains
all currently capabilities if the process is run as root[2].

[1] see e.g. src/nspawn/nspawn.c#L147 of commit c52950c
[2] see commit abc56644566a6095bb72a5bf70fcee7dd90e9447
2022-04-20 12:05:36 +01:00
Alexander Larsson
68481f48ae Support specifying multiple devices in all mkfs versions (like xfs)
mkfs.xfs already has `additionalProperties: true` for the devices
section, as this is necessary for example when creating lvm2 setups.
This should be possible for other filesystem types too.
2022-04-19 18:00:15 +02:00
Jelle van der Waa
4eb35babed inputs/org.osbuild.tree: fix typo 2022-04-16 15:39:15 +02:00
Jakub Rusz
b7a9e9c5a3 workflows/trigger-gitlab: run Gitlab CI in new image-builder project
We have a new project in Gitlab
https://gitlab.com/redhat/services/products/image-builder/ci/osbuild
and we want to run the CI there instead.
2022-04-14 14:42:50 +02:00
schutzbot
896c897afc Post release version bump
[skip ci]
2022-04-13 13:23:19 +00:00
Jakub Rusz
008d013e1c ci: run ci-details.sh
This script collects useful information about CI runners.
2022-04-13 14:57:27 +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
Jakub Rusz
a5b42a84f2 mockbuild: use rpmrepo in mock templates
We're using rpmrepo snapshots as system repositories on the runners, so
let's use them also for mockbuild.
2022-04-13 14:57:27 +02:00
Jakub Rusz
700a893cf8 Schutzfile: add Schutzfile
Schutzfile contains rpmrepo snapshots for various CI runners that are
used as system repositories to mitigate broken dependencies and similar
issues.
2022-04-13 14:57:27 +02:00
Tomas Hozza
f41edba1fb Support VMDK subformat in qemu assembler 2022-04-07 15:51:44 +02:00
Tomas Hozza
bbe6127ddb Stages: support vmdk subformat in the qemu stage
Support specifying the subformat for the `vmdk` image type in the
`org.osbuild.qemu` stage.
2022-04-05 15:01:34 +02:00
Tomas Hozza
b4593f0f2b Add unit test for org.osbuild.qemu stage
The unit test consists of a manifest creating an empty file, which
is then converted to various formats using the `org.osbuild.qemu` stage
in separate pipelines.

The unit test then builds and exports each pipeline with qemu stage and
inspects the resulting image file using `qemu-img info` command and checks
that the test data specified in `checks.json` is a subset of the data
returned by the command.
2022-04-05 15:01:34 +02:00
schutzbot
744dcedd7a Post release version bump
[skip ci]
2022-03-24 07:42:59 +00:00
Enric Balletbo i Serra
31eed79760 stages/sfdisk: support changing GPT partition attribute bits
When is specified change the GPT partition attribute bits. The attributes
is a comma list of bits numbers or bit names. You can take a look at the
manual page of sfdisk to see the supported attribute bits.
2022-03-24 00:05:32 +01:00
Simon Steinbeiss
b1d703a260 Enable scheduled upstream releases
Instead of a human pushing a tag with the release notes let a bot do the
work.
The bot is part of our composite action in osbuild/release-action on the
create-tag branch. It calculates the next subsequent release version and
creates a tag based on pull request titles associated with the changes
since the last release.
Finally the tag is pushed to the repository.

Unfortunately GH Actions don't allow for reliably fortnightly schedules,
so we do an additional check that determines if this is an even or an
odd week. This will help with correctly scheduling alternating osbuild
and osbuild-composer releases.

For reference, we do exactly the same for osbuild-composer already:
https://github.com/osbuild/osbuild-composer/blob/main/.github/workflows/create-tag.yml
2022-03-24 00:04:49 +01:00
Tomas Hozza
3dea4b934c stages/rpm: don't verify signatures during install
If instructed, the rpm stage checks all digests and signatures of a package
explicitly using `rpmkeys` tool. The default stage behavior is that no
package signatures are checked when installed by the stage (not even
explicitly).

For these reasons, the package signature checking is supposed to be
disabled when installing rpm packages. This was achieved by passing the
`--define "_pkgverify_level none"` option to rpm. However this option
specifies only requirements for a package to be installed and `none`
means that packages without any signature are accepted by rpm. If the
package signature is deemed BAD, the package installation fails even
though this option has been passed to rpm.

There are valid cases when even packages which signature marked as BAD
should be installed. It may happen, that the GPG key used to sign a
package uses an algorithm not allowed by the system crypto policy, e.g.
SHA1. If such GPG key is imported on the system and a package signed
using it is being installed, its installation would fail when the
package is read by rpm. This is because its signatures are by default
checked if they exist in the package.

The desired behavior to not check any package signatures when installing
a package is instead achieved by using `--nosignature` rpm option. It
turns off the whole signature checking mechanism.

Use the `--nosignature` rpm option instead of
`--define "_pkgverify_level none"`, when installing packages using rpm.

Fix https://github.com/osbuild/osbuild/issues/991
2022-03-22 18:41:12 +01:00
Christian Kellner
d38cdb6425 stages/selinux: directly call setfilecon
Instead of using `chcon`, directly call `selinux.setfilecon`.
On systems without SELinux support, i.e. coreutils was built
without `<selinux.h>` present, `chcon` will return `ENOTSUP`
for all calls to SElinux functions like `setfilecon` even if
the selinux libraries are later installed.
Therefore we directly call the new osbuild helper function,
which really is just a wrapper around setting extended file
attributes and thus will work even if SELinux support is not
compiled into coreutils.
The only other thing `chcon` is doing besides a cal to the
`setfilecon` method is to convert the context string to a
new `contex_t` and back to validate it. This should not be
needed since the kernel will do this for us. On system
without SELinux support `context_new` will also not validate
the context.
2022-03-18 20:36:10 +01:00
Christian Kellner
75df59bace util/selinux: add setfilecon method
This is basically a re-implementation of `setfilecon(3)` minus the
translation of human readable context to raw context. Add test for
the new function.
2022-03-18 20:36:10 +01:00
Christian Kellner
5735357b74 test: convert util.selinux test to pytest
No semantic change in the test itself.
2022-03-18 20:36:10 +01:00
Christian Kellner
e11d86cdf3 util/selinux: define XATTR_NAME_SELINUX
Define the extended attribute name for SELinux at the module level and
use that in the `getfilecon` function.
2022-03-18 20:36:10 +01:00
Tom Gundersen
e175529f7c sources/curl: don't limit total download time
Some RPMs might be very large, and limiting the total download time
might lead to failed build even in cases where downloading is making
progress. Instead, set a minimum download speed (1kbps). If the
minimum is not surpassed for 30 seconds in a row, the download fails
and is retried. This follows the logic employed by DNF.

Adjust the number of retries to 10 and the connection timeout to 30,
in order to match what DNF does. One difference is that DNF does 10
retries across all downloads, whereas we do it per download, this
could be changed in a follow-up.

Old:
 - a download taking more than 5 minutes is unconditionally aborted

New:
 - slow but working downloads will never be aborted
 - downloads will be stalled for at most five minutes
   in total before being aborted
 - time spent making progress does not count towards
   the five minutes

Signed-off-by: Tom Gundersen <teg@jklm.no>
2022-03-16 14:48:03 +01:00
Laura Barcziova
87d1299888 Packit: build SRPMs in Copr
Add srpm_build_deps key to the Packit configuration to specify the needed dependencies for SRPM build
and indicate to build SRPM in Copr.
2022-03-09 13:38:29 +00:00
ochosi
53a598afec Post release version bump
[skip ci]
2022-03-04 15:49:16 +00:00
Christian Kellner
d8f36b55fa stages/grub2: option to configure GRUB_DEFAULT
Add a new attribute `config.default` that when set will be written to
`GRUB_DEFAULT`. This should be set to `saved` when a `saved_entry` is
specified so that the functionality will be preserved if the grub cfg
gets regenerated (which is really should not, but we can not prohibit
it).
2022-03-04 16:38:41 +01:00
Tomas Hozza
9054da7d25 stages/firewall: fix fail when setting only the default zone
When the firewall stage is provided with stage options, which set only
the default firewall zone, the `firewall-offline-cmd` command is
executed unconditionally without any parameters. This is because in this
case `ports`, `enabled_services` and `disabled_services` are all an
empty lists. This results in a failure with the following error message:

`Opening of '/etc/sysconfig/system-config-firewall' failed, exiting.`

Make sure that the second invocation of `firewall-offline-cmd` happens
conditionally, only when at least one of the `ports`, `enabled_services`
or `disabled_services` is a non-empty list.

Adjust the stage test to cover this scenario.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-03-04 10:02:27 +01:00
Christian Kellner
3b40125d4a test/lvm2: separate stdout and stderr
In all the invocation of `subprocess.run` stderr and stdout were both
combined in a shared pipe, but lvm sometimes spits out notices and
informational messages on stderr and thus potentially interfering
with the data we are interested in on stdout. Separate the two.
2022-03-04 08:42:35 +01:00
Christian Kellner
81c9444cd5 devices/lvm2.lv: separate stdout and stderr
In all invocations of `subprocess.run` stderr and stdout were both
combined in a shared pipe, but lvm sometimes spits out notices and
informational messages on stderr and thus potentially interfering
with the data we are interested in on stdout. Separate the two.
2022-03-04 08:42:35 +01:00
Christian Kellner
5a5da44c06 stages/rpm: option to import gpg keys from tree
Add a new option `gpgkeys.fromtree` that when specified will
import the specified gpg keys from files located in the tree,
such as `/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release`.
2022-03-04 08:37:38 +01:00
Christian Kellner
7676c459e4 runners: add org.osbuild.fedora37
Fedora has branched, add the corresponding runner.
2022-03-03 10:40:47 +01:00
Jakub Rusz
8f430733c1 ci/deploy: use public EPEL-9 2022-03-02 16:59:11 +01:00
Tomas Hozza
e71a91f5d0 Extend firewall stage to set the default zone
Extend the firewall stage to allow setting the default firewall zone.
Modify the stage unit test accordingly.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-03-02 16:43:22 +01:00
lavocatt
3eb91401cf Post release version bump
[skip ci]
2022-03-02 13:35:20 +00:00
Jelle van der Waa
00c6bf2376 test: update arch manifests for new stages 2022-03-01 16:07:27 +01:00
Jelle van der Waa
b7fe5c724f stages: add org.osbuild.pacman.mirrorlist.conf
Stage for configuring the pacman mirrorlist file.
2022-03-01 16:07:27 +01:00