Commit graph

446 commits

Author SHA1 Message Date
Tom Gundersen
31f3533886 spec: use forgemeta
This changes the name of the source tarball, but apart from that has
no effect as-is.

However, if the `commit` global is set, then the source tarball is
expected to be the standard git-archive at that commit, and the
release field is set to contain the date and the git sha. This is
useful for when we want to build rpms between releases.

This works analogously to how osbulid-composer currently works.

See <https://fedoraproject.org/wiki/Forge-hosted_projects_packaging_automation>
for details.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-24 12:17:54 +01:00
Ondřej Budai
bd6e6bde56 ci: run the rpm build tests in Fedora containers
Building rpm directly on Ubuntu is somewhat possible but it's fragile and
it cannot cover all quirks of rpm build. This commit switches the rpm build
tests to using fedora containers. This isn't also the best solution but
imho it's much better than the previous one.
2020-02-22 10:31:44 +01:00
Major Hayden
ddb652ecc7 dnf: enable fastestmirror by default
Enabling the fastestmirror plugin allows dnf to choose the fastest
(also usually the closest) mirror to the instance of osbuild. It
has no effect on builds that force the use of a specific server
or mirror.

Signed-off-by: Major Hayden <major@redhat.com>
2020-02-22 02:01:17 +01:00
Tom Gundersen
e48c2f178c osbuild: allow the sources to be passed in on stdin
Currently stdin is taken to be the pipeline to be built, this allows
it to be instead a map containing the suorces and the pipeline.
We would imagine passing around the sources and pipeline together, so
this just makes the behavior of osbuild more closely match the intended
use and semantics of the sources configuration.

This keeps backwards compatibility for now, but that may be dropped as
soon as osbuild-composer no longer relies on the old behavior.

Disable too-many-{branches,statements} pylint warnings in __main__.py.
These do not seem helpful, but could be reenabled if we drop some
options in the future.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-19 15:59:11 +01:00
Tom Gundersen
481213a8dd pipeline: pin the sources options in the pipeline object
Make the sources options a static property of the pipeline, in
particular of each stage, rather than being passed in on `run()`.

This more closely matches the intended semantics of sources and
pipeline having similar lifetimes and being fairly coupled together.

The difference between the pipeline and the sources is that the
sources do not contribute to identifying the pipeline (they are not
part of the hash for the pipeline id), and they could be swapped
out without changing the output image (as long as they are valid).
However, a pipeline without A sources object would not be useful,
and typically the pipeline and the sources are generated, passed
around and used together.

This is different from the build environment and the secrets object,
which both are specific to either the host or the caller, unlike
the pipeline which should be universal.

This changes the `load()` function to take a `manifest`, which is
a map containing both the pipeline and the sources.

Note that the semantics of the build-env parameter remains unchanged:
It shares the sources with the rest of the pipeline. We may want to
reconsider this in future commits, as the build-env is specific to
the host, whereas the regular pipeline is not.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-19 15:59:11 +01:00
Major Hayden
961322d959 Remove unused GitLab CI configuration
We're not using the GitLab CI integration yet and we will need to
rethink how to implement it anyway.

Signed-off-by: Major Hayden <major@redhat.com>
2020-02-19 15:12:52 +01:00
Tom Gundersen
be663bd3d5 stages/rpm: be a bit more verbose to give some progress indication
The dnf stage was very verbose, probably overly so. Rather than
benig completely silent, let's print basic progress indication
so we have some idea what's going on.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-06 19:01:12 +01:00
Tom Gundersen
16dfd7eec1 remoteloop: drop O_DIRECT
Appart from giving us a hard time on s390x, this feature did not seem
to have a measurable effect. Moreover, O_DIRECT is not supported by
tmpfs so without this patch we could not use tmpfs as backing store,
which does speed up image generation considerably.

Drop the flag and and rather put the store on tmpfs in order to speed
things up.
2020-02-06 19:01:12 +01:00
Tom Gundersen
1d588b8e86 stages/rpm: adapt to use the files source
Drop the rpm downloading and instead use the files source. This gives
us caching for free, and is the last missing step before we can
deprecate the dnf stage.

The main benefit of the rpm over the dnf stage is that we pin the package
versions rather than the repo metadata version. This will allow us to
support continuously changing repositories as individual packages are much
less likely to change than the repos iteself, and old packages are meant
to stay around for some time, unlike the repo metadata which is instantly
swapped out.

Depsolving is also slow on the first run, which we were always hitting as
the depsolving was always happening in a fresh container.

