Commit Graph

32 Commits

Author SHA1 Message Date
Marcus Schäfer
a7b984115d
Fixed delta_root build
The support for delta_root allows to build a delta container
image from a given base container. Due to the refactoring of
the kiwi code base using context managers no explicit deletion
of instances happens anymore. This uncovered a weakness of
the delta root code at the level of the overlay mount. At
the time of the umount there are still active temporary
mount handlers which keeps the mountpoint busy. In order to
fix this properly also the PackageManager factory is now
a context manager and the Repository factory received a
cleanup method which is called when the PackageManager goes
out of scope. This refactoring also fixes the busy state
when building deltas
2024-03-07 15:50:58 +01:00
Marcus Schäfer
f158e22ae3
Move SystemPrepare to context manager
Change the SystemPrepare class to context manager.
All code using SystemPrepare was updated to the following
with statement:

    with SystemPrepare(...) as system_prepare:
        system_prepare.some_member()

This completes the refactoring from finalizers to
context managers and Fixes #2412
2024-02-27 15:43:06 +01:00
Alexandre Detiste
fb69627ad3
Use unittest.mock from core python everywhere
mock was an independent module that has been merged into the Python standard library.
2024-02-18 22:15:30 +01:00
Marcus Schäfer
ca334c1962
Remove obsolete destructor from BootImageDracut
With MountManager as context manager the BootImageDracut
class doesn't need a destructor anymore. This is
related to Issue #2412
2024-02-05 15:00:09 +01:00
David Cassany
ab4abf97da
Use rsync defaults to sync the initrd root-tree
This commits makes use of rsync default options to sync
the root-tree of the boot image for custom initrds.

Fixes bsc#1207128 where it was noted hardlinks
were not preserved inside the initrd.

Signed-off-by: David Cassany <dcassany@suse.com>
2023-01-18 08:05:55 +01:00
Marcus Schäfer
a344c540dc
Increase scope of kernel lookup
So far kiwi was looking up kernels only on /boot. Including
other bootloaders it's no longer required that the kernel
packages of the distributions provides the kernel in /boot
Thus kiwi's lookup needs to be extended to other places
which is done by this commit.
2022-11-15 09:04:57 +01:00
Marcus Schäfer
fe478de901
Added API for BLS and systemd-boot support
Bootloaders implementing the Boot Loader Spec (BLS) are not
directly compatible with the original Bootloader Class design
in kiwi. Because of that an interface class which translates
the original API into calls following BLS was added. This allows
us to keep the implementations in the Builder classes and the
public BootLoader interface untouched. In addition to the BLS
API an implementation to support the systemd-boot loader is
part of this commit too.

An example type definition to use systemd-boot with an EFI
disk image type looks like the following:

    <type image="oem" filesystem="xfs" firmware="efi" bootloader="systemd_boot" efipartsize="200"/>

The implementation uses bootctl and kernel-install tools
provided from systemd and expects a proper integration
of systemd-boot by the distribution maintainers

