Commit graph

516 commits

Author SHA1 Message Date
Michael Ho
21054b181c stages/org.osbuild.users: support multiple SSH keys
Add a new attribute, "keys", to allow specifying multiple public SSH
keys to install to a users authorized_keys file.

This maintains backwards compatibility with the existing "key" attribute
that can only specify a single SSH key to install into the file (without
using some newline hacks).

Signed-off-by: Michael Ho <michael.ho@ieee.org>
2023-10-16 18:05:27 +02:00
Dusty Mabe
3cc733d7cd stages/ostree.deploy: support an ostree input
This will allow a user to specify an input directly to the deploy
stage rather than requiring a ostree.pull stage to be called first.

Adding inputs will also be useful when we soon add support for
deploying from a container rather than just deploying from an existing
ostree commit in a repo.
2023-10-06 15:55:26 +02:00
Dusty Mabe
c6c9454f6f osbuild/util: create pull_local function in util/ostree
This is prep for sharing this functionality with other stages than
the ostree.pull stage.
2023-10-06 15:55:26 +02:00
Dusty Mabe
4e99e80c4a osbuild/util: hoist ostree code into util/ostree
Prep for sharing with other stages later.
2023-10-06 15:55:26 +02:00
Dusty Mabe
34d3471fdd stages/ostree.passwd: delete dead code ostree function
As far as I can tell this is unused in this file.
2023-10-06 15:55:26 +02:00
Dusty Mabe
0f477889be stages/ostree: add deprecation notice/warning
I've been informed that this stage is old and shouldn't be used for
newly created manifests. Let's add a comment to the top for future
explorers of this code base.
2023-10-06 15:55:26 +02:00
Maxime Ripard
7af2f1a5c1 Create additional option to setup FS geometry
Some platforms like the TI AM62 require a particular FAT geometry for
their CPU to read the file system (and thus the bootloader). Failing
that the CPU will simply not boot and keep looking for a bootloader.

Let's add some options to enforce a particular filesystem geometry
through the -g option of mkfs.fat.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
2023-10-05 20:17:40 +02:00
Maxime Ripard
e58fc3d289 Consolidate the options setup for mkfs.fat
The current options building code for mkfs.fat prevents to have multiple
options at a time since it will assign the opts list to either the label
or fatsize options.

If both are set, only the last one, fatsize, will be set.

Use the occasion to rewrite the code a bit and limit the number of
lists concatenation.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
2023-10-05 20:17:40 +02:00
Dusty Mabe
4e5de3808e osbuild/util: add containers_source helper
This will hoist even more code into util out of the skopeo stage.
Now a caller can call:

    with containers.container_source(image) as (image_name, image_source):
        print(f"{image_name}, {image_source}")

to process containers inputs.
2023-09-30 02:29:05 +02:00
Dusty Mabe
4cd9af47d0 osbuild/util: hoist container handling code into util/containers
This hoists container handling code from the skopeo stage into
util/containers. It is prep for adding another stage that accepts
containers as an input. The code is common so we should share it
amongst all stages that use containers as input.
2023-09-30 02:29:05 +02:00
Dusty Mabe
c88b3982e8 stages/ostree.deploy: switch to v2 schema
Prep for possibly adding inputs to the ostree.deploy stage in the
future.
2023-09-28 21:38:58 +02:00
Dusty Mabe
e31b0fe931 stages/ostree.deploy: drop requirement on rootfs option
For Fedora CoreOS we don't actually have any root= kernel command
line option in our baked images. We have services that rely on this
and set up sysroot on first boot. The code in this stage doesn't
require for this option to have been provided and actually gracefully
handles when it's not provided. Let's just change the schema to also
not require it.
2023-09-14 13:02:19 +02:00
Colin Walters
fd44af4fe7 osbuild.ostree.selinux: xref ostree issue for this
We should drop this stage entirely once we have a way to
force on selinux in ostree.
2023-08-31 14:01:12 +02:00
Brian Masney
e7fb2e1117 stages/dracut: add dracut omit drivers option
Add option to exclude specific kernel modules from the initramfs that's
generated by dracut.

