Commit graph

40 commits

Author SHA1 Message Date
Tom Gundersen
cebed27cd9 osbuild: drop the concept of an input_dir
This removes the possibility of passing in arbitrary input data. We
now restrict ourselves to explicitly specified files/directories or
a base tree given by its pipeline id.

This drops the tar/tree stages/assemblers, as the tree/untree ones
are implicit in osbuild, and if we wish to also support compressed
trees, then we should add that to osbuild core as an option.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-03 13:11:37 +02:00
Tom Gundersen
e607053c32 osbuild.py/pipeline: add the concept of a content store
Whenever an assembler is not specified, the output tree is instead
saved to the content store, in a directory named after the pipeline
id.

This should render the io.weldr.tree assembler redundant.

In order to build the samples as before, specify the content store
as the input directory to build any pipeline that uses the
io.weldr.untree stage.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-03 13:11:37 +02:00
Tom Gundersen
f25cffa151 osbuild.py/pipeline: assign a unique id to every pipeline
This uniquely identifies a pipeline based on its content. Pipelines
are considered equal modulo whitespace and the order of object
elements.

The intention is that two runs of a pipeline with the same id
generates functionaly equivalent ids. It is up to the writers
of stages and pipelines to ensure this property holds.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-03 13:11:37 +02:00
Tom Gundersen
1219f1dc55 osbuild.py: introduce a Pipeline class
This is not a functional change, it is just a wrapper class around the
pipeline state.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-03 13:11:37 +02:00
Lars Karlitski
767b249b2d osbuild: move run() into osbuild.py
This allows for running a pipline from python and for non-interactive
mode, in which all output is captured.
2019-07-01 17:01:26 +02:00
Martin Sehnoutka
1d7f2461a0 make named parameters mandatory 2019-06-21 15:44:40 +02:00
Tom Gundersen
28fd21ba40 osbuild: allow empty output dir
We wanted to force an empty output dir to avoid assembly stages using
previous output when creating their new one, and hence creating
dependencies between osbuild runs. We may still do that, but for now
let's remove the restriction as it seems rather arbitrary to protect
people from themselves to this extent.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 16:07:43 +02:00
Lars Karlitski
2d487fe685 osbuild.py: add systemResourcesFromEtc key
Some programs have resources in /etc (for example, /etc/pki or grub's
config scripts). Give stages a way to access these.
2019-06-14 20:29:14 +02:00
Lars Karlitski
bd87038210 osbuild.py: separate tree from build root
There's no reason to conflate the two. This allows us to build on
something other than a tmpfs.
2019-06-14 19:54:42 +02:00
Lars Karlitski
ce0b01e93d osbuild: remove --sit
It's not really useful because it's at the wrong place, after a stage
has torn down all mounts. It also makes the code more complex for too
little benefit.
2019-06-14 18:38:13 +02:00
Lars Karlitski
2dbd177b0f osbuild.py: add BuildRoot.run_assembler()
This is the canonical way to run an assembler.

Also improve error handling by introducing a StageFailed exception.
2019-06-13 21:07:23 +02:00
Lars Karlitski
b36c8135ae osbuild: split BuildRoot into a reusable module 2019-06-13 20:01:53 +02:00
Lars Karlitski
abca9d7b03 osbuild: mount build root and tree in /run/osbuild 2019-06-13 19:30:57 +02:00
Lars Karlitski
e7b8f757d4 osbuid: introduce libdir
Run stages and the runner from a libdir, which is either $prefix/lib or
the current directory.
2019-06-13 19:30:19 +02:00
Lars Karlitski
48f8a7fc2a osbuild: pass arguments to main() explicitly 2019-06-13 16:16:33 +02:00
Lars Karlitski
0178cce4ee osbuild: make --input and --output absolute paths 2019-06-13 16:04:42 +02:00
Lars Karlitski
9703b975c3 osbuild: be more quiet
Don't print systemd-nspawn's messages about starting and stopping
containers.