This Fixes #1935
2022-11-12 17:39:22 +01:00
Marcus Schäfer
92273ee651
Fix helper method to detect dracut outfile format
The method _get_boot_image_output_file_format_from_dracut_code
is used in kiwi to match parts of the dracut code for the used
output file format. Beginning with dracut-056 the code part
checked has changed syntactically such that the match did
no longer work. This commit increases the scope of the match
and replace pattern and Fixes #2149
2022-06-08 23:12:43 +02:00
Marcus Schäfer
9c9250ebc4
Support nose and xunit style tests
The modifications in this commit allows the unit tests
to run on both, pytest 6.x (nose test layout) and the new
pytest 7.x (xunit test layout). This Fixes #2072 in a
much nicer way. Thanks much to @smarlowucf
2022-02-26 20:26:18 +01:00
Marcus Schäfer
1f869e7ca8
Revert "Unit test adaptions to pytest v7"
This reverts commit 0dc2e803e0.
The pytest interface from version v6 to v7 has received
changes which requires the tests to be adapted to work for
either the old or the new interface. As there are still many
distributions which uses v6 as the standard we decided to
revert back the adaptions done to support v7 and create
a version requirement to v6 in .virtualenv.dev-requirements.txt
This Fixes #2072
2022-02-26 20:19:42 +01:00
Marcus Schäfer
0dc2e803e0
Fixed unit tests
The pytest interface setup() method call has changed
in a way that an additional parameter is passed to
the method which leads to a python error at invocation
time if the setup method does not define it.
2022-02-07 21:27:39 +01:00
Marcus Schäfer
6a53c6a606
Fixed image builds without kernel
If an image is build without a kernel kiwi fails due to
some code paths expecting the presence of kernel modules
and or kernel binaries. This commit fixes this and allows
creating an image without installing a kernel.
2022-01-14 20:08:17 +01:00
Marcus Schäfer
282529de8f
Do not force dracut into a compression setting
So far we called dracut with --xz which forces the initrd
to be xz compressed. There are other compression formats
used by the distributions and they might differe from xz.
The selection for a compression tool is done by a dist
configuration in dracut.conf.d which is provided by the
distributions as they see fit. For us this means not
forcing dracut into a specific compression setting allows
to make use of the distro provided setting and also
allows to change/override this setting by an overlay
file. This Fixes bsc#1192975
2021-11-24 12:15:47 +01:00
Marcus Schäfer
fc2446dfea
Moving temp data handling to its own namespace
Moving use of mkdtemp, NamedTemporaryFile and TemporaryDirectory
into its own class called Temporary: By default all temporary
data is created below /var/tmp but can be changed via the
global commandline option --temp-dir. This Fixes #1870
2021-07-22 13:31:44 +02:00
Marcus Schäfer
7d65259a92
Mount dev and proc filesystems prior dracut
In newer versions of dracut /dev and /proc must be mounted
for dracut to work correctly. If not present the resulting
initrd is incomplete. This Fixes #1867
2021-06-29 12:54:58 +02:00
Marcus Schäfer
8794d4a7cb
Fixed cleanup of temporary directory
In the custom kiwi initrd build process a temporary directory
holding a copy of the initrd root tree is created. That data
got never cleaned up. This commit uses a TemporaryDirectory
object from the tempfile module to make sure it gets deleted
once the execution scope is done. This Fixes #1837
2021-06-10 11:10:56 +02:00
Marcus Schäfer
08388f2215
Fixed building with custom kiwi initrd setup
The change from allowing to build with initrd_system="none"
broke the build for initrd_system="kiwi". This commit fixes
the regression
2021-06-05 21:01:21 +02:00
Marcus Schäfer
49479af059
Add strong typing for the following API methods
kiwi/boot/image/base.py
kiwi/boot/image/builtin_kiwi.py
kiwi/boot/image/dracut.py

This references issue #1644
2021-05-28 14:36:53 +02:00
Marcus Schäfer
8ede3ee0b6
Added support for skipping initrd creation
Embedded systems and other customer use cases sometimes
doesn't require an initrd. So far the initrd creation was
a mandatory step in the process. With this commit it's
possible to configure <type ... initrd_system="none"/>
and therefore skip the creation and setup of an initrd.
Using this feature comes with a price. Without an initrd
the task of mounting the specified root=DEVICE_SPEC now
becomes a task of the kernel. If the kernel doesn't have
the required filesystem driver compiled in or the mount
process of the device is not just a simple mount
action, the boot of such an appliance will fail
2021-05-27 16:07:55 +02:00
Marcus Schäfer
614b5fbc57
Fixed setup of repository architecture
Unfortunately the architecture reported by uname is not
necessarily the same name as used in the repository metadata.
Therefore it was not a good idea to set the architecture
and manage the name via a mapping table. It also has turned
out that repo arch names are distro specific which causes
more complexity on an eventual mapping table. In the end
this commit changes the way how the repository architecture
is setup in a way that we only set the architecture if
a name was explicitly specified such that the user keeps
full control over it without any mapping magic included
This Fixes bsc#1185287
2021-05-12 15:25:17 +02:00
David Cassany
2e3f2daeba
Refactor disk and install builders and dracut boot image
This commit mainly refactors the DiskBuilder class. Then install builder
and dracut boot image refactors are mostly to drop no longer needed
code. The refactors tries to make the build simpler and easier to read and
also prevent the reuse of the BootImage instance used for the main image
when creating the installation media (this aplies only for
dracut based images).

