Commit Graph

53 Commits

Author SHA1 Message Date
Marcus Schäfer
88ccd4d1e9
Allow bundle format to be set on the commandline
The bundle format is usually specified as part of the image
description in the bundle_format attribute. This commit also
allows to specify/overwrite the bundle format in the kiwi
result bundle command via the new --bundle-format option.
This Fixes #2509
2024-03-19 15:50:23 +01:00
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
4fc0d2147d
Move DiskFormat to context manager
Change the DiskFormat Factory to be a context manager.
All code using DiskFormat was updated to the following
with statement:

    with DiskFormat(...).new as disk_format:
        disk_format.some_member()

This is related to Issue #2412
2024-02-29 16:42:49 +01:00
Marcus Schäfer
8739088340
Catch error condition more specific
Only a KiwiCommandError is an exception we want to
catch and handle, everything else is a bug and should
not be masked
2024-02-28 10:31:38 +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
Dan Čermák
48817a6441
Refactor Command class
Command.run() currently has a bit of a confusing behavior: if raise_on_error is
False and the executable is not found, then a weird CommandT is returned (return
code is -1 and stdout+stderr is None). This makes it possible to hanlde command
not found errors separately, but it makes that needlessly verbose. So instead,
let's just return None in *this* special case.

That in turn uncovered, that in most cases when we set `raise_on_error=True`, we
actually want an error if the command is not present but no error if the command
fails to execute (e.g. because it returns -1 if you run `$cmd --version`). Hence we
introduce the flag `raise_on_command_not_found`, which causes an exception to
be raised if the command is not found. This makes it independent of the
`raise_on_error` flag.

Additionally, we add a small optimization: if command starts with /, then we
assume it's a full path and we omit the call to which (and just check whether it
exists).

Co-authored-by: Marcus Schäfer <marcus.schaefer@gmail.com>
2024-02-19 16:33:24 +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
54f92d2a9f
Drop support for syslinux/isolinux
SYSLINUX has been abandoned for several years now, and it does not
even work with modern versions of the filesystems supported in kiwi.
This commit drops it and Fixes #2433
2024-01-26 21:25:37 +01:00
Marcus Schäfer
cdbe5060ca
Move LoopDevice class to context manager
Change the LoopDevice class to be a context manager.
All code using LoopDevice was updated to the following
with statement:

with LoopDevice(...) as loop_provider:
    loop_provider.some_member()

This is related to Issue #2412
2024-01-11 19:18:01 +01:00
Marcus Schäfer
9628abd7f4
Fixed unit tests for parallel invokation 2023-12-17 16:12:42 +01:00
Marcus Schäfer
2980ad1926
Support TOML markup
Allow to use TOML markup for the kiwi image description
This Fixes #2372
2023-09-13 12:07:24 +02:00
Marcus Schäfer
8549db8699
Fixed wrong test assertions
Former versions of pytest did ignore invalid assertions.
Now they are reported as an error and show the mistakes
of the past
2023-01-17 16:30:09 +01:00
Marcus Schäfer
bbbfdce1e9
Allow to pass credentials as file reference 2022-12-14 16:58:43 +01:00
Marcus Schäfer
80fffdecc2
Support repo URI's with credentials on cmdline
Specifying a repository as part of the image description
allows for credentials via the username and password attributes.
Howver, repositories can also be specified on the commandline
via the --set-repo / --add-repo options. The options on the
commandline did not allow to specify credentials so far.
This commit adds the commandline options --set-repo-credentials
and --add-repo-credentials to support them
2022-12-14 16:58:43 +01:00
Marcus Schäfer
b8bcabf30c
Added --loglevel option
specify logging level as number. Details about the
available log levels can be found at:
https://docs.python.org/3/library/logging.html#logging-levels
Setting a log level causes all message >= level to be
displayed.
2022-11-08 15:06:50 +01:00
Marcus Schäfer
14c49af271
Consolidate and cleanup logging
Make sure all loggers; stream handlers, file and socket
handler uses the same logging format. Also make sure that
there is only one place for setLogLevel when kiwi is
used as application
2022-11-02 22:25:32 +01:00
Marcus Schäfer
ce203dbe14
Added support for --logsocket
Like with --logfile this commit adds support for using
an existing Unix Domain Socket for logging. It's required
that there is a listener on the given socket otherwise
kiwi exits with an appropriate error message from the
socket layer. A simple listener could look like the
following:

```python
sock_file = '/tmp/log_socket'
buffer = 1024
if os.path.exists(sock_file):
    os.unlink(sock_file)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(sock_file)
sock.listen(1)
while True:
    connection, client_address = sock.accept()
    try:
        while True:
            data = connection.recv(buffer)
            if not data:
                break
            print(data.decode())
    finally:
        connection.close()
```

With the listener in place kiwi can be called as follows:

    kiwi-ng --logsocket /tmp/log_socket ...
2022-10-29 20:36:08 +02:00
Marcus Schäfer
c39b7396b8
Support URIs with credentials in solver plugin
check if the URI string contains credentials and
extract/trim them from the uri object. The urlparse
class does not recognize this information as a valid
URI and throws an exception
2022-08-09 15:43:44 +02:00
Marcus Schäfer
a52117eb63
Fixed handling of signing_keys in cmdline options
When passing signing_keys with the --add-repo|--set-repo
commandline options the delimiter to separate the single
key information is a colon(:). However, this is stupid when
kiwi expects the signing key to be references as an URI
format like file://... Therefore this patch changes the
delimiter from colon(:) to semicolon(;)
2022-06-08 18:29:42 +02:00
Carlos Bederián
dd7e75f9c6
Setup SELinux on every system prepare / build (#2148)
Setup SELinux on every system prepare / build such that all image types benefit from it not only the disk (oem) type
2022-06-01 11:31:00 +02:00
Marcus Schäfer
6c2b2916ee
Allow more repo params to be set on the cmdline
The repository parameters for signing keys, the component
list the main distribution name for debian repositories and
also the repository_gpgcheck could not be set via the
commandline options --add-repo and/or --set-repo. This
commit adds support for them and also updates the manual
page accordingly
2022-05-08 09:51:20 +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
dd763835cf
Added debug option --debug-run-scripts-in-screen
Instead of running scripts in screen if the --debug switch is
set, we allow to explicitly switch on this behavior via
a new option. This Fixes #2010
2022-01-11 09:38:22 +01:00
Marcus Schäfer
ed523284f2
Add global --kiwi-file option
When building with kiwi a search on the kiwi main config
file is made inside of the given --description directory.
The search looks up for the file config.xml or *.kiwi.
So far there was no opportunity to specify another name.
This commit adds an option in the global area named:

    --kiwi-file name

which will make kiwi to lookup this file inside of the
given --description directory and fail if it does not
exist. This Fixes #1973
2021-11-29 12:23:26 +01:00
Marcus Schäfer
8fea098ed2
Added support for reading metalink in info module
For resolver operations through libsolv the 'kiwi image info'
module exists. So far it could not read the repos from
metalink repo definitions. This Fixes #1890
2021-11-22 22:08:56 +01:00
David Cassany
7b14694093
Force key attribute from signing element to be treated as a URI
Signed-off-by: David Cassany <dcassany@suse.com>
2021-11-19 13:29:52 +01:00
David Cassany
d232e8382a
Pass signing keys from the XML to the repositories
This commits makes sure signing keys are passed to
repositories setup in build task.

Signed-off-by: David Cassany <dcassany@suse.com>
2021-11-18 16:52:52 +01:00
Marcus Schäfer
350ed05454 Allow to set sign keyfile in repository elements
This commit adds a new and optional child element <signing>
to the repository/source element as shown in the following
example:

<repository>
    <source path="...">
        <signing key="keyfile"/>
    </source>
</repository>

The collection of all keyfiles from all repositories will be
added to the keyring as used by the selected package manager.
Signing keys specified on the commandline and signing keys
specified in the image description will be combined.
This Fixes #1883
2021-11-16 10:15:46 -05:00
Marcus Schäfer
442e9b9ac4
Followup fix for debootstrap called only once
A recent change skipped calling debootstrap if the allow-existing-root
flag was passed in combination with apt as the package manager.
However this is not enough. If you say allow-existing-root but
the existing root is empty or not valid to continue with chroot
and apt the debootstrap phase should not be skipped. This commit
checks if apt works in the chroot such that we can assume
debootstrap has done its job and can be skipped
2021-11-12 22:53:02 +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
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
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
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
Marcus Schäfer
09b7cdd442
Fixed unit tests for parallel invocation
With the change to allow the platform architecture to be
set application global, the unit tests might fail if tests
run in parallel and using different mock architectures
for the test. Thus test that runs depending on a platform
name needs to set the name in the test
2021-04-28 17:05:03 +02:00
Marcus Schäfer
50416ddc22
Added optional post_bootstrap.sh script hook
After the bootstrap phase a script post_bootstrap.sh is executed
in a chroot process which allows to add/modify system settings
prior the completion of the system installation. This helps
users for example with custom package manager settings and
Fixes #1763 as well as Fixes #1782
2021-04-05 13:21:49 +02:00
Marcus Schäfer
5e983dd546
Add kiwi dracut mod vs. kiwi compatibility check
Add a runtime check to be called in the create stage
which reads the version(s) of the installed kiwi dracut
modules from the package database and compare them with
a min_version setting maintained in the KIWI builder
code. If the installed dracut module is not compatible
with the used kiwi builder version the build stops
at this point with a descriptive error message
2021-03-01 10:32:53 +01:00
Marcus Schäfer
aae7da639d
Added deb support to sat solver module
Add support to create SAT solvables from Debian repos via
deb2solv tool from libsolv. This allows image info --resolve-package-list
to work with Debian/Ubuntu image descriptions. Please note
by default libsolv is not compiled with support for Debian.
Therefore the following compile flags must be set on libsolv

* -DENABLE_DEBIAN=1
* -DMULTI_SEMANTICS=1

If libsolv does not provide the needed capabilities kiwi will
fail on either the repository solvable creation due to missing
deb2solv or on call of setdisttype() due to missing MULTI_SEMANTICS
feature in libsolv
2021-02-21 18:50:16 +01:00
Marcus Schäfer
930745268d
Added check_swap_name_used_with_lvm runtime check
The optional oem-swapname is only effective if used together
with the LVM volume manager. A name for the swap space can
only be set if it is created as a LVM volume. In any other
case the name does not apply to the system. This condition
should be checked to avoid useless settings in the image
description.
2020-12-11 15:26:38 +01:00
Marcus Schäfer
7b727414ce
Refactor Partitioner
This commit refactors the Partitioner class and turns it into a
proper factory class and also includes type hints to facilitate
it's use from an API POV. Related to #1498
2020-11-25 17:02:12 +01:00
Marcus Schäfer
7b479cbd9c
Refactor DiskFormat
This commit refactors DiskFormat to turn it into a proper
factory class and to also include type hints to facilitate it's
use from an API POV. Related to #1498
2020-11-02 14:53:36 +01:00
Marcus Schäfer
d1d0444abd
Refactor ImageBuilder Factory
This commit refactors the ImageBuilder 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-22 16:34:44 +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
54ab18c96c
Make oem image use dracut by default
Before this commit an oem image still had the kiwi initrd_system
set as default. As we are decommission the custom kiwi initrd
concept the default should be changed. It is still possible to
use a custom kiwi initrd but it needs to be explicitly requested
via the initrd_system="kiwi" attribute. In addition to the
changed default a runtime check was introduced that checks
the presence of the boot= attribute which only makes sense
in combination with the kiwi initrd_system. If boot= is
set but initrd_system="kiwi" is not, a message is raised that
explains the situation and either requests setting initrd_system
properly or deleting the boot attribute. The change only
affects people who still use oem with a boot="oemboot/..."
setting and no explicit selection of kiwi as the initrd_system.
As these image type configurations should not be in use anyway
because this is all legacy and announced to go away, we
need to make the next step and enforce a new default in
code. This is related to Issue #1299
2020-09-11 09:49:17 +02:00
Marcus Schäfer
500fab909c
Fixed line ending of sha256 bundler file
The .sha256 file does not end with a newline. This Fixes #1449
2020-05-25 12:44:19 +02:00
Marcus Schäfer
4720d21283
Support multiple markup formats
Allow to read multiple markup formats. Supported are XML
and YAML. The parsing and transformation is based on the
anymarkup module. The use of anymarkup is optional and
implemented as an on demand loading module. If a user
uses a yaml config file or a request to convert into
yaml is made without an installed anymarkup module an
exception is thrown
2020-05-15 13:59:22 +02:00
David Cassany
469f71144e
Clean AnonymousUniqueId from the image
This commit is two fold.

For one side does a small refactor to move the deletion of custom RPM
macros to package manager level inside a cleaning method. This way only
RPM based package managers run RPM specific code and each package manager
can apply its own specific logic.

On the other hand for the zypper package manager the deletion of
/var/lib/zypp/AnonymousUniqueId file has been added as part of the
new cleaning method.

Fixes #1396
2020-04-30 15:19:08 +02:00