Signed-off-by: Brian Masney <bmasney@redhat.com>
2023-08-28 13:25:04 +02:00
Ondřej Budai
3bbded4607 org.osbuild.mkfs.btrfs: add support for -m argument
Osbuild doesn't support creating btrfs over multiple devices, thus it should
be fine to have only single and dup in the schema (other options are for raid)
2023-08-25 12:35:56 +02:00
Ondřej Budai
724183b35c stages: add org.osbuild.btrfs.subvol
A trivial stage to create subvolume on a btrfs partition.
2023-08-25 12:35:56 +02:00
Sayan Paul
61da6124ed stages/systemd:support for user service dropin
systemd unit stage will now be able to add user unit dropin,
this is done by adding an additional field:unit-type
which is set to system by default. It also adds ability
to update the unit config with ConditionPathExists.
Relevant testing updated for the new workflow.

Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
2023-08-16 13:23:16 +02:00
Sayan Paul
ed926ecc71 stages/systemd:support timer units
unit pattern updated to incoporate timer units

Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
2023-08-16 13:23:16 +02:00
Simon de Vlieger
161fe789af dnf4.mark: mark packages in DNF state database
This adjustment allows the definition of the mark with the RPMs and runs
DNF after installing the RPMs to put the proper markings in the DNF
state database. See #455.

This ensures that packages don't get removed during `autoremove` leading
to broken systems.
2023-08-15 00:37:06 +02:00
Brian C. Lane
44c28c8c16 autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
Ondřej Budai
6e254c95af stages/ostree.encapsulate: use new entrypoint on rpm-ostree >=2023.2
rpm-ostree 2023.2 dropped the `rpm-ostree container-encapsulate` entrypoint.
Instead, we have to use `rpm-ostree compose container-encapsulate`.

Adjust the code that it selects the correct entrypoint based on the rpm-ostree
version.

Since the new stage now requires python-yaml, add it to the buildroot and
regenerate all manifests.
2023-08-08 12:41:17 +02:00
Colin Walters
6f81c59894 ostree.encapsulate: It's rpm-ostree, not ostree
We have a lot of copypasta of `def ostree()` but in this
case it's actually rpm-ostree, and we should be clear about that.

