OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
301 stars 152 forks source link

Exception thrown on missing <ype image="iso"> entry #925

Closed dcermak closed 5 years ago

dcermak commented 5 years ago

Problem description

A config.xml that is missing the <preferences><type image="iso" ...>[snip]</type></preferences> field results in kiwi duming this (not too helpful) exception to the log:

[ ERROR   ]: 14:02:57 | Unexpected error:
Traceback (most recent call last):
  File "/usr/bin/kiwi-ng", line 11, in <module>
    load_entry_point('kiwi==9.17.8', 'console_scripts', 'kiwi-ng-3')()
  File "/usr/lib/python3.6/site-packages/kiwi/kiwi.py", line 64, in main
    App()
  File "/usr/lib/python3.6/site-packages/kiwi/app.py", line 35, in __init__
    task_class().process()
  File "/usr/lib/python3.6/site-packages/kiwi/tasks/system_build.py", line 150, in process
    self.runtime_checker.check_dracut_module_for_disk_oem_in_package_list()
  File "/usr/lib/python3.6/site-packages/kiwi/runtime_checker.py", line 401, in check_dracut_module_for_disk_oem_in_package_list
    self.xml_state.get_bootstrap_packages() + \
  File "/usr/lib/python3.6/site-packages/kiwi/xml_state.py", line 326, in get_bootstrap_packages
    return sorted(list(set(result)))
TypeError: '<' not supported between instances of 'NoneType' and 'str'

