-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support for ostree based systems #2557
Draft
travier
wants to merge
6
commits into
OSInside:main
Choose a base branch
from
travier:main-atomic-ostree-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bdaee21
defaults: Add method to check for ostree case
travier e14f0e8
bootloader/config/grub2: Handle ostree case for BLS configs
travier d044c51
system/kernel: Find kernel in ostree case
travier d5f7346
kiwi/builder/live: Handle ostree case
travier b93421c
kiwi/bootloader/config/grub2: Handle ostree case
travier efbd720
Make unit tests to pass
schaefi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import logging | ||
from typing import Dict | ||
import shutil | ||
import re | ||
|
||
# project | ||
from kiwi.utils.temporary import Temporary | ||
|
@@ -172,41 +173,58 @@ def create(self) -> Result: | |
working_directory=self.root_dir | ||
) | ||
|
||
# prepare dracut initrd call | ||
self.boot_image.prepare() | ||
if not Defaults.is_ostree(self.root_dir): | ||
# prepare dracut initrd call | ||
self.boot_image.prepare() | ||
|
||
# create dracut initrd for live image | ||
log.info('Creating live ISO boot image') | ||
live_dracut_modules = Defaults.get_live_dracut_modules_from_flag( | ||
self.live_type | ||
) | ||
live_dracut_modules.append('pollcdrom') | ||
for dracut_module in live_dracut_modules: | ||
self.boot_image.include_module(dracut_module) | ||
self.boot_image.omit_module('multipath') | ||
self.boot_image.write_system_config_file( | ||
config={ | ||
'modules': live_dracut_modules, | ||
'omit_modules': ['multipath'] | ||
}, | ||
config_file=self.root_dir + '/etc/dracut.conf.d/02-livecd.conf' | ||
) | ||
self.boot_image.create_initrd(self.mbrid) | ||
# Clean up leftover dracut config file (which can break installs) | ||
os.unlink(self.root_dir + '/etc/dracut.conf.d/02-livecd.conf') | ||
if self.bootloader == 'systemd_boot': | ||
# make sure the initrd name follows the dracut | ||
# naming conventions | ||
boot_names = self.boot_image.get_boot_names() | ||
if self.boot_image.initrd_filename: | ||
Command.run( | ||
[ | ||
'mv', self.boot_image.initrd_filename, | ||
self.root_dir + ''.join( | ||
['/boot/', boot_names.initrd_name] | ||
) | ||
] | ||
) | ||
# create dracut initrd for live image | ||
log.info('Creating live ISO boot image') | ||
live_dracut_modules = Defaults.get_live_dracut_modules_from_flag( | ||
self.live_type | ||
) | ||
live_dracut_modules.append('pollcdrom') | ||
for dracut_module in live_dracut_modules: | ||
self.boot_image.include_module(dracut_module) | ||
self.boot_image.omit_module('multipath') | ||
self.boot_image.write_system_config_file( | ||
config={ | ||
'modules': live_dracut_modules, | ||
'omit_modules': ['multipath'] | ||
}, | ||
config_file=self.root_dir + '/etc/dracut.conf.d/02-livecd.conf' | ||
) | ||
self.boot_image.create_initrd(self.mbrid) | ||
# Clean up leftover dracut config file (which can break installs) | ||
os.unlink(self.root_dir + '/etc/dracut.conf.d/02-livecd.conf') | ||
if self.bootloader == 'systemd_boot': | ||
# make sure the initrd name follows the dracut | ||
# naming conventions | ||
boot_names = self.boot_image.get_boot_names() | ||
if self.boot_image.initrd_filename: | ||
Command.run( | ||
[ | ||
'mv', self.boot_image.initrd_filename, | ||
self.root_dir + ''.join( | ||
['/boot/', boot_names.initrd_name] | ||
) | ||
] | ||
) | ||
else: # pragma: nocover | ||
# TODO: ostree: this code should be part of an OSTree class find the existing initrd in the ostree case | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open for the Friday conversation |
||
boot_ostree_dir = os.sep.join([self.root_dir, 'boot/ostree']) | ||
initramfs_ostree_pattern = '.*/boot/ostree/.*/initramfs-(.*)' | ||
if os.path.isdir(boot_ostree_dir): | ||
for deployment in sorted(os.listdir(boot_ostree_dir)): | ||
deployment_dir = os.sep.join([self.root_dir, 'boot/ostree', deployment]) | ||
if os.path.isdir(deployment_dir): | ||
files = sorted(os.listdir(deployment_dir)) | ||
for f in files: | ||
initramfs_file = os.sep.join([self.root_dir, 'boot/ostree', deployment, f]) | ||
version_match = re.match(initramfs_ostree_pattern, initramfs_file) | ||
if version_match: | ||
initrd_dest = os.sep.join([self.root_dir, 'boot/initramfs']) | ||
Command.run(['cp', initramfs_file, initrd_dest]) | ||
self.boot_image.initrd_filename = initrd_dest | ||
|
||
# create EFI FAT image | ||
if self.firmware.efi_mode(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
|
||
# project | ||
from kiwi.command import Command | ||
from kiwi.defaults import Defaults | ||
|
||
from kiwi.exceptions import KiwiKernelLookupError | ||
|
||
|
@@ -90,6 +91,29 @@ def get_kernel( | |
filename=kernel_file, | ||
version=version | ||
) | ||
|
||
if Defaults.is_ostree(self.root_dir): # pragma: nocover | ||
# TODO: ostree: This code looks similar to the one in builder/live and should imho exist only once in a OSTree class | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open for the Friday conversation |
||
boot_ostree_dir = os.sep.join([self.root_dir, 'boot/ostree']) | ||
kernel_ostree_pattern = '.*/boot/ostree/.*/vmlinuz-(.*)' | ||
if os.path.isdir(boot_ostree_dir): | ||
for deployment in sorted(os.listdir(boot_ostree_dir)): | ||
deployment_dir = os.sep.join([self.root_dir, 'boot/ostree', deployment]) | ||
if os.path.isdir(deployment_dir): | ||
files = sorted(os.listdir(deployment_dir)) | ||
for f in files: | ||
kernel_file = os.sep.join([self.root_dir, 'boot/ostree', deployment, f]) | ||
version_match = re.match(kernel_ostree_pattern, kernel_file) | ||
if version_match: | ||
version = version_match.group(1) | ||
return kernel_type( | ||
name=os.path.basename( | ||
os.path.realpath(kernel_file) | ||
), | ||
filename=kernel_file, | ||
version=version | ||
) | ||
|
||
if raise_on_not_found: | ||
raise KiwiKernelLookupError( | ||
'No kernel found in {0}, searched for {1}'.format( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open for the Friday conversation