(Also in the future this code will need to change
 to use the non-deprecated entrypoint, see
 https://github.com/coreos/rpm-ostree/pull/4527 )
2023-08-05 23:42:50 +02:00
Simon de Vlieger
d60690ce46 tox: add tox
`tox` is a standard testing tool for Python projects, this allows you to
test locally with all your installed Python version with the following
command:

`tox -m test -p all`

To run the tests in parallel for all supported Python versions.

To run linters or type analysis:

```
tox -m lint -p all
tox -m type -p all
```

This commit *also* disables the `import-error` warning from `pylint`,
not all Python versions have the system-installed Python libraries
available and they can't be fetched from PyPI.

Some linters have been added and the general order linters run in has
been changed. This allows for quicker test failure when running
`tox -m lint`. As a consequence the `test_pylint` test has been removed
as it's role can now be fulfilled by `tox`.

Other assorted linter fixes due to newer versions:
- use a str.join method (`consider-using-join`)
- fix various (newer) mypy and pylint issues
- comments starting with `#` and no space due to `autopep8`

This also changes our CI to use the new `tox` setup and on top of that
pins the versions of linters used. This might move into separate
requirements.txt files later on to allow for easier updating of those
dependencies.
2023-08-01 15:01:13 +02:00
Gianluca Zuccarelli
74eed6a33b stages: add openscap autotailor stage
Add a new stage to generate an OpenSCAP tailoring file. The stage
overrides a base OpenSCAP profile by enabling and disabling user
selected rules and creates a new profile name which can be used for
OpenSCAP scanning and remediation.
2023-07-18 15:29:13 -07:00
Brian C. Lane
8f6535cacc org.osbuild.rpm: Add some context to rpmkeys failure
This will hopefully help debug problems when the signature check fails.
You need to manually take the hash and look it up in the manifest
sources list to figure out what package failed since this stage doesn't
have access to sources.
2023-07-18 18:42:47 +02:00
Simon de Vlieger
f1b79c8a73 stage: anaconda, allow access to more config
Anaconda has deprecated the `kickstart_modules` directive and instead
now has `activatable_`, `forbidden_`, and `optional_modules`. This is
available starting in Fedora 35.

This change allows frontend code (`osbuild-composer`) to put version
checks in place to write the correct keys.
2023-07-18 13:41:05 +02:00
Ondřej Budai
c01caae3ac stages/squashfs: add support for zstd compression
Fedora and RHEL 9 kernels support it and since it's an interesting alternative
to other compression methods, we should support it in osbuild.

I also took the liberty of sorting the compression methods alphabetically.
2023-07-18 08:58:26 +02:00
Simon de Vlieger
36ee0d3edc stages/sysconfig: add desktop support 2023-07-17 12:15:12 +02:00
Simon de Vlieger
829183a1f3 stages/sysconfig: add livesys support 2023-07-17 12:15:12 +02:00
Ondřej Budai
dc372bbdea stages/rpm: set machine-id to 444
According to the systemd spec file, /etc/machine-id should have the 444
permissions. Thus, we need to chmod the file to 444 after it's created.

See:
 - 9c05b44a4b/f/systemd.spec (_821)
 - https://bugzilla.redhat.com/show_bug.cgi?id=2221269
 - https://issues.redhat.com/browse/COMPOSER-1992
2023-07-12 10:53:31 +02:00
Antonio Murdaca
4bfd646b0d stages: add new zstd stage
typo fix test/data/stages/README.md
add updated test-data after adding zstd to fedora-34-build-v2.mpp.json

Signed-off-by: Sarita Mahajan <sarmahaj@redhat.com>
2023-06-14 09:44:00 +02:00
Simon de Vlieger
4bd169c20e stage: add a livesys stage
This stage is necessary for the live image work being done in
`osbuild-composer` at the moment.
2023-05-31 09:30:55 +02:00
Tomáš Hozza
3e780762cb stages/sgdisk: option to not quote partition names passed to sgdisk
The partition name in the sgdisk stage was previously quoted when
passed to sgdisk as an argument. I think that this was done because
the sgdisk man page states that:

```
If you want to set a name that includes a space, enclose it in
quotation marks, as in sgdisk -c 1:"Sample Name" /dev/sdb.
```

However, this should apply only when sgdisk is run in a shell, so that
the argument is not split by shell into multiple arguments and passes
as a single string.

The stage is executing sgdisk using Python `subprocess` module, which
does not need strings with spaces to be quoted, because they are passed
to the command as separate items which are not split in any way.

The previous behavior of the stage was that these quotes became part of
the actual partition name in the partition table.

After a discussion within the team, we determined that this is a bug.
However, fixing it would result in osbuild producing a different
artifact for the same manifest, compared to osbuild version without such
fix. This is undesired.

For backward compatibility, a new `quote_partition_name` property is
added to the stage options, which can be used to make the stage not
quote the partition name when passed to `sgdisk`. As a result, the
partition name won't be quoted in the partition table.

The default stage behavior us kept.

Modify unit tests to use this option by default.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-05-26 08:43:52 +02:00
Eric Chanudet
267f3909bd stages/sfdisk: support changing GPT partition attribute bits
util-linux 2.38.1, at least, does not accept raw bit indexes for the
reserved bits (Bit0-2). The undefined ones are out of reach as well and
will have sfdisk throw an error. Only the GUID specific ones can be
passed as raw indexes. This can be verified with the --part-attrs
option. It replicates the format of the --dump output:

$ dd if=/dev/zero of=disk.img bs=$((4<<10)) count=$((32<<10)
$ sgdisk disk.img -n 0:0:+64M -t 0:0FC63DAF-8483-4772-8E79-3D69D8477DE4 -c 0:root
$ sgdisk disk.img -A1:set:{0,1,2,3,48}
$ sfdisk --dump disk.img
label: gpt
label-id: 7484F730-3429-47BF-8A72-3A7AE1F2D86C
device: disk.img
unit: sectors
first-lba: 34
last-lba: 262110
sector-size: 512

disk.img1 : start=        2048, size=      131072, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=404694AC-247D-43B3-9907-A468E5C038A3, name="root", attrs="RequiredPartition NoBlockIOProtocol LegacyBIOSBootable GUID:48"

$ sfdisk --part-attrs disk.img 1 0
unsupported GPT attribute bit '0'
sfdisk: disk.img: partition 1: failed to set partition attributes

While the --dump output prefixes the GUID specific bits with "GUID:",
that is not necessary for setting them, which is consistent with the
man-page.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
2023-05-25 14:57:28 +02:00
Simon de Vlieger
a348fe2d49 stages/isolinux: default list
Otherwise when `opts` (which isn't `required`) is left out we fail the
stage.
2023-05-23 10:13:15 +02:00
Alexander Larsson
3343696a7b org.osbuild.mkfs.ext4: Add verity option to
This allows enabling the ext4 "verity" feature (which is currently
default to off). This will be needed in the automotive work we're
doing.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2023-05-16 00:03:16 +02:00
Sanne Raymaekers
1fbd9d975f stages/org.osbuild.ovf: support older python3 versions
`str.removesuffix` was introduced in python3.9, yet el8 uses python3.6
by default.
2023-05-09 23:54:01 +02:00
Gianluca Zuccarelli
586d6bbe43 stages/yum.repo: add sslverify field
Add `sslverify` field to the yum.repo stage.
2023-05-03 20:53:52 +02:00
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
Sanne Raymaekers
028bf67a1d stages/org.osbuild.wsl.conf: add stage to configure WSL settings 2023-04-11 10:11:08 +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
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
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
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
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
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
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
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