The offending config.xml is at the end of this issue (unfortunately github really doesn't want me to upload it).

Expected behavior

A better error message would be nice, something like

[ ERROR   ]: 14:02:57 | Missing iso configuration section. Aborting...

The message would of course depend on what the actual issue is, which I just guess.

Steps to reproduce the behavior

Copy the config.xml from the end of the issue into this folder: https://github.com/SUSE/kiwi-descriptions/tree/master/suse/x86_64/suse-leap-15.0-JeOS and run:

kiwi-ng --type oem system build --description . --target-dir /tmp/myimage

OS and Software information

Reproducer

config.xml:

<?xml version="1.0" encoding="utf-8"?>

<image schemaversion="6.8" name="OpenSUSE-Leap-15.0">
    <description type="system">
        <author>Marcus Schaefer</author>
        <contact>ms@suse.de</contact>
        <specification>
            OpenSUSE Leap 15.0
        </specification>
    </description>
    <!-- <preferences> -->
    <!--     <type image="iso" primary="true" flags="overlay" hybrid="true" firmware="efi" kernelcmdline="splash" hybridpersistent_filesystem="ext4" hybridpersistent="true" mediacheck="true"/> -->
    <!--     <version>1.15.0</version> -->
    <!--     <packagemanager>zypper</packagemanager> -->
    <!--     <locale>en_US</locale> -->
    <!--     <keytable>us</keytable> -->
    <!--     <timezone>Europe/Berlin</timezone> -->
    <!--     <rpm-excludedocs>true</rpm-excludedocs> -->
    <!--     <rpm-check-signatures>false</rpm-check-signatures> -->
    <!--     <bootsplash-theme>openSUSE</bootsplash-theme> -->
    <!--     <bootloader-theme>openSUSE</bootloader-theme> -->
    <!-- </preferences> -->
    <preferences>
        <type image="oem" filesystem="ext4" initrd_system="dracut" installiso="true" bootloader="grub2" kernelcmdline="splash" firmware="efi" boottimeout="10">
            <oemconfig>
                <oem-systemsize>2048</oem-systemsize>
                <oem-swap>false</oem-swap>
                <oem-device-filter>/dev/ram</oem-device-filter>
                <oem-multipath-scan>false</oem-multipath-scan>
            </oemconfig>
            <machine memory="512" guestOS="suse" HWversion="4">
                <vmdisk id="0" controller="ide"/>
                <vmnic driver="e1000" interface="0" mode="bridged"/>
            </machine>
        </type>
    </preferences>
    <users>
        <user password="vagrant" home="/root" name="root" groups="root" pwdformat="plain" />
    </users>
    <users>
        <user password="vagrant" home="/home/vagrant" name="vagrant" groups="users" pwdformat="plain" />
    </users>
    <repository type="rpm-md" alias="Leap_15_0" imageinclude="true">
        <source path="obs://openSUSE:Leap:15.0/standard"/>
    </repository>
    <repository type="rpm-md" alias="Leap_15_0_Update" imageinclude="true">
        <source path="obs://openSUSE:Leap:15.0:Update/standard"/>
    </repository>
    <repository type="rpm-md" alias="Leap_15_0_non_free" imageinclude="true">
        <source path="obs://openSUSE:Leap:15.0:NonFree/standard"/>
    </repository>
    <repository type="rpm-md" alias="Leap_15_0_non_free_Update" imageinclude="true">
        <source path="obs://openSUSE:Leap:15.0:NonFree:Update/standard"/>
    </repository>

    <packages type="image">
        <package name="checkmedia"/>
        <package name="bindfs"/>
        <package name="ca-certificates"/>
        <package name="ca-certificates-mozilla"/>
        <package name="curl"/>
        <package name="patterns-openSUSE-base"/>
        <package name="plymouth-branding-openSUSE"/>
        <package name="plymouth-dracut"/>
        <package name="grub2-branding-openSUSE"/>
        <!-- <package name="ifplugd"/> -->
        <package name="iputils"/>
        <package name="vim"/>
        <package name="grub2"/>
        <package name="grub2-x86_64-efi" arch="x86_64"/>
        <package name="grub2-i386-pc"/>
        <package name="syslinux"/>
        <package name="lvm2"/>
        <package name="plymouth"/>
        <package name="fontconfig"/>
        <package name="fonts-config"/>
        <package name="tar"/>
        <package name="parted"/>
        <package name="openssh"/>
        <!-- <package name="iproute2"/> -->
        <package name="less"/>
        <package name="bash-completion"/>
        <package name="dhcp-client"/>
        <package name="which"/>
        <package name="shim"/>
        <package name="sudo"/>
        <package name="kernel-default"/>
        <package name="timezone"/>

        <!-- <package name="p11-kit-nss-trust"/> -->
        <!-- <package type="delete" name="mozilla-nss-certs"/> -->
    </packages>
    <packages type="iso">
        <package name="gfxboot-branding-openSUSE"/>
        <package name="dracut-kiwi-live"/>
    </packages>
    <packages type="oem">
        <package name="gfxboot-branding-openSUSE"/>
        <package name="dracut-kiwi-oem-repart"/>
        <package name="dracut-kiwi-oem-dump"/>
    </packages>
    <packages type="bootstrap">
        <package name="udev"/>
        <package name="filesystem"/>
        <package name="glibc-locale"/>
        <package name="cracklib-dict-full"/>
        <package name="ca-certificates"/>
        <package name="openSUSE-release"/>
    </packages>
    <!-- <packages type="delete"> -->
    <!--     <package name="snapper"/> -->
    <!--     <package name="snapper-zypp-plugin"/> -->
    <!--     <package name="grub2-snapper-plugin"/> -->
    <!-- </packages> -->
</image>
davidcassany commented 5 years ago

@dcermak the issue you are facing is caused by not having a package manager other required data from <preferences> defined in the config.xml. This not related to missing the iso type, but caused by missing preferences data. I'd suggest you to not comment the original preferences and include all your <type image="oem"...> section into the original <preferences>. Calling with

kiwi-ng --type oem system build --description . --target-dir /tmp/myimage

already enforces KIWI to build the OEM image thanks to --type oem flag.

Anyway I agree we should catch it and provide better feedback. I am having a look at it.

dcermak commented 5 years ago

@davidcassany Yes, I have broken the config.xml myself by commenting the parts out, i was kind of expecting to get an error.

Thanks for taking a look at that!