Commit Graph

1328 Commits

Author SHA1 Message Date
Marcus Schäfer
94de1336d8
Support custom partitions
In addition to the volume volume management settings also
allow to setup low level table entries like in the following
example:

<partitions>
    <partition name="var" size="100" mountpoint="/var" filesystem="ext3"/>
</partitions>
2021-11-03 13:31:17 +01:00
Marcus Schäfer
e892edf2f1 Make sure debootstrap is called only once
When building debian based images the bootstrap phase
is done by calling debootstrap. If kiwi is called on
an already existing root tree via --allow-existing-root
this will make debootstrap to fail in any case. This
is because for debootstrap it's an error condition if
there is already data in the root. However, for kiwi
and the explicitly requested re-use of the root tree
this is not an error. Thus this commit skips the
bootstrap by debootstrap and directly continues with
the image phase.
2021-10-27 12:58:22 -04:00
Marcus Schäfer
d32661888b
Add support for custom result bundle naming
Allow to specify a bundle_format per <type> which is used
at the time of the result bundle creation to create image
output names matching the provided pattern.
This Fixes #1943
2021-10-21 11:13:49 +02:00
Marcus Schäfer
c27308377c
Raise exception on umount issue
Up to now kiwi tried to umount a resource it has mounted for some
time and if it was not possible due to a busy state the process
continued. In any of these situations it was not possible to free
up the nested resources and it could also happen that the image
build result got corrupted because there is still data that can
be consumed but shouldn't be there anymore. The change here makes
kiwi to stop the process and raise with an error also including
the information that there are now resources still active but
busy on the host and a manual cleanup is unfortunately needed.
This Fixes #1914
2021-10-20 22:57:44 +02:00
Marcus Schäfer
0aa490c654
Fixed use of LUKS encrypted images with empty pass
For initial provisioning of LUKS encrypted disk images an
empty passphrase key is handy to avoid interaction in the
deployment process. However, the dracut kiwi modules were
lacking the information that the luks keyfile could be an
empty passphrase key which must not be opened with the
potential risk to get prompted for input. This commit
introduces a new profile environment variable evaluated
by the dracut kiwi lib code to open the LUKS pool and
allows to distinguish the situation on key files with
or without a passphrase
2021-10-14 11:27:16 +02:00
Marcus Schäfer
cded86afec
Add support for portable result data (#1949)
In addition to the serialized Result instance kiwi.result
file this commit also creates a portable version of this
information in kiwi.result.json. Only the information that
can be expressed as json document is part of the portable
version. This is related to Issue #1918
2021-10-12 18:31:49 -04:00
Marcus Schäfer
3d1a5b9b53
Merge pull request #1939 from OSInside/fix_grub_linux_default_setup
Fixed GRUB_CMDLINE_LINUX_DEFAULT setup regression
2021-10-07 09:51:49 +02:00
Marcus Schäfer
ef05ecc36e
Add support for toplevel include directive(s)
On the toplevel of an image description you can now
specify include directive(s) like in the following
example

<image ...>
    ...
    <include from="filename_a.xml"/>
    ...
    <include from="filename_b.xml"/>
</image>

At the place of their occurrence the include statement
will be replaced with the contents of the given filename.
The implementation is based on a XSLT stylesheet and
applies very early in the process. The stylesheet reads
the contents of the given file as XML document().
Thus only valid XML documents gets accepted by this
include concept. This Fixes #1929 and is related to
Issue #1918
2021-10-07 09:50:38 +02:00
804be745f2
Merge pull request #1938 from OSInside/allow_stdout_logging
Allow logfile option to log on stdout
2021-10-06 08:18:09 -04:00
Marcus Schäfer
7ca20f398a
Fixed creation of loopback config
If an extra boot partition is in use the creation of the config
file for the loopback boot feature was using the wrong path.
This commit fixes it and also introduces integration checks
which builds in this condition
2021-10-06 12:44:10 +02:00
Marcus Schäfer
e297a0f2a2
Fixed GRUB_CMDLINE_LINUX_DEFAULT setup regression
The value for GRUB_CMDLINE_LINUX_DEFAULT should only be
changed if custom kernelcmdline values are provided. In
case there are none kiwi should not change this value.
The test to check for this condition is based on the
result cmdline reduced by the root setting. However the
default cmdline setting in kiwi appends 'rw' in addition
to the root device information. This means the default
kernelcmdline is never empty and therefore the grub
setting GRUB_CMDLINE_LINUX_DEFAULT="rw" is always set.
This commit fixes the conditional change by making sure
the default cmdline only consists out of the root
device information. This Fixes #1650
2021-10-05 19:44:41 +02:00
Marcus Schäfer
7e0927e8d5
Allow logfile option to log on stdout
The option setting '--logfile stdout' is now a special form
and logs the messages usually written to a file to stdout
instead. This is handy if all messages of the build are
requested but the --debug switch is not because it does more
than that, e.g calling scripts through debug'able screen
sessions
2021-10-05 17:25:25 +02:00
Marcus Schäfer
b900264779
Fixed script calls when running in obs
kiwi is called with --debug in obs which triggers the scripts
to be called through screen. However the obs caller is not
associated with a terminal thus it fails. This commit creates
an exception for debug mode when running in obs
2021-09-23 16:54:31 +02:00
Luis González Fernández
547c3e2dcc
Fix secure boot for ubuntu based images
This patch fixes #1911 and makes secure boot images to work again in Ubuntu 20.04

Co-authored-by: Luis Ladislao Gonzalez Fernandez <luislgf@inditex.com>
2021-09-23 15:34:08 +02:00
Marcus Schäfer
7fa6cda579
Run scripts via a screen session in debug mode
When creating a custom script it usually takes some iterations of
try and testing until a final stable state is reached. To support
developers with this task kiwi calls scripts associated with a
screen session. The connection to screen is only done if kiwi
is called with the --debug option.
2021-09-22 11:48:47 +02:00
Marcus Schäfer
6e33f4a038
Merge pull request #1924 from OSInside/fix_package_uninstall
Fixed uninstall handling via dnf, microdnf, zypper
2021-09-10 23:52:00 +02:00
Marcus Schäfer
79080d1c97
Fixed uninstall handling via dnf, microdnf, zypper
The above package managers supports uninstall instructions
like 'iwl*'. In kiwi there was code checking via rpm if
the packages given to uninstall actually exists. That code
does not work if the given package to uninstall is an
instruction that matches a pattern. Therefore if we use
the uninstall section in the kiwi image description, just
pass the provided information to the package manager and
don't try to be clever in kiwi itself.
2021-09-10 23:49:37 +02:00
Marcus Schäfer
0ee9e22556
Only wipe bundle dir when required
The given result bundle dir must only be wiped if the
request to turn the result files into an rpm was given.
Only in this case the given bundle dir must start empty
2021-09-10 22:42:23 +02:00
Marcus Schäfer
7616114348
Added support for building rpm package from bundle
With the new option --package-as-rpm it is possible to
call the kiwi result bundler such that the image build
results gets packaged into an rpm. I think this is a
handy feature to transport image builds via repositories
2021-09-08 16:25:32 +02:00
Marcus Schäfer
21d757dafe
Merge pull request #1848 from OSInside/delete_obsolete_ddb_adapter_hack
Delete obsolete ddb.adapterType patching
2021-09-07 18:01:57 +02:00
Marcus Schäfer
702326d848
Merge pull request #1903 from OSInside/allow-archive-target
Allow target dir for archive
2021-09-07 18:01:41 +02:00
Marcus Schäfer
ab5836d5a6
Merge pull request #1915 from OSInside/sync_data_trailing_slash
Sync data trailing slash
2021-09-07 18:01:28 +02:00
Jesus Bermudez Velazquez
fd52237478
Allow target dir for archive
- Add the option to specify a target directory
  to unpack the archive
- Update doc for target dir attribute

This Fixes #1794
2021-09-07 15:13:24 +01:00
Marcus Schäfer
2de29ae5bb
Fixed condition for GRUB_DISABLE_LINUX_UUID="true"
The grub config parameter GRUB_DISABLE_LINUX_UUID must only
be set if the device persistence setting is not UUID. However,
in kiwi UUID device names are the default and doesn't have to
be expressed explicitly. Therefore the condition to check
for different than 'by-uuid' is wrong for the default case were
no device persistence setting exists. This results in a wrong
grub option to be set. This commit fixes it in a way to disable
UUID device names in grub if the only other device persistency
setting in kiwi named: 'by-label' is explicitly configured.
This Fixes #1842
2021-09-06 11:35:52 +02:00
Marcus Schäfer
bbb7efdf2f
Added force_trailing_slash argument to sync_data
A speciality of the rsync tool is that it behaves differently
if the given source_dir ends with a '/' or not. If it ends
with a slash the data structure below will be synced to the
target_dir. If it does not end with a slash the source_dir
and its contents are synced to the target_dir. For example:

    source
      └── some_data

1. $ rsync -a source target

    target
      └── source
            └── some_data

2. $ rsync -a source/ target

    target
      └── some_data

The parameter force_trailing_slash in the DataSync::sync_data
method can be used to make sure rsync behaves like shown in
the second case. This Fixes #1786
2021-09-06 11:18:30 +02:00
Marcus Schäfer
80f3148788
Add missing bootloader tests
Merging #1850 exposed the missing bootloader tests.
This reminds me to move the gitlab driven unit tests
to github actions because for forked repos the gitlab
tests does not run but github actions tests would run
2021-09-02 13:00:51 +02:00
Marcus Schäfer
e3e0d888c8
Added support for repo customization script
repo files allows for several customization options
which could not be set by kiwi through the current
repository schema. As the options used do not follow
any standard and are not compatible between package
managers and distributions the only generic way to
handle this is through a script which is invoked
with the repo file as parameter for each file created
to describe a repo for the selected package manager.
This allows users to update/change the repo file content
on their individual needs. In the kiwi description the
path to the custom script can be specified as follows

    <repository ... customize="/path/to/custom_script">
        <source path="..."/>
    </repository>

This Fixes #1896
2021-08-10 10:10:01 +02:00
Marcus Schäfer
51b5822aa7
Fixed LVM get_volumes
Due to the change on the temporary directory yet another
error in the volume manager classes for LVM got exposed.
2021-07-24 16:40:30 +02:00
Marcus Schäfer
59875a516d
Fixed LVM/btrfs volume based image builds
Due to the change on the temporary directory an error
in the volume manager classes for LVM and btrfs was
exposed. There was code which uses a sub-part of the
volume mount point directory which is a tempdir based
directory name. The sub-part was choosen by an index
based path split which worked for /tmp but no longer for
/var/tmp. With tempdir now being also a commandline
option this code has to become more robust.
2021-07-24 11:04:45 +02:00
Marcus Schäfer
5252e89d6b
Do not expose the delete feature in Temporary
We do not want to expose the ability to create temporary
data that doesn't get auto deleted at the end of its
scope
2021-07-22 15:49:55 +02:00
Marcus Schäfer
800be5594d
Refactor recovery archive creation
The creation of the recovery archive was based on a tempfile
which then gets moved to the final target file. This is bad
because if causes the tempfile cleanup to raise an exception
unless you specify delete=False. Creating a tempfile with
delete=False however, negates the reason for creating self
managed temporary data. Thus this code was refactored to
create the recovery archive file at its final destination
from the beginning on
2021-07-22 15:47:49 +02: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
c80e36e52d
Handle UnicodeDecode errors more gracefully
If the Codec.decode() method cannot encode the given data to utf-8
an Encoding exception is raised which causes kiwi to raise a
KiwiDecodingError. That way to handle the error causes an image
build to fail. However, this sort of error for example happens if
the .changes file of a package contains invalid characters. From
a user perspective this cannot be fixed and you cannot build the
image because of a stupid character error in a .changes file
outside your control. Because of this reason this commit handles
the decode error case differently and applies the 'replace'
strategy on error. The characters in questions gets replaced and
the rest of the data which can be decoded is returned.
2021-07-20 15:27:55 +02:00
Marcus Schäfer
e9935d01ee
Increase size of efi fat image
For ISO images an embedded efi fat image is needed to boot.
As consequence of adding the mok manager it can happen that
the size of the efi fat image is too small. With this commit
the size is increased to prevent an out of space issue
2021-07-14 12:26:24 +02:00
Marcus Schäfer
218cfa16b0
Fixed secure boot fallback setup
Make sure MokManager gets copied. The name and location of
the mok manager is distribution specific in the same way as
the shim loader. Thus we need to apply a similar concept
for looking it up. This Fixes bsc#1187515
2021-07-12 18:10:22 +02:00
Dan Čermák
e5c7ced265
Add tests for baseVagrantSetup 2021-07-07 16:29:52 +02:00
Marcus Schäfer
b65bcd8274
Fixed LUKS keyfile permission bits
LUKS keyfile should use 0600 file permission flags
2021-07-06 14:42:19 +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
Neal Gompa
f3b485089b Use namespaced files in /var/tmp for large temporary files
Previously, kiwi created staging image files as plain temporary files
in /tmp, which causes issues on operating systems where /tmp is tmpfs.
Notably, image builds would fail with "no space left on the device"
because the tmpfs was not big enough for everything to exist there.

To fix this, we change to use /var/tmp, and additionally add a prefix
for our temporary files so that the user knows which ones kiwi created.

Fixes: https://github.com/OSInside/kiwi/issues/1866
2021-06-28 12:06:42 -04:00
Marcus Schäfer
f807a630dc
Merge pull request #1860 from OSInside/no_shell_for_dnf_calls
Don't shell out for calling dnf
2021-06-21 15:15:13 +02:00
Dan Čermák
0511838c1b
Functions integration tests (#1851)
Add integration tests for functions.sh

Implement a container based test system to run shell code for testing.
The concept utilizes pytest-testinfra and runs a container per test.
The nested container in a container feature is supported by the github
actions workflow. Thus the integration of this testing concept runs in
the github actions CI rather than on gitlab
2021-06-21 15:03:13 +02:00
Marcus Schäfer
d8d0fa38f2
Merge pull request #1857 from OSInside/no_shell_for_pacman_calls
Prevent calling pacman through a shell
2021-06-21 14:53:01 +02:00
Marcus Schäfer
89b5a6f526
Don't shell out for calling dnf
refactor the dnf call to install packages and groups in
one call. This allows to prevent calling dnf through a
shell. For installing of a package group the group ID
name is expected. This Fixes #1856
2021-06-21 14:50:59 +02:00
Marcus Schäfer
47e4a6709c
Do not shell out for calling microdnf.
In fact it can be counter productive if the shell
evaluates eventually existing package name/instruction
patterns. This is related to Issue #1856
2021-06-21 11:59:04 +02:00
Marcus Schäfer
89f18b02b5
Prevent calling pacman through a shell
There is no reason to shell out for calling pacman.
In fact it can be counter productive if the shell
evaluates eventually existing package name/instruction
patterns. This is related to Issue #1856
2021-06-21 11:51:43 +02:00
Marcus Schäfer
fb3dc5744d
Allow creation of LUKS system with empty key
To support cloud platforms better we should allow the
creation of an initial(insecure) LUKS encrypted image
with an empty passphrase/keyfile. This Fixes
bsc#1187461 and bsc#1187460
2021-06-17 16:57:40 +02:00
Marcus Schäfer
687a2decf9
Delete obsolete ddb.adapterType patching
When building a vmdk image with pvscsi as adapter type, kiwi
implicitly changed the adapter_type from pvscsi to lsilogic
because qemu only knows lsilogic. At the end kiwi patched
the adapter type in the descriptor of the vmdk header back
to pvscsi. That patching seems to be wrong according to
information from users and VMware support. This commit
deletes the descriptor patching and only leaves the pvscsi
setting in the guest configuration(vmx).
This Fixes bsc#1180539 and Fixes #1847
2021-06-15 10:16:28 +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