Merge pull request #2057 from dalto8/dracutimagename

[dracut] Change image name terminology to match dracut
This commit is contained in:
dalto8 2022-10-22 17:48:44 +00:00 committed by GitHub
commit 1ee2a2a364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 12 deletions

View File

@ -5,6 +5,6 @@
---
# Dracut defaults to setting initramfs-<kernel-version>.img
# If you want to specify another filename for the resulting image,
# set a custom kernel name, including the path
# set a custom name, including the path
#
# kernelName: /boot/initramfs-linux.img
# initramfsName: /boot/initramfs-linux.img

View File

@ -6,4 +6,4 @@ $id: https://calamares.io/schemas/dracut
additionalProperties: false
type: object
properties:
kernelName: { type: string }
initramfsName: { type: string }

View File

@ -12,9 +12,10 @@
#
# Calamares is Free Software: see the License-Identifier above.
#
import subprocess
import libcalamares
from libcalamares.utils import check_target_env_call
from libcalamares.utils import target_env_process_output
import gettext
@ -34,12 +35,20 @@ def run_dracut():
:return:
"""
kernelName = libcalamares.job.configuration['kernelName']
try:
initramfs_name = libcalamares.job.configuration['initramfsName']
target_env_process_output(['dracut', '-f', initramfs_name])
except KeyError:
try:
target_env_process_output(['dracut', '-f'])
except subprocess.CalledProcessError as cpe:
libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}")
return cpe.returncode
except subprocess.CalledProcessError as cpe:
libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}")
return cpe.returncode
if not kernelName:
return check_target_env_call(['dracut', '-f'])
else:
return check_target_env_call(['dracut', '-f', '{}'.format(kernelName)])
return 0
def run():
@ -50,7 +59,6 @@ def run():
:return:
"""
return_code = run_dracut()
if return_code != 0:
return (_("Failed to run dracut on the target"),
_("The exit code was {}").format(return_code))
return (_("Failed to run dracut"),
_(f"Dracut failed to run on the target with return code: {return_code}"))