Based on a patch by Lars Karlitski.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-06 19:01:12 +01:00
Tom Gundersen
be0ff68411 fixup: files 2020-02-06 19:01:12 +01:00
Tom Gundersen
7817ae5e8b sources: add org.osbuild.files source
This source adds support for downloaded files. The files are
indexed by their content hash, and the only option is their URL.

The main usecase for this will be downloading rpms. Allowing depsolving
to be done outside of osbuild, network access to be restricted and
downloaded rpms to be reused between runs.

Each source is now passed two additional arguments, a cache directory
and an output directory. Both are in the source's namespace, and
the source is responsible for managing them. Each directory may
contain contents from previous runs, but neither is ever guaranteed
to do so.

Downloaded contents may be saved to the cache and resued between
runs, and the requested content should be written to the output dir.
If secrets are used, the source must only ever write contents to
the output that corresponds to the available secrets (rather than
contents from the cache from previous runs).

Each stage is passed an additional argument, a sources directory.
The directory is read-only, and contains a subdirectory named after
each used source, which will contain the requseted contents when
the `Get()` call returns (if the source uses this functionality).

Based on a patch by Lars Karlitski.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-06 19:01:12 +01:00
Tom Gundersen
794ec97bf3 api: add barriers
Ensure that the api sockets are created before entering the with clause.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-06 19:01:12 +01:00
Christian Kellner
5a61d8c869 objectstore: extract method to open a TreeObject
Extract the opening a TreeObject out of the treesum property so
that the latter is easier to read.
2020-02-06 16:10:35 +01:00
Christian Kellner
6f4d286ff4 osbuild: support for checkpoints during build
Add a new `--checkpoint` option, which can be provided multiple
times, that indicate after which stages a the current stage of
the tree should be committed to the object store; the tree id
will be the treesum of the tree at that point and a reference
is created with the id of the stage at the point.
The argument to `--checkpoint` is the id of the stage. If not
all the given checkpoints can be found the execution will be
aborted.
2020-02-06 16:10:35 +01:00
Christian Kellner
8d98696f47 tests: check duplicate objects are supported
Check that creating two trees with the exact same content, i.e.
exact same treesum only lead to exactly one object and two
references.
2020-02-06 16:10:35 +01:00
Christian Kellner
4fe69b756f tests: check basic properties of objectstore
Check the very basic operations of the object store, i.e. creating
multiple trees with different object_ids works and results in the
correct number of objects and references.
2020-02-06 16:10:35 +01:00
Christian Kellner
1cf0e944c9 tests: new object store unit test
Basic functional checks, including the new snapshot support.
2020-02-06 16:10:35 +01:00
Christian Kellner
ce5719a03f objectstore: move tree-moving code into the tree
The code to move the a TreeObject more naturally belongs to the
TreeObject itself and makes the ObjectStore.commit() method even
easier to read.
2020-02-06 16:10:35 +01:00
Christian Kellner
b5b5e7be29 objectstore: also ignore EEXIST when committing
When the tree is committed to the objects directory of the object-
store, it is done via rename(3). The two possible errors that can
be raised in case that a non-empty tree with the same name already
exist is [EEXIST] or [ENOTEMPTY]. The latter was already ignored
but the former was not. At least on btrfs former will be raised

  File "/home/gicmo/Code/src/osbuild/osbuild/objectstore.py",
    os.rename(tree.root, output_tree)
  FileExistsError: [Errno 17] File exists: 'store/tmpyyi3yvie/tree' -> 'store/objects/…'
