Commit graph

63 commits

Author SHA1 Message Date
Lars Karlitski
93da5caa69 stages/dnf: add mandatory basearch argument
We've been effectively using the basearch of the host, making the stage
non-reproducible: if the same pipeline was run on machines with
different architectures, it would produce different results. However,
pipelines producing different outputs must be different. Thus, this
patch includes the basearch in the pipeline.

In principle, this allows cross-arch builds. dnf should be the only
stage running binaries from the target tree. This is not yet tested.
2019-09-24 20:17:04 +02:00
Lars Karlitski
cd59b94ded tree-wide: always explicitly pass check to subprocess.run
pylint recently started recommending this.
2019-09-24 20:17:04 +02:00
Martin Sehnoutka
27bbb02265 make firewall options optional
there is no need to require all arguments in the firewall stage, so
let's reflect this in the code
2019-09-10 15:40:13 +02:00
Ondřej Budai
7fabcfe333 stages/locale: Refactor locale stage to look like similar ones
The locale stage now cannot be used to set the keymap. Use the keymap
stage instead. Also, the stage was refactored to look like keymap and
timezone stages just to be consistent (systemd-firstboot is now used).
2019-09-10 09:22:26 +02:00
Ondřej Budai
57bdfef754 stages/ansible: Drop the ansible stage
We use chroot connection type to "connect" to the target filesystem
where ansible should run the playbook. However, the target is not booted
system, it's just an image of not-yet-booted one. Unfortunately, many
ansible modules cannot be used inside not-booted system. Also, the core
principle of osbuild is to never boot the currently built image.
Therefore we decided to remove the ansible stage.

If ansible is needed in the future, there is a possibility to add a new
ansible stage, which would run the playbook during the first boot.
2019-09-09 09:11:52 +02:00
Tom Gundersen
fc838a8e20 stages: add test stage
Adds a new systemd unit to the image that will be pulled in by default,
run a given command, forward the output to a virtio serial port and
shutdown the machine.

We add a sample that uses this to verify that systemd conciders the
machine successfully booted. A simple way to run this test from the
commandline is to use
  `$ socat UNIX-LISTEN:qemu.sock -`
to listen for either `running` for success or `degraded` or
`maintenance` for failure.

The image should then be booted using something like
  `$ qemu-kvm -m 1024 -nographic -monitor none -serial none -chardev socket,path=qemu.sock,id=char0 -device virtio-serial -device virtserialport,chardev=char0,id=test0 -snapshot  base.qcow2`

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-29 10:25:15 +02:00
Tom Gundersen
a914627c89 stages: add debug shell
This gives shell access into the image on a given tty. Useful for
testing and debugging, while minimally affecting the image.

Note that this must never be used in production, as it allows root
access without a password.

For instance this could be used to verify that an image was fully
booted:

```
[teg@teg-x270 osbuild]$ qemu-kvm -m 1024 -nographic -serial mon:stdio -snapshot  base.qcow2
sh-5.0# systemctl is-system-running --wait
running
```

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-27 23:32:04 +03:00
Tom Gundersen
5854ceea42 stages/grub2: make booting in ro/rw mode configurable
Move the decision whether the root fs should be mounted ro or rw
into the pipeline configuration.

Update the pipelines accordingly.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
17d562e75f stages/fstab: add a stage to specify the fstab to be installed
This will allow us to boot in 'ro' mode, and remount later on.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
9af32f1aae stages/dnf: make install_weak_deps optional
Default to True, which is what dnf defaults to, but allow it to be
overridden in the pipeline. Whether this option should be used should
be a distro policy, but for now we just want it to get images compatible
with the official fedora ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
b348d858b8 stagse/dnf: don't make verbosity configurable
We don't want non-functional configuration in the pipelne, we want to
restrict ourselves to options that changes the final image.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Lars Karlitski
f54fbe2912 stages/fix-bls: add workaround for grub2-mkrelpath
grub2-mkrelpath uses /proc/self/mountinfo to find the source of the file
system it is installed to. This breaks in a container.

