Commit graph

343 commits

Author SHA1 Message Date
Christian Kellner
24f41495d9 loop: fix a few typos
Some minor spelling corrections and a correction to the API doc in
one place.
2019-12-13 18:15:08 +01:00
Christian Kellner
c77313079b assembler/qemu: add filesystem label support
Add a (optional) property call `label` to the `filesystem` object to
support labeling the filesystem. Add the label for the ESP to both
UEFI examples.
2019-12-12 17:25:47 +01:00
Christian Kellner
5cae5283d7 samples/f30-aarch64: 64bit ARM examples
Based on the UEFI sample (f30-base-uefi.json). NB: the inclusion
of the dracut-config-generic is needed to disable "host-only" for
dracut so the initramfs will include the virtio_blk block device
driver that is needed to mount the root file system when running
the image in qemu.
2019-12-12 17:25:47 +01:00
Brian C. Lane
4a44fdf317 samples/f30-base-uefi.json: UEFI x86_64 example
Include a basic example to generate a x84_64 UEFI image.
2019-12-12 17:25:47 +01:00
Christian Kellner
accef40124 assembler/qemu: support ESP partitions
Add mkfs_vfat and hook it up into the generic mkfs_for_type()
dispatcher function. Install grub2 to the MBR only if the partition
table is of type "MBR".
2019-12-12 17:25:47 +01:00
Christian Kellner
5eb4ceff2f assembler/qemu: support generic partition layouts
Introduce two new assembler options `pttype` and `partitions` to
allow fine grained control over how the partition table is created.
The first one controls the partition type, either `mbr` (default,
when the key is missing) or `gpt`; if specified the `partitions`
key must contain a list of objects describing the individual
partitions (`start`, `size`, `type`) together with a `filesystem`
object describing the filesystem (`type`, `uuid`, `mountpoint`) to
be created on that partition.
In the case the `pttype` option is missing, the legacy mode is used
where `root_fs_uuid` and `root_fs_type` need to be specified.
2019-12-12 17:25:47 +01:00
Christian Kellner
9688859acf assembler/qemu: install_grub uses partitions
Use the newly available partition information in the install_grub2
method: detect which module to use for the root filesystem and
assert the second stage fits between the MBR and the first partition.
2019-12-12 17:25:47 +01:00
Christian Kellner
9863b5ad10 assembler/qemu: refactor fs creation & mounting
Introduce a generic mkfs_for_type() function that will dispatch
to the correct mkfs function depending on the type. Additionally
refactor the partition creation and mounting code to handle more
than one partition.
2019-12-12 17:25:47 +01:00
Christian Kellner
9b9c604ab7 assembler/qemu: refactor partition table code
Part of the refactoring to support uefi/gpt: the method that creates
the partition table now returns an array of dictionaries corresponding
to the individual partitions that have been created together with the
information for the filesystem that this partition should end up with.
2019-12-12 17:25:47 +01:00
Christian Kellner
b85e8ea673 assembler/qemu: refactor to prepare for uefi/gpt
Prepare the stage for uefi/gpt support by extracting the code that
installs GRUB and creates the partitions into its own functions.
Should not have any effect on the actual data written to the image.
2019-12-12 17:25:47 +01:00
Christian Kellner
ce5f3c4331 stages/grub: add uefi support (optional)
Introduce two new configuration options: `legacy` and `uefi`. The
first one being a boolean (default: True) that controls if GRUB
modules, fonts and the configuration is installed in the right
locations to support legacy boot mode.
The `uefi` option (of type object with a single `vendor` property)
enables UEFI support by writing the configuration into the correct
EFI directory, "/boot/efi/EFI/<vendor>/grub.cfg", where vendor is
taken from said `vendor` property.
2019-12-12 17:25:47 +01:00
Christian Kellner
1f5853a27f stages/grub: extract code to write grub config
Part of refactoring the grub2 stage to be able the handle UEFI. No
semantic change.
2019-12-12 17:25:47 +01:00
Christian Kellner
b6da6418c1 stages/grub: extract font copying code
Part of refactoring the grub2 stage to be able the handle UEFI. No
semantic change.
2019-12-12 17:25:47 +01:00
Christian Kellner
1c0f00e37c stages/grub: extract module copying code
Part of refactoring the grub2 module so it can also handle UEFI.
No semantic change.
2019-12-12 17:25:47 +01:00
Christian Kellner
d1d27567e8 buildroot: dyld workaround also on ppc64le
The workaround of manually linking /lib64 -> /usr/lib64 inside the
container that is needed on s390 is also required on ppc64 because
here the dynamic linker is set to /lib64/ld64.so.2 and the /lib64
link is not created.
2019-12-12 13:16:05 +01:00
Christian Kellner
575039db29 buildroot: work around s390x linker + nspawn issue
Work around a combination of systemd not creating the link from
/lib64 -> /usr/lib64 (see systemd issue #14311) and the dynamic
linker is being set to (/lib/ld64.so.1 -> /lib64/ld64.so.1)
Therefore we manually create the link before calling nspawn
2019-12-12 13:16:05 +01:00
Lars Karlitski
e590dee93b assemblers/tar: fix compression
Commit 283281f broke compression by appending the argument last to the
tar command line. It needs to appear before the file.

Fix that and add a test.

[teg: add minor fix]
2019-12-10 12:07:08 +01:00
Lars Karlitski
f0a7b2261e pipeline: introduce host runner
osbuild currently throws an error when not passing a build environment
on the command line, because the runner is unset. This is annoying on
hosts which only need a runner set, but no build pipeline.

To simplify running osbuild in this common case, introduce
`org.osbuild.host`, which is a runner that is defined to work on the
host that osbuild is installed on. Use this runner by default and
include a symlink to the right runner in the Fedora and RHEL packages.

Also add `runners/org.osbuild.host` to `.gitignore`, so that developers
can set the symlink when running osbuild from the source directory.

Fixes #171
2019-12-02 13:45:48 +01:00
Lars Karlitski
d8bb359e81 6 2019-11-29 19:08:53 +01:00
Lars Karlitski
f64a6aaa64 stages/dnf: disable all dnf plugins
osbuild does not use any plugins. When running without a build root, dnf
shouldn't pull in anything from the host.
2019-11-29 00:45:14 +01:00
Lars Karlitski
7754fd8e78 treesum: don't use dir_fd parameter in os.scandir()
This parameter was added in python 3.7, but we're only depending on 3.6
for RHEL.

Pass a path to `/proc/self/fd/...` instead.
2019-11-29 00:45:14 +01:00
Lars Karlitski
2c564afae8 osbuild.spec: make /usr/lib/osbuild/{stages,assemblers}/osbuild
osbuild bind-mounts its library to this location. The directory needs to
exist, because it is mounting `/usr` read-only.
2019-11-29 00:45:14 +01:00
Lars Karlitski
9f14aa79c4 osbuild.spec: replace tabs with spaces
To silence an rpmlint warning.
2019-11-29 00:45:14 +01:00
Lars Karlitski
2a1f49c8fa assemblers/qemu: add raw.xz format
Amazon images are sometimes delivered as `raw.xz` format.

Use compression level of `-0`, which seems to be what Red Hat is using
for cloud images.
2019-11-28 00:51:16 +01:00
Lars Karlitski
40cd95dbf3 assemblers/qemu: clarify extra_args 2019-11-28 00:51:16 +01:00
Lars Karlitski
d2dbdcf5ef stages/systemd: add default_target
Allow setting the default to boot into.
2019-11-27 22:22:13 +01:00
Lars Karlitski
64713449ce Introduce runners
We've been using a generic `osbuild-run`, which sets up the build
environment (and works around bugs) for all build roots. It is already
getting unwieldy, because it tries to detect the OS for some things it
configures. It's also about to cause problems for RHEL, which doesn't
currently support a python3 shebang without having /etc around.

This patch changes the `build` key in a pipeline to not be a pipeline
itself, but an object with `runner` and `pipeline` keys. `pipeline` is
the build pipeline, as before. `runner` is the name of the runner to
use. Runners are programs in the `runners` subdirectory.

Three runners are included in this patch. They're copies of osbuild-run
for now (except some additions for rhel82). The idea is that each of
them only contains the minimal setup code necessary for an OS, and that
we can review what's needed when updating a build root.

Also modify the `--build-pipeline` command line switch to accept such a
build object (instead of a pipeline) and rename it accordingly, to
`--build-env`.

Correspondingly, `OSBUILD_TEST_BUILD_PIPELINE` → `OSBUILD_TEST_BUILD_ENV`.
2019-11-25 13:05:22 +01:00
Lars Karlitski
616e1ecbba buildroot: run everything with osbuild-run
`osbuild-run` sets up the build root so that programs can be run
correctly in it. It should be run for all programs, not just stages and
assemblers (even though they're the only consumers right now).

Also, conceptually, `osbuild-run` belongs to the build root. We'll
change its implementation based on the build root in a future commit.

The buildroot already sets up `/run/osbuild/api`. It makes sense to have
it manage libdir as well.

A nice side benefit of this is a simplification of the Stage and
Assembler classes, which grew quite complex and contained duplicate
code.
2019-11-25 13:05:22 +01:00
Lars Karlitski
8c02636bae assemblers/rawfs: add support for xfs
This introduces the `root_fs_type` option on the org.osbuild.rawfs
assembler. It only accepts "ext4" and "xfs" values right now and
defaults to "ext4" to preserve backwards compatibility.
2019-11-24 15:12:23 +01:00
Lars Karlitski
2437bb6196 assemblers/qemu: add support for xfs
This introduces the `root_fs_type` option on the org.osbuild.qemu
assembler. It only accepts "ext4" and "xfs" values right now and
defaults to "ext4" to preserve backwards compatibility.
2019-11-24 15:12:23 +01:00
Martin Sehnoutka
a253aedbc2 remove the resize, leave only vpc support and options 2019-11-23 19:35:19 +01:00
Martin Sehnoutka
459a25bba7 Support for vpc format in qemu assembler (fixes #164) 2019-11-23 19:35:19 +01:00
Lars Karlitski
aece548644 stages/dnf: add module_platform_id option
This is needed by modular repositories.
2019-11-18 19:11:21 +01:00
Martin Sehnoutka
fbb43c1c9a Revert "Fill in the license template"
This reverts commit 6add9c387ba647e5e3e71c268843358657caa212 as I
understood the license text in a wrong way.
2019-11-18 12:23:10 +01:00
Will Woods
6164b38fb9 Add STAGE_DESC, STAGE_INFO, and STAGE_OPTS to stages
This commit adds semi-structured documentation to all osbuild stages and
assemblers. The variables added work like this:

* STAGE_DESC: Short description of the stage.
* STAGE_INFO: Longer documentation of the stage, including expected
              behavior, required binaries, etc.
* STAGE_OPTS: A JSON Schema describing the stage's expected/allowed
              options. (see https://json-schema.org/ for details)

It also has a little unittest to check stageinfo - specifically:

1. All (executable) stages in stages/* and assemblers/ must define strings named
   STAGE_DESC, STAGE_INFO, and STAGE_OPTS
2. The contents of STAGE_OPTS must be valid JSON (if you put '{' '}'
   around it)
3. STAGE_OPTS, if non-empty, should have a "properties" object
4. if STAGE_OPTS lists "required" properties, those need to be present
   in the "properties" object.

The test is *not* included in .travis.yml because I'm not sure we want
to fail the build for this, but it's still helpful as a lint-style
check.
2019-11-13 21:47:03 +01:00
Will Woods
9d4b526a25 org.osbuild.rpm: make rpm --install check signatures
It turns out that rpm will happily check signatures on `--install`,
that's just not the default behavior, because of Historical Reasons.

This commit enables RPM's signature checking and drops our manual check,
which will probably speed up the RPM stage a little bit. Fun!

Oh, also there's two bonus code cleanups: one to use f-strings harder,
and one to make sure we ignore whitespace in package checksum strings.
2019-11-13 21:11:39 +01:00
Will Woods
d6ce127a8e org.osbuild.rpm: safe tempfiles
This makes the org.osbuild.rpm stage use safe temporary files for
handling keys and the package manifest.
2019-11-13 21:11:39 +01:00
Will Woods
8b8493cf04 org.osbuild.{dnf,yum}: use safe tempfiles
As a general rule, using temporary files with predictable names is a
security risk. It probably isn't _actually_ a security risk inside
osbuild stages, since they're usually running in some kind of isolated
container environment, but it's still a better idea to use tempfiles.

This makes the dnf and yum stages put their temporary files into a
temporary directory that gets deleted after dnf/yum finishes.
2019-11-13 21:11:39 +01:00
msehnout
93a3f68a31 Fill in the license template
Fixed #159
2019-11-12 12:41:21 +01:00
Lars Karlitski
1f526477d2 5 2019-10-30 18:49:56 +01:00
Christian Kellner
6e5b838892 pipeline: use API to setup stdio inside the container
Use the new the osbuild API to setup the standard input/output
inside the container, i.e. replace stdin, stdout, and stderr with
sockets provided by the host.
2019-10-30 18:44:55 +01:00
Christian Kellner
93e1c60460 api: new host side API to be used by the container
Introduce an osbuild API that can be used by the container to talk
to the osbuild host. It currently supports one method 'setup-stdio'
which should be used by the container to setup its standard input/
output so the stages can transparently do i/o with the osbuild host
via stdio.
The input data (args) is written to a temp-file backed buffer. The
output is either the host's stdout directly or another temp-file
backed buffer; the latter is re-opened (via /proc/self/fd) to get
another file-descriptor for the container, so in theory the host
and the container could do i/o to the same buffer independently.
2019-10-30 18:44:55 +01:00
Christian Kellner
76518db26b dump_fds: add flags and address parameter
Expose the flags, address parameter of the underlying sock.sendmsg
method, in order to be able to explicitly specify the recipient of
the message; as needed in connection-less mode.
2019-10-30 18:44:55 +01:00
Christian Kellner
1c5b97afbc load_fds: use frombytes instead of fromstring
Python 3.2 renamed array.fromstring to array.frombytes, but kept
the former as an, now deprecated, alias. Use the canonical form
which indeed better describes what is going on.
2019-10-30 18:44:55 +01:00
Martin Sehnoutka
27cf84edd5 bind osbuild module from dynamically discovered path 2019-10-21 15:20:31 +02:00
Martin Sehnoutka
831459e9e9 fix execv /usr/lib/osbuild/osbuild-run does not exist
In case osbuild is invoked without libdir parameter, the osbuild files
are not propagated into the buildroot container and therefore all
pipelines containing buildroot fail.

Example:
```
$ sudo osbuild --store /var/osbuild/ qcow2-pipeline.json
...
execv(/usr/lib/osbuild/osbuild-run) failed: No such file or directory
```

Unfortunately this is only the first error. Once you fix it, you realize
that also the symlink from "assemblers" directory is missing and
therefore you cannot import osbuild because it is not available anywhere
in the path. This is why I had to bind the osbuild module from host to
the build container.
2019-10-21 15:20:31 +02:00
Ondřej Budai
ce6f77cbdc stages: add org.osbuild.chrony stage
lorax-composer supports modifying timeservers, this stage implements it.

I was concerned if I should name this stage timeservers or chrony, but
I've decided to go with chrony. If some day in future Fedora/RHEL
changes the ntp client, we can easily introduce new stage named after
the new ntp client. Additionally, this solution enables us to create
systemd-timesyncd stage, which can change timeservers when chrony is not
installed (in that case systemd-timesyncd takes over the ntp
synchronization).
2019-10-19 18:38:17 +02:00
Ondřej Budai
21d91fd6df stages: add org.osbuild.groups stage
lorax-composer supports adding groups, therefore we need it as well.
2019-10-17 16:14:20 +01:00
Ondřej Budai
d0a3f99342 stages/users: set authorized_keys file permissions to 600
Otherwise user may be unable to login. More information:
https://stackoverflow.com/questions/6377009/adding-public-key-to-ssh-authorized-keys-does-not-log-me-in-automatically
2019-10-17 16:11:01 +01:00
Ondřej Budai
dff8d6591b tests: fix ResourceWarning: unclosed file when running osbuild
We don't close osbuild's stdin when no input is given. Don't open stdin
at all when no input is specified.
2019-10-17 16:07:03 +01:00