Also supress a ldconfig warning and only show output from
systemd-sysusers when it fails.
2019-06-13 13:35:45 +02:00
Lars Karlitski
170eadde04 osbuild: add "assembler"
An assembler is a stage that may have outputs. It is the only stage
that gets the output_dir argument passed (and not input_dir).
2019-06-13 10:04:46 +02:00
Lars Karlitski
88c1f7be3b osbuild: add BuildRoot.run_stage() 2019-06-12 20:53:38 +02:00
Lars Karlitski
3cca6ccb8a osbuild: factor running systemd-nspawn out of the main loop
Also rename BuildContainer to BuildRoot. It's not a container.
2019-06-12 20:33:00 +02:00
Lars Karlitski
da121beda1 osbuild: factor out BuildContainer
As start of a public API for osbuild.
2019-06-12 19:40:59 +02:00
Tom Gundersen
34de8e0274 osbuild: always pass an input_dir argument
All stages must be able to handle an input_dir argument, as we now
either pass it to all or none for agiven run. Simply set it to
'None' if it is not provided.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-12 18:54:31 +02:00
Lars Karlitski
2462f0d6e1 osbuild: output stage stdout/stderr again 2019-06-12 18:24:41 +02:00
Lars Karlitski
6ad3a3b039 osbuild: work around systemd-nspawn "cleaning" the hostname 2019-06-12 18:15:02 +02:00
Lars Karlitski
72f10e184c osbuild: pass input directory to all stages 2019-06-12 17:12:30 +02:00
Tom Gundersen
40cf349f18 osbuild: replace --from and --save with --input and --output
The new arguments are passed to the first, respectively last, stage
and are both directories. --input is read only and can be used to
initialize the first stage. --output is r/w and is where the final
stage should place the produced image.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-12 16:26:29 +02:00
Lars Karlitski
01aa00837f osbuild: drop state
Stages should be as stateless as possible. Don't provide an easy way out
of that.

Only the dnf stage used stage to save the dnf cache. That's only useful
during development and can be solved by pointing to a local repo mirror.
2019-06-12 15:23:45 +02:00
Lars Karlitski
7a866aa1c3 osbuild: don't show log output on the terminal
The output makes it hard to see which stage is currently processed and
how to enter the build container. Also, it doesn't include all relevant
logs.

Instead, stream log output into /tmp/output in the build container. Keep
outputting it to stdout, so that osbuild can collect it in the future.
2019-06-12 12:47:04 +02:00
Lars Karlitski
ba2a194d5d osbuild: add --sit
Passing --sit keeps the build environment up for inspection when a stage
failed.
2019-06-07 21:46:23 +02:00
Lars Karlitski
5e7a111120 osbuild: run further setup in build environment
Introduce `run-stage` script, which sets up the build environment before
running the stage. Run `ldconfig`, `systemd-sysusers`, and
`systemd-tmpfiles` in it.
2019-06-07 21:33:31 +02:00
Tom Gundersen
256bb718ee osbuild: print the nsenter command needed to get a shell in the container
This is useful for debugging, and would be as a very lightweight ssh
session, but one that only insepcts the environment without hooking
into anything.
2019-06-07 17:19:44 +02:00
Tom Gundersen
61f83b3f46 osbuild: run stages as PID2 instead of PID1
nspawn can provide a minimal PID1 implementation, avoiding stages to
themselves do things like reap zobies etc. Use that.
2019-06-07 17:00:24 +02:00
Lars Karlitski
5f59cc0cb4 osbuild: only use /usr from the host
Use systemd-nspawn's "volatile" mode, which creates a tmpfs for the root
directory. This ensures that we're not accidentally using configuration
from the host.

The only remaining hole is `/etc/pki`.

Anaconda cannot run without its configuation in `/etc`. Recreate the
defaults.
2019-06-07 13:14:21 +02:00
Tom Gundersen
13cb397eca osbuild: use systemd-nspawn
Rather than using unshare, we use nspawn as it gives us more isolation
for free. We are not sure if we will end up with this in the end, but
for the time being let's see how well it works for us.

We have to do a work-around as nspawn refuses to spawn with the current
root as the directory, even in read-only mode, so we bindmount it first
and use the bindmount, in order to trick nspawn.
2019-06-06 19:37:49 +02:00
Tom Gundersen
cdcfa1277e osbuild: make state handling generic
Rather than treating the dnf-cache specially, give each stage its
own state directory that they can reuse. This should obviously be
used with care by the stages in order to make the builds
reproducible.
2019-06-06 19:37:49 +02:00
Tom Gundersen
d557784c8c osbuild: do not set up API VFS in the target tree
Some stages will be chrooting into the target to run things there,
and they will require the standard API VFS to be mounted. Some
tools do that themselves, other do not. In all cases, we would like
to discourage running things in the target tree.

For these reasons do not pre-mount the API VFS, but require the
stages who need it to do the mounting themselves. This is a partial
revert of f6023ed78b.
2019-06-06 16:52:03 +02:00
Tom Gundersen
78c8a176c9 mount /run in the target
Like the other API VFS, we need our own /run instance.
2019-06-05 20:41:34 +02:00
Lars Karlitski
f6023ed78b Bind-mount vfs directories for each stage
Many of the stages need it anyway.
2019-05-06 00:23:56 +02:00
Lars Karlitski
790a184aef Add --from and --save options
These options allow initializing and saving the tree to a .tar.gz before
running the pipeline.
2019-04-09 12:16:55 +02:00
Lars Karlitski
ae1afef209 osbuild 2019-04-08 13:03:13 +02:00