Modules: Improve error reporting

- [initcpio] remove superfluous inner function
 - [initcpio] catch errors from mkinitcpio itself and report them in a nice
   readable format.

 - Save translators the effort of doing a dozen messages
   with just the name of the module changed. All of these modules
   bail out on bad configurations with a meaningful message.
   - [initcpiocfg]
   - [fstab]
   - [initramfscfg]
   - [localecfg]
   - [luksbootkeyfile]
   - [luksopenswaphookcfg]

 - [machineid] Warn on bad config. It's conceivable that this is run
   with an empty rootMountPoint (i.e. "") to modify the running system,
   so only bail on None.
main
Adriaan de Groot 6 years ago
parent 1f7dfafe9a
commit ec0fe2ccd3

@ -306,6 +306,16 @@ def run():
conf = libcalamares.job.configuration
partitions = global_storage.value("partitions")
root_mount_point = global_storage.value("rootMountPoint")
if not partitions:
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("fstab"))
if not root_mount_point:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("fstab"))
mount_options = conf["mountOptions"]
ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
crypttab_options = conf.get("crypttabOptions", "luks")

@ -32,18 +32,19 @@ _ = gettext.translation("calamares-python",
def pretty_name():
return _("Creating initramfs with mkinitcpio.")
def run_mkinitcpio():
""" Runs mkinitcpio with given kernel profile """
kernel = libcalamares.job.configuration['kernel']
check_target_env_call(['mkinitcpio', '-p', kernel])
def run():
""" Calls routine to create kernel initramfs image.
:return:
"""
run_mkinitcpio()
from subprocess import CalledProcessError
kernel = libcalamares.job.configuration['kernel']
try:
check_target_env_call(['mkinitcpio', '-p', kernel])
except CalledProcessError as e:
libcalamares.utils.warning(str(e))
return ( _( "Process Failed" ),
_( "Process <pre>mkinitcpio</pre> failed with error code {!s}. The command was <pre>{!s}</pre>." ).format( e.returncode, e.cmd ) )
return None

@ -181,6 +181,16 @@ def run():
"""
partitions = libcalamares.globalstorage.value("partitions")
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
if not partitions:
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("initcpiocfg"))
if not root_mount_point:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("initcpiocfg"))
modify_mkinitcpio_conf(partitions, root_mount_point)
return None

@ -88,6 +88,16 @@ def run():
"""
partitions = libcalamares.globalstorage.value("partitions")
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
if not partitions:
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("initramfscfg"))
if not root_mount_point:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("initramfscfg"))
copy_initramfs_hooks(partitions, root_mount_point)
return None

@ -138,6 +138,12 @@ def run():
}
install_path = libcalamares.globalstorage.value("rootMountPoint")
if install_path is None:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(install_path))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("localecfg"))
target_locale_gen = "{!s}/etc/locale.gen".format(install_path)
target_locale_gen_bak = target_locale_gen + ".bak"
target_locale_conf_path = "{!s}/etc/locale.conf".format(install_path)

@ -46,6 +46,11 @@ def run():
partitions = libcalamares.globalstorage.value("partitions")
if not partitions:
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("luksbootkey"))
luks_root_device = ""
luks_root_passphrase = ""

@ -90,6 +90,15 @@ def run():
openswap_conf_path = libcalamares.job.configuration["configFilePath"]
partitions = libcalamares.globalstorage.value("partitions")
if not partitions:
libcalamares.utils.warning("partitions is empty, {!s}".format(partitions))
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use." ).format("luksopenswaphookcfg"))
if not root_mount_point:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("luksopenswaphookcfg"))
openswap_conf_path = openswap_conf_path.lstrip('/')
return write_openswap_conf(partitions, root_mount_point, openswap_conf_path)

@ -43,6 +43,12 @@ def run():
:return:
"""
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
if root_mount_point is None:
libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point))
return (_("Configuration Error"),
_("No root mount point is given for <pre>{!s}</pre> to use." ).format("machineid"))
enable_systemd = libcalamares.job.configuration["systemd"]
enable_dbus = libcalamares.job.configuration["dbus"]
enable_symlink = libcalamares.job.configuration["symlink"]

Loading…
Cancel
Save