Add org.osbuild.fix-bls which goes through /boot/loader/entries and
fixes paths by removing anything before /boot.
2019-08-15 09:43:28 +03:00
Lars Karlitski
29c396584f stages/dnf: use nspawn's vfs tree
dracut stumbled over the one we set up (errors about not being able to
access /dev/kmsg). Use the one that systemd-nspawn sets up instead.
2019-08-14 13:49:27 +02:00
Martin Sehnoutka
c27cdd5928 introduce hostname stage
this stage will set /etc/hostname in the image. it uses
systemd-firstboot to perform the change
2019-08-13 13:24:36 +02:00
Lars Karlitski
4c91a23e98 stages/org.osbuild.users: manage users
This stage allows to add or modify users. For now, this includes all
fields available in passwd, setting auxiliary groups, and setting an ssh
key.

Based on a patch by Martin Sehnoutka <msehnout@redhat.com>.
2019-08-12 13:45:30 +02:00
Lars Karlitski
a394e975c1 stages/dnf: supress error from completion module
Disable the module. There's no need to update the completion databse in
the container.
2019-08-12 13:07:11 +02:00
msehnout
dc1466eeca
introduce firewall stage (#61)
as described in lorax documentation, we need to support raw
ports/protocols and services as defined by firewalld:
https://weldr.io/lorax/lorax-composer.html#customizations-firewall
2019-08-07 09:34:22 +02:00
Martin Sehnoutka
28e33c07ce introduce support for user-defined kernel options 2019-08-01 14:59:37 +02:00
Tom Gundersen
8b659ae638 travis: add a test for a yum-based pipeline
Travis uses Ubuntu, which does not ship dnf, so introduce a yum
stage that allows us to test actual generation of trees on Travis.

We use this to generate a tree containing the tools necessary to
create abritrary Fedora-based build images in the future. We base
this on Fedora 27, as that is the last version that is installable
using yum rather than dnf.

In the future, once we support pipelines with nested build-images,
rather than just using the host OS as the build image, this will
allow us to bootstrap arbitrary pipelines on Travis.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-31 01:34:31 +02:00
Martin Sehnoutka
0cf93934eb unify messages about files to be removed 2019-07-29 20:13:36 +02:00
Martin Sehnoutka
1ca4d8e6bb introduce keymap stage 2019-07-29 12:39:38 +02:00
Martin Sehnoutka
593c6de385 add timezone stage 2019-07-29 12:05:42 +02:00
Lars Karlitski
f4862457a3 rename io.weldr to org.osbuild (#39) 2019-07-26 09:40:55 +02:00
Tom Gundersen
a17ecd0fca stages/assemblers: symlink the osbulid python library
This way the assemblers/stages are valid in isolation, even without
osbulid installed system-wide. This would be needed to have this work
when --libdir is not the system-wide one, as the library would
otherwise not be in sys.path.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-25 21:28:23 +02:00
Martin Sehnoutka
f04cb3836f fix warnings generated by pylint 2019-07-17 13:08:22 +02:00
Tom Gundersen
a428572382 stages/io.weldr.grub2: drop unused functions and options
Since we no longer use grub2-mkconfig, but write static configuration
we can drop most of the helpers.

The partitin table id was never used in the first place. We use
filesystem UUIDs, not partition UUIDs to name our root/boot partitions.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-11 15:01:44 +02:00
Martin Sehnoutka
5ca90dc052 mount filesystems as rw
d-bus service was unable to start with the previous setup
2019-07-09 10:29:48 +02:00
Martin Sehnoutka
9ea6150ee7 introduce disabled services into the systemd stage 2019-07-09 10:29:48 +02:00
Lars Karlitski
34d620feea stages/dnf: don't use configparser to write dnf.conf
configparser writes strings with quotes and lists with enclosing
brackets, both of which may not appear in dnf.conf.

dnf.conf(5) defines the format loosely.
2019-07-08 14:22:25 +02:00
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
9f5ce324b0 stages/grub2: use static grub.cfg/grubenv files
Afetr discussions with Javier Martinez Canillas and Alberto Ruiz
from the grub team, it was clear that we want move to a static
configuration shipped in the grub rpm in the future. For now,
we use our own, but the aim is to use the same as upstream.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-02 20:05:19 +02:00
Tom Gundersen
037f439d01 stages/grub2: fix defaults/grub
This file was missing new-lines.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-01 22:18:05 +02:00
Tom Gundersen
ecaed3bbfa stages/grub2: don't set up a partition table
We only need the filesystem with the correct fs-UUID to chroot into,
there is no need to set up a whole partition table.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-27 16:22:30 +02:00
Tom Gundersen
779e5c40ea stages/grub2: set default entry
Without a default and/or timeout set, grub refuses to boot.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 13:46:19 +02:00
Tom Gundersen
d9488e5f8b losetup: make sure image sizes are multiples of 512K sectors
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 12:57:20 +02:00
Tom Gundersen
b540eb5ee7 losetup: create and attach images to loopback devices in one operation
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 12:45:35 +02:00
Tom Gundersen
63a4f795dc stages/selinux: add an selinux stage
This stage labels the target tree based on an SELinux policy already
installed in the target.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-21 13:36:49 +02:00
Tom Gundersen
a428ff05ad assemblers/qcow2: move from the old stage and make it work again
Minor ajustments needed after we changed the internal API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 19:49:53 +02:00
Tom Gundersen
4742ae1e72 stages/locale: fix typo
Add missing quotes around a string.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 18:49:21 +02:00
Tom Gundersen
a2441bf112 stages/dnf: allow both operation and verbosity to be configurable
This is for the sake of debuggability, but I figure dnf is the most
complex of our tools, so instrumenting that a bit makes sense.

The defaults are "install" and "info", as before.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 16:08:29 +02:00
Tom Gundersen
4b69d02dc8 stages/systemd: minor fixes
We cannot use the tool from within the tree unless we chroot
(library versions ay be wring etc). If possible we want to
always use tools from the build image, in order to avoid forcing
the contenst of the target tree, so do that instead.

Finally, add a missing include.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 23:54:23 +02:00
Tom Gundersen
b38506a702 stages/dnf: allow other operations on the provided packages than 'install'
We would like to avoid 'upgrading', but let's allow it in the tools.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 23:53:27 +02:00
Tom Gundersen
31a5eed4d9 stages: fix cp usage
We want to copy the contents of a directory to another, the correct
syntax for that is `cp -a src/. dst`. I was not aware of this beauty,
so the previous patch simulated the functionality in python code.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 09:48:35 +02:00
Tom Gundersen
f246ccf11e stages/assemblers: add tree/untree assembler and stage
In the simplest case we don't need to make an image, a filesystem tree
will do. Also support using such a tree as input for further pipelines
through the untree stage.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-17 17:44:04 +02:00
Tom Gundersen
6ae19579c1 stages/io.weldr.grub2: add a stage to generate grub2 configuration
The stage populates the tree with grub2 configuration. The API and
semantics is the way we want it, but internally this is a massive
hack.

GRUB2 is only able to run grub2-mkconfig on the image it wants to
configure. The reason is that it will inspect / and /boot to detect
the existing UUIDs and filesystems to use, despite this being
information we already know. In principle, the tool does support
passing this is, but due to several bugs that functionality does
not work.

We therefore create the image we want, copy over the tree, run
grub2-mkconfig in this image, then copy it back over the tree. The
end result is that the files /etc/defaults/grub,
/boot/grub2/grub.cfg and /boot/grub2/grubev are added to the tree.

The alternative would be to do what tools typically do, and just
run grub2-mkconfig on the final image at the time it is being
assembled. We want to avoid this in order to fully split filesystem
tree generation from image assembly. This way we can better control
and verify what ends up on the filesystem which should help with
reprobucibility and reuse of filesystem trees. Above all though,
we want to make sure that we can actually place some guarantees
on what each stage of the image building process actually does,
allowing us to argue about and change it without worrying about
arbitrary fallout.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-17 14:55:42 +02:00
Lars Karlitski
92f3af94f6 stage api: pass options in a separate key
This avoids name clashes between osbuild and stage options.
2019-06-16 12:07:27 +02:00
Lars Karlitski
c0769fc318 Add assemblers/ directory 2019-06-14 19:46:37 +02:00
Tom Gundersen
fc72b5cd03 stages/untargz: add a stage to populate a tree from a tar.gz
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-12 19:46:39 +02:00
Tom Gundersen
35917303c8 stages/targz: add a targz stage
This generates a tarball of the tree.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-12 18:55:49 +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