2020-02-06 16:10:35 +01:00
Christian Kellner
3a40d31bee objectstore: introduce tree snapshot support
Add a new method to the ObjectStore that takes a path to a file
system tree, which is currently being built, and commits it to
the store and references it via a given object_id.
The tree is copied to a temporary location (co-located in the
store to enable fast copying via reflinks) and then atomically
moved into the ObjectStore's objects path via rename(3).
2020-02-06 16:10:35 +01:00
Christian Kellner
db8618f192 objectstore: extract logic to commit a tree
Extract the code from ObjectStore.new that will commit the filled
tree to the store into its own method so it can be used from a
future method to snapshot trees at random points in time.
2020-02-06 16:10:35 +01:00
Christian Kellner
4831927e84 objectstore: introduce TreeObject
Introduce a small `TreeObject` class that is the representation of
a tree during its construction. It supports calculating its treesum
as well initialize the new tree with an existing one.
2020-02-06 16:10:35 +01:00
Christian Kellner
e3956ac831 gitignore: ignore IDE files
Ignore files related VS Code, PyCharm and gdb.
2020-02-05 15:53:34 +01:00
Christian Kellner
4cbbcdba87 samples: fix types for fstab.{freq, passno}
The schema demands that these are of type integer not string.
2020-01-29 18:03:24 +01:00
Christian Kellner
beb24a38b0 assembler/qemu: schema: 'dos' option for 'pttype'
Reflect the actual code by allowing 'dos' as pttype, which is as an
alias for 'mbr'.
2020-01-29 18:03:24 +01:00
Christian Kellner
ed8b71da36 assembler/qemu: fix 'size' schema type
It is an integer not a string.
2020-01-29 18:03:24 +01:00
Christian Kellner
2a3e5107f4 assembler/rawfs: fix schema type for 'size'
It is supposed to be an integer not a string.
2020-01-29 18:03:24 +01:00
Christian Kellner
4f72036efa stages/grub2: fix schema entry for 'legacy'
The 'legacy' option can either be of type boolean (the old version
kept for compatibility reasons) or 'string'. Adjust the schema to
account for that.
2020-01-29 18:03:24 +01:00
Christian Kellner
56a8586bab test: verify all stage options are valid json
Load all stages and assemblers and verify that the json in
STAGE_OPTS is actually valid json.
2020-01-28 13:10:14 +01:00
Christian Kellner
a3b9b55682 stages/grub2: fix json for stage options
Extra data: line 49 column 1 (char 1350) caused by an extra "}" at
the end of the data.
2020-01-28 13:10:14 +01:00
Christian Kellner
c084d51e3e stages/error: fix json for stage options
Expecting ',' delimiter: line 5 column 5 (char 88) caused by a
missing ','.
2020-01-28 13:10:14 +01:00
Christian Kellner
b261cb071e stages/dnf: fix json for stage options
Expecting property name enclosed in double quotes: line 81
column 1 (char 2272), caused by a trailing ",".
2020-01-28 13:10:14 +01:00
Tom Gundersen
ee86b57392 pipeline: back var by the store
This makes sure all disk access is backed by the same disk. We may
want this for performance reasons (avoiding moving across disks), but
also to experiment with different backing stores for all disk access.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-01-27 15:51:47 +01:00
Tom Gundersen
2837604bf8 buildroot: allow customizing the backing store for /var
Currently /var was always backed by /var/tmp, but we may want to
control exactly what it is backed by. The default is the same, so
this is not a behavioral change.
2020-01-27 15:51:47 +01:00
Major Hayden
2691acefeb Add the first gitlab ci YAML
This is the first test of connecting gitlab CI to the github
repository.

Signed-off-by: Major Hayden <major@redhat.com>
2020-01-24 00:41:12 +01:00
Christian Kellner
cf9c9946e0 pipeline: bind mount the osbuild module for the stages
The dnf stage wants to import `osbuild.sources` but currently the
osbuild module is not available in the stages. Apply the same hack
done in the Assembler also in for the stages, i.e. bind mount the
osbuild module to the stages/osbuild.
2020-01-23 00:49:11 +01:00
Christian Kellner
e7b989a08d osbuild.spec: actually install runners symlinks
The Fedora 31 and Fedora 32 runners are symlinks but the spec file
only looked for files and not symlinks. Fix that.

Follow up by 6a14ba40f7. Found by
Lars.
2020-01-23 00:47:57 +01:00
Christian Kellner
eab3414f00 samples: add hybrid boot with extra boot partition
Add a new sample that supports hybrid boot, i.e. legacy boot and
UEFI, like f30-hybrid-qcow2, but with a separate boot partition.
The latter means that 'fix-bls' as well as the 'grub2' stage need
to be adapted for it: 'fix-bls' needs have the prefix set to "/"
and grub2 needs to have a 'boot_fs_uuid' option pointing to the
uuid of the filesystem for the boot partition.
2020-01-19 23:01:36 +01:00
Christian Kellner
eb71e3d85c assembler/qemu: grub prefix relative to mountpoint
The grub prefix ("/boot/grub2") should be defined as relative to the
mountpoint of the filesystem containing it, i.e. /boot/grub2 if it is
on the root filesystem or /grub2 if boot is on a separate partition.
2020-01-19 23:01:36 +01:00
Christian Kellner
abfc4d6b5a stages/fix-bls: support for different prefix
The paths for the kernel and the initrd in the BLS snippets are
meant to be relative to the root of the filesystem they are on.
The current code assumes that kernel and initrd are installed
under '/boot' and that '/boot' is on the root file system and
thus all paths get fixed up to start with '/boot/…'. But the
'/boot' directory can be on a separate partition and thus file
system, and then paths need to be relative to that and should
be fixed up with '/…'. Introduce a new option 'prefix' that
can be used to manually specify the prefix after the fixup,
defaulting to '/boot' for backwards compatibility.
NB: The canonical Boot Loader Specification[1] requires that
a separate partition is used boot related files and it will
be mounted at '/boot' (or '/efi').

