Commit graph

436 commits

Author SHA1 Message Date
David Rheinsberg
054bba5228 stages/greenboot: avoid new pylint suppressions
The `consider-using-f-string` suppression is new, thus old pylint will
complain about unknown directives. If we start ignoring unknown
directives for this reasons, we will no longer get warned about
misspelled directives. Hence, lets avoid this for now and just use an
f-string.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-14 12:26:37 +02:00
David Rheinsberg
cdd65d4fd9 stages/greenboot: ignore f-string recommendation
The explicit string-formatting is definitely easier to manage than an
f-string in the greenboot case. Make pylint suppress its recommendation.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
2022-09-13 16:21:14 +02:00
Simon de Vlieger
ea6085fae6 osbuild: run isort on all files 2022-09-12 13:32:51 +02:00
Simon de Vlieger
b07aca5d86 modules: explicit encodings for open() 2022-09-09 15:33:29 +02:00
Alexander Larsson
f4bfce05e3 org.osbuild.oci-archive: Support setting Entrypoint
This allows setting Entrypoint (as well as Cmd) in the oci image,
as per the spec:

  https://github.com/opencontainers/image-spec/blob/main/config.md

Note: These two are not equivalent, the Cmd part is replaced by the
argument on the `docker run` commandline, whereas the entrypoint is
kept from the config, so it is important to expose both of these.
2022-09-05 13:10:47 +02:00
Sayan Paul
28854f452a Add greenboot configuration management via osbuild
The script will update /etc/greenboot/greenboot.conf if user passes
the parameter in the config. Right now this only tweaks one config but
it will/can be expanded if other use cases come.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2022-08-23 16:53:55 +02:00
Achilleas Koutsou
b87eaf6032 stages/ostree.remotes: support contenturl
OSTree remotes can be configured with a contenturl that is separate from
the metadata url.  When specified, the contenturl is used for content
and the url is used only for metadata.
Updated the description of the url property for clarity.
2022-08-22 20:17:40 +02:00
Achilleas Koutsou
2bff83364b stages/ostree.remotes: support gpgkeypath
OSTree remotes can be configured to import keys from a file on disk or a
directory containing multiple keys.