Fixes #873
2021-05-03 14:08:46 +02:00
Marcus Schäfer
ce9b1ccc08
Added option to set the image target architecture
The option --target-arch allows to set the architecture
used to build the image. By default this is the host
architecture. Please note, if the specified architecture
name does not match the host architecture and is therefore
requesting a cross architecture image build, it's important
to understand that for this process to work a preparatory
step to support the image architecture and binary format
on the building host is required and is not considered a
responsibility of kiwi. There will be a followup effort
on providing a plugin for kiwi which should be used to
manage the needed binfmt settings for cross arch image
builds
2021-04-14 12:53:28 +02:00
David Cassany
6366624ef1
Add the installinitrd element
This commit adds the `<installinitrd>` element in kiwi schema to
facilitate the dracut modules configuration for the installation initrds
on OEM images. Within installinitrd element is possible list the dracut
modules to append, to omit or to just set an static list of dracut
modules to include.

Fixes #1676
Fixes #1683
2021-01-21 16:33:43 +01:00
Marcus Schäfer
490a9db564
Use pragma: no cover to skip non reachable code
Instead of placing the file into .coveragerc use the
no cover pragma to skip code paths that can never be
reached from being counted in the coverage report.
This affects the abstract constructors in the Factory
classes
2020-09-29 09:58:22 +02:00
Marcus Schäfer
0b8abf1c7c
Refactor BootImage Factory
This commit refactors the BootImage factory to be a real
factory and to add type hints such that its use from an api
perspective is clear and enforced. Related to Issue #1498
2020-09-23 15:48:21 +02:00
Marcus Schäfer
8d2d9c214c
Make oem be a superset of vmx
A vmx image is the same disk as an oem just without the dracut
repart/resize feature. This difference is better handled with
an oemconfig parameter <oem-resize> which allows to switch resize
on or off. The extra image type vmx will be dropped and an XSLT
stylesheet automatically transforms a vmx description to be a
oem image with the resize feature switched off.
This Fixes #1425
2020-09-16 12:56:14 +02:00
Marcus Schäfer
c009e6a393
Fixed permissions of custom boot image root dir
When building a custom kiwi initrd the root directory
has the permissions of the mkdtemp created directory
but should have the permissions of a linux root dir
which is 0755. This Fixes #1394
2020-06-09 13:55:44 +02:00
Marcus Schäfer
c7ed1cfc29
Allow to access disk root after sync_data
In preparation to allow a chroot operation into the loop
mounted disk this commit refactors the process when filesystems
gets umounted and also fixes the canonical order for calling
the destructors. Related to Issue #1464
2020-06-02 12:52:49 +02:00
Marcus Schäfer
f1303396f9
Fixed dracut output file format detection
The current way to detect the dracut output file format was
based on a lookup of the format used in the dracut tool itself.
However there are distributions like Ubuntu which calls dracut
and passes the name of the initrd file as options to the call.
This invalidates the checking done by kiwi. The only chance
for kiwi to do the same than the distributions does is by
looking for an initrd file pre-created by the package
installations and use the same format. Only if no such initrd
file exists the former format detection code applies. The
additional code expects any initrd file to match the glob
pattern 'init*'. This Fixes #1450
2020-05-25 14:31:49 +02:00
Marcus Schäfer
94c7a7cdf6
Added new oem-resize-once element
The new element controls the behavior of the repart/resize code
in the oem-repart dracut module. By default the repart/resize
happens on every reboot and therefore also allows for disk
geometry changes during the livetime of the machine. If the
element is set to false the repart/resize operation happens
only once and then never again. To check for this condition
a new profile environment variable kiwi_rootpartuuid which
holds the PARTUUID of the root partition has been added to
the disk builder.
2020-03-27 10:37:42 +01:00
David Cassany
fc4a1616bc
Allow builds without KIWI dracut modules
This commit avoids requesting non installed dracut modules to the dracut
creation. It bumps a warning message if the module requested by KIWI is
not installed in the root-tree and ignores the request.

This allows the creation of images without including KIWI dracut modules
when the related runtime checks are disabled.

Fixes #1300
2020-01-15 11:08:19 +01:00
David Cassany
4b3a105026
Re-structure unit tests folders
This commit relocates unit tests to a folder structure that matches
the source code structure.

Fixes #1128
2019-10-21 14:00:05 +02:00