[1] https://systemd.io/BOOT_LOADER_SPECIFICATION/
2020-01-19 23:01:36 +01:00
Christian Kellner
b3ae34b07e stages/grub2: make $boot just an alias for $root
Up until now the grub config theoretically supported having different
values for 'root' (via grubenv's $GRUB2_ROOT_FS_UUID) and 'boot' (via
grubenv's $GRUB2_BOOT_FS_UUID). 'boot' is a leftover from the initial
implementation when grub was looking for BLS snippets also in the ESP,
and will be removed in the future.
In our and also the canonical Fedora/RHEL grub configurations the BLS
are in the very same location for UEFI and legacy and thus 'boot' is
always 'root'.
Therefore we get rid of the extra grubenv variable refering to 'boot'
and just set 'boot' to 'root' after that was discovered.
2020-01-19 23:01:36 +01:00
Christian Kellner
92e2961090 stages/grub2: support for separate boot partition
Add a new `boot_fs_uuid` option for when a separate partition is
being used for '/boot' with the indicated uuid. This will then be
used for the grub2 "root" and "boot" variables. Additionally, in
the redirect config, need to refer to files and directories paths
relative to the partition they are contained, i.e. /boot/grub2 if
/boot is on root ('/') or /grub2 if /boot is on a extra dedicated
partition.
2020-01-19 23:01:36 +01:00
Lars Karlitski
7bb06d2334 loop: handle set_status returning EBUSY
This happens rarely when the same loop device is used in rapid
succession. The kernel flushes the page cache asynchronously, which
means that it might not be cleared yet when a new file is bound.
`set_status` checks if the cache is clear (`set_fd` doesn't).

Handle this by trying a different device when `set_status` returns
`EBUSY`.

Fixes #177
2020-01-19 22:19:25 +01:00
Lars Karlitski
b487126bb8 loop: explicitly close fds to loop devices
Don't wait until python's garbage collector closes the file descriptors
to loop devices. Close them when the `LoopServer` context manager exits,
after an assembler has finished running.
2020-01-19 22:19:25 +01:00
Lars Karlitski
47dc1b5b92 loop: don't leak open fd to /dev
Close the file descriptor to `/dev` when we opened it.
2020-01-19 22:19:25 +01:00
Lars Karlitski
977f0a465b loop: fix typo in LoopInfo member 2020-01-19 22:19:25 +01:00
Christian Kellner
2d6fa9564c samples/f30-s390x: use new stlye sources for dnf
Instead of directly encoding the repo configuration make use of the
new sources api. The corresponding entry in samples/sources.json
which is referenced here ("sha256:450d4c0…") was added with the
previous commit ("92cfc57d720…").

    "it's the future! 🛸" - Lars Karlitski
2020-01-13 20:05:10 +01:00
Christian Kellner
8d7cd7c871 samples/sources: add f30 on s390x dnf repo
Add the repo source for the org.osbuild.dnf stage for fedora 30 on
s390x.
2020-01-13 20:05:10 +01:00
Christian Kellner
d53787be66 samples/f30-s390x.json: example for s390x
Bare bones example for image creation on s390x with MBR partition
layout and zipl bootloader. The kernel command line is configured
via the new org.osbuild.kernel-cmdline stage which needs to be run
before the dnf stage.
2020-01-13 20:05:10 +01:00
Christian Kellner
49e1b91d47 assembler/qemu: support for zipl bootloader
Support the s390x bootloader zipl (z Initial Program Loader). We
supply the parameters for the kernel+initrd as well es the target,
i.e. the boot partition where the bootmap is creating, the device,
here called 'targetbase', to install the bootloader on, including
parameters describing the device (type, blocksize) and also the
offset of the partition containing the target from the start of
device (in sectors).
The kernel and initrd are found via the bootloader entry, ignoring
the rescue kernel.
Since zipl needs the device as well as access to the boot partition
the image is bound to a loopback device. Also keep the filesystem
tree mounted during the execution of the zipl installation.
2020-01-13 20:05:10 +01:00