When specified, explicitly enables gpg-verify=true.
2022-08-22 20:17:40 +02:00
Christian Kellner
a967c61d17 stages/rpm: ability to set database path
Add a new option `dbpath` that controls the database path of the
rpm database.
2022-08-15 18:22:59 +02:00
Christian Kellner
8c00907461 stages/rpm.macros: new-line terminate values
Needed if we want to specify multiple values and even for the
single value use case this is the right thing to do.
2022-08-15 18:22:59 +02:00
Christian Kellner
b33f178a11 stages/rpm.macros: allow setting of _dbpath
Allow setting the database path via the `_dbpath` variable.
2022-08-15 18:22:59 +02: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
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
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
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
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
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
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
Simon de Vlieger
3fd864e5a9 osbuild: fix optional-types
Optional types were provided in places but were not always correct. Add
mypy checking and fix those that fail(ed).
2022-07-13 17:31:37 +02:00
Christian Kellner
6e66c69608 stages: add org.osbuild.containers.storage.conf
New stage to  create or modify `containers-storage.conf` config
files. The currently implement strategy is to merge the given
and existing configuration options.
2022-07-11 16:25:56 +02:00
Gianluca Zuccarelli
852fad9fcb oscap: image build remediation
Refactor the oscap remediation stage to
scan and run remediatoin on the image tree
rather than running the remediation at first
boot.
2022-07-06 09:59:00 +02:00
Christian Kellner
1235c62f8b stages/dnf.config: extend documentation
Add a few more words about the stage.
2022-06-30 09:37:27 +01:00
Christian Kellner
4c12967c0d stages/dnf.config: add support for tsflags
Add support for specifying rpm transaction flags via the `tsflags`
options. See `dnf.conf(5)` for more details.
2022-06-30 09:37:27 +01:00
Christian Kellner
c1c6ab6493 stages/dnf.config: fix schema for config.main
The properties for `main` were not properly defined and but also
not really checked since `additionalProperties` was not defined.
2022-06-30 09:37:27 +01:00
Christian Kellner
57b320f04f stages/dnf.config: specify encondig for open
This is a pyling warning `W1514` "using open without explicitly
specifying an encoding" in newer version, so fix this.
2022-06-30 09:37:27 +01:00
Christian Kellner
10b8c0dcdc stages/rpm.macros: new stage to set rpm macros
This is to persistently set specific RPM macros. Currently only
`_install_langs` is supported.
2022-06-30 00:17:23 +01:00
Christian Kellner
34ebe60bf0 stages/rpm: new option to set _install_langs
RPM supports installing only specific locales by setting the
`_install_langs` macro.
2022-06-30 00:17:23 +01:00
Christian Kellner
a6e7070b13 stages/oci-archive: make config optional in code
According to our schema `config` is optional but the code actually
accessed it unconditionally; fix that.
2022-06-30 00:03:49 +02:00
Christian Kellner
b761188b98 stages/oci-archive: fix comment to use single # 2022-06-30 00:03:49 +02:00
Christian Kellner
9b548d12c7 stages/oci-archive: specify encoding for open
This is a pyling warning `W1514` "using open without explicitly
specifying an encoding" in newer version, so fix this.
2022-06-30 00:03:49 +02:00
Christian Kellner
4d39f9ec2b stages: add new org.osbuild.rpmkeys.import stage
Add a new stage to import public keys into the RPM database via the
`rpmkeys` command. This is similar as to what the `org.osbuild.rpm`
stage already does but it uses inputs instead of inline data.
2022-06-25 13:19:11 +01:00
Jelle van der Waa
923cc60fdb stages: add vagrant stage for libvirt
This commit introduces a new vagrant stage and initially only supports
the libvirt backend. The vagrant stage takes a disk image as input
generates a Vagrantfile and metadata.json.
2022-06-23 11:06:12 +02:00
Christian Kellner
d602b5ff7f stages/mkfs.fat: pass -I command line option
The option will force `mkfs.fat` to ignore existing partitions on
the target device. The check is done via the corresponding device
node in sysfs, i.e. the contents of the `partition` attribute in
`/sys/dev/block/<major>:<minor>`. In certain situations this info
can be stale. Passing `-I` will work-around these situations.
2022-06-20 11:19:33 +02:00
Christian Kellner
86123da599 stages/qemu: expose vpc options
Currently we hard code the vpc options `subformat=fixed` and
`force_size`, which are needed to generate valid azure images
with newer versions of qemu. But for other use cases or other
versions of qemu these options might not be wanted or valid.
Expose all the options but with defaults corresponding to the
old behavior.
Add a unit test for the `force_size` option to check its
effect. Also add a check for the correct size to the existing, 
default value (i.e. `force_size` being `true`).
2022-06-15 13:41:11 +02:00
Gianluca Zuccarelli
66d2cf6df5 stages: add oscap-remediation stage
Add a new stage to handle openscap first boot
remediation. The openscap-remediation.service
looks for a `/system-update` symlink which
points to an openscap config file. This stage
creates both the necessary configuration and
the `/system-update` symlink.
2022-05-31 01:32:49 +02:00
Christian Kellner
e1c2d642dc stages/grub2.legacy: replace arch with platform
The `architecture` served two purposes: 1) the selection of the loader
and 2) the selection of the platform. Instead of inferring the latter
from `architecture`, it is now explicitly specified as a property of
the `bios` value, which in turn was transformed into an object.
The loader is still inferred but since `bios` is an object now there
is the option of adding an explicit `loader` option to it.
All this should make it more transparent what is happening and is
also more in line with the normal `grub2` stage.
2022-05-29 14:02:16 +02:00
Christian Kellner
dcc56d083f stages/grub2.legacy: make schema stricter
The code requires that `id`, `product` and `kernel` are defined for
each entry. Reflect that in the schema. Require at least one entry.
2022-05-29 14:02:16 +02:00
Christian Kellner
8137597ac4 stages/grub2.legacy: use x86 instead of x64
The usage `x64` is to specific since we could indeed boot 32 bit
`x86`, so just use that.
2022-05-28 17:13:17 +01:00
Christian Kellner
b96ee08ce1 stages/grub2.legacy: make the "bios" option a bool
We use an internal mapping from `architecture` to the needed
grub2 platform identifier, there is no need to pass it in.
Change it to a boolean.
2022-05-28 17:13:17 +01:00
Christian Kellner
e0fbbdaa5e stages: add new sgdisk stage
Can be used to create partition tables via GPT laypout via `sgdisk(8)`.
The schema of `partitions` is intentionally kept identical to the one
in `org.osbuild.sfdisk`.
Add corresponding tests.
2022-05-23 13:00:44 +02:00
Christian Kellner
e51d08ba9e stages/ostree.passwd: fix subid source path
The sub{g,u}id files in the commit are located in `/usr/etc` not
`/etc`. Read the files from there.
2022-05-16 17:51:56 +02:00
Christian Kellner
20daf92cf3 stages/udev.rules: use correct separator
The key-value-operator expressions should separated by comma
not space. Fix this.
2022-05-16 17:19:40 +02:00