def prepare(self): """ Prepare new root system suitable to create a kiwi initrd from it """ self.load_boot_xml_description() boot_image_name = self.boot_xml_state.xml_data.get_name() self.import_system_description_elements() log.info('Preparing boot image') system = SystemPrepare(xml_state=self.boot_xml_state, root_dir=self.boot_root_directory, allow_existing=True) manager = system.setup_repositories(signing_keys=self.signing_keys) system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.boot_xml_state) profile.add('kiwi_initrdname', boot_image_name) defaults = Defaults() defaults.to_profile(profile) self.setup = SystemSetup(self.boot_xml_state, self.boot_root_directory) profile.create(Defaults.get_profile_file(self.boot_root_directory)) self.setup.import_description() self.setup.import_overlay_files(follow_links=True) self.setup.call_config_script() system.pinch_system(manager=manager, force=True) # make sure system instance is cleaned up before setting up del system self.setup.call_image_script() self.setup.create_init_link_from_linuxrc()
class TestProfile: def setup(self): self.tmpfile = mock.Mock() self.tmpfile.name = 'tmpfile' self.profile_file = 'tmpfile.profile' description = XMLDescription('../data/example_dot_profile_config.xml') self.profile = Profile(XMLState(description.load())) @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile self.profile.create(self.profile_file) os.remove(self.tmpfile.name) os.remove(self.profile_file) assert self.profile.dot_profile == { 'kiwi_Volume_1': 'usr_lib|size:1024|usr/lib', 'kiwi_Volume_2': 'LVRoot|freespace:500|', 'kiwi_Volume_3': 'etc_volume|freespace:30|etc', 'kiwi_Volume_4': 'bin_volume|size:all|/usr/bin', 'kiwi_Volume_5': 'usr_bin|freespace:30|usr/bin', 'kiwi_Volume_6': 'LVSwap|size:128|', 'kiwi_bootkernel': None, 'kiwi_bootloader': 'grub2', 'kiwi_bootprofile': None, 'kiwi_target_removable': None, 'kiwi_boot_timeout': None, 'kiwi_cmdline': 'splash', 'kiwi_compressed': None, 'kiwi_delete': '', 'kiwi_devicepersistency': None, 'kiwi_bootloader_console': None, 'kiwi_displayname': 'schäfer', 'kiwi_drivers': '', 'kiwi_firmware': 'efi', 'kiwi_fsmountoptions': None, 'kiwi_hybridpersistent_filesystem': None, 'kiwi_hybridpersistent': None, 'kiwi_iname': 'LimeJeOS-openSUSE-13.2', 'kiwi_installboot': None, 'kiwi_iversion': '1.13.2', 'kiwi_keytable': 'us.map.gz', 'kiwi_language': 'en_US', 'kiwi_loader_theme': 'openSUSE', 'kiwi_lvm': 'true', 'kiwi_lvmgroup': 'systemVG', 'kiwi_oembootwait': None, 'kiwi_oemdevicefilter': None, 'kiwi_oemnicfilter': None, 'kiwi_oemkboot': None, 'kiwi_oemmultipath_scan': None, 'kiwi_oempartition_install': None, 'kiwi_oemrebootinteractive': None, 'kiwi_oemreboot': None, 'kiwi_oemrecoveryID': None, 'kiwi_oemrecoveryInPlace': None, 'kiwi_oemrecovery': False, 'kiwi_oemrecoveryPartSize': None, 'kiwi_oemrootMB': 2048, 'kiwi_oemshutdowninteractive': None, 'kiwi_oemresizeonce': None, 'kiwi_oemshutdown': None, 'kiwi_oemsilentboot': None, 'kiwi_oemsilentinstall': None, 'kiwi_oemsilentverify': None, 'kiwi_oemskipverify': 'true', 'kiwi_oemswapMB': None, 'kiwi_oemswap': None, 'kiwi_oemtitle': 'schäfer', 'kiwi_oemunattended_id': None, 'kiwi_oemunattended': None, 'kiwi_oemvmcp_parmfile': None, 'kiwi_profiles': '', 'kiwi_ramonly': True, 'kiwi_initrd_system': 'kiwi', 'kiwi_install_volid': 'INSTALL', 'kiwi_btrfs_root_is_snapshot': None, 'kiwi_gpt_hybrid_mbr': None, 'kiwi_showlicense': None, 'kiwi_splash_theme': 'openSUSE', 'kiwi_strip_delete': '', 'kiwi_strip_libs': '', 'kiwi_strip_tools': '', 'kiwi_target_blocksize': None, 'kiwi_timezone': 'Europe/Berlin', 'kiwi_type': 'oem', 'kiwi_vga': None, 'kiwi_startsector': 2048, 'kiwi_wwid_wait_timeout': None, 'kiwi_xendomain': 'dom0', 'kiwi_rootpartuuid': None } @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create_displayname_is_image_name(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_pxe_config.xml') profile = Profile(XMLState(description.load())) profile.create(self.profile_file) os.remove(self.tmpfile.name) os.remove(self.profile_file) assert profile.dot_profile['kiwi_displayname'] == \ 'LimeJeOS-openSUSE-13.2' @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create_cpio(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_dot_profile_config.xml') profile = Profile(XMLState(description.load(), None, 'cpio')) profile.create(self.profile_file) os.remove(self.tmpfile.name) os.remove(self.profile_file) assert profile.dot_profile['kiwi_cpio_name'] == \ 'LimeJeOS-openSUSE-13.2' def test_add(self): self.profile.add('foo', 'bar') assert self.profile.dot_profile['foo'] == 'bar' def test_delete(self): self.profile.add('foo', 'bar') self.profile.delete('foo') assert 'foo' not in self.profile.dot_profile
class TestProfile(object): def setup(self): self.tmpfile = mock.Mock() self.tmpfile.name = 'tmpfile' description = XMLDescription('../data/example_dot_profile_config.xml') self.profile = Profile( XMLState(description.load()) ) @patch('kiwi.system.profile.NamedTemporaryFile') def test_create(self, mock_temp): mock_temp.return_value = self.tmpfile result = self.profile.create() os.remove(self.tmpfile.name) print(self.profile.dot_profile) assert self.profile.dot_profile == { 'kiwi_allFreeVolume_bin_volume': 'size:all:LVusr_bin', 'kiwi_allFreeVolume_LVusr_bin': 'size:all', 'kiwi_bootkernel': None, 'kiwi_bootloader': 'grub2', 'kiwi_bootprofile': None, 'kiwi_boot_timeout': None, 'kiwi_cmdline': 'splash', 'kiwi_compressed': None, 'kiwi_delete': '', 'kiwi_devicepersistency': None, 'kiwi_displayname': 'LimeJeOS-openSUSE-13.2', 'kiwi_drivers': '', 'kiwi_firmware': 'efi', 'kiwi_fsmountoptions': None, 'kiwi_hwclock': 'utc', 'kiwi_hybrid': True, 'kiwi_hybridpersistent_filesystem': None, 'kiwi_hybridpersistent': None, 'kiwi_iname': 'LimeJeOS-openSUSE-13.2', 'kiwi_installboot': None, 'kiwi_iversion': '1.13.2', 'kiwi_keytable': 'us.map.gz', 'kiwi_language': 'en_US', 'kiwi_loader_theme': 'openSUSE', 'kiwi_LVM_etc_volume': 'freespace:30:LVetc', 'kiwi_lvmgroup': None, 'kiwi_LVM_LVRoot': 'freespace:500', 'kiwi_LVM_LVusr_lib': 'size:1024', 'kiwi_lvm': 'true', 'kiwi_lvmgroup': 'systemVG', 'kiwi_oemataraid_scan': None, 'kiwi_oembootwait': None, 'kiwi_oemdevicefilter': None, 'kiwi_oemkboot': None, 'kiwi_oemmultipath_scan': None, 'kiwi_oempartition_install': None, 'kiwi_oemrebootinteractive': None, 'kiwi_oemreboot': None, 'kiwi_oemrecoveryID': None, 'kiwi_oemrecoveryInPlace': None, 'kiwi_oemrecovery': False, 'kiwi_oemrecoveryPartSize': None, 'kiwi_oemrootMB': 2048, 'kiwi_oemshutdowninteractive': None, 'kiwi_oemshutdown': None, 'kiwi_oemsilentboot': None, 'kiwi_oemsilentinstall': None, 'kiwi_oemsilentverify': None, 'kiwi_oemskipverify': None, 'kiwi_oemswapMB': None, 'kiwi_oemswap': 'true', 'kiwi_oemtitle': None, 'kiwi_oemunattended_id': None, 'kiwi_oemunattended': None, 'kiwi_oemvmcp_parmfile': None, 'kiwi_profiles': '', 'kiwi_ramonly': None, 'kiwi_btrfs_root_is_snapshot': None, 'kiwi_gpt_hybrid_mbr': None, 'kiwi_showlicense': None, 'kiwi_splash_theme': 'openSUSE', 'kiwi_strip_delete': '', 'kiwi_strip_libs': '', 'kiwi_strip_tools': '', 'kiwi_target_blocksize': None, 'kiwi_timezone': 'Europe/Berlin', 'kiwi_type': 'oem', 'kiwi_vga': None, 'kiwi_wwid_wait_timeout': None, 'kiwi_xendomain': None } assert result == [ "kiwi_LVM_LVRoot='freespace:500'", "kiwi_LVM_LVusr_lib='size:1024'", "kiwi_LVM_etc_volume='freespace:30:LVetc'", "kiwi_allFreeVolume_LVusr_bin='size:all'", "kiwi_allFreeVolume_bin_volume='size:all:LVusr_bin'", "kiwi_bootloader='grub2'", "kiwi_cmdline='splash'", "kiwi_displayname='LimeJeOS-openSUSE-13.2'", "kiwi_firmware='efi'", "kiwi_hwclock='utc'", "kiwi_hybrid='true'", "kiwi_iname='LimeJeOS-openSUSE-13.2'", "kiwi_iversion='1.13.2'", "kiwi_keytable='us.map.gz'", "kiwi_language='en_US'", "kiwi_loader_theme='openSUSE'", "kiwi_lvm='true'", "kiwi_lvmgroup='systemVG'", "kiwi_oemrootMB='2048'", "kiwi_oemswap='true'", "kiwi_splash_theme='openSUSE'", "kiwi_timezone='Europe/Berlin'", "kiwi_type='oem'" ] @patch('kiwi.system.profile.NamedTemporaryFile') @patch('builtins.open') @patch('kiwi.system.shell.Shell.quote_key_value_file') def test_create_cpio(self, mock_shell_quote, mock_open, mock_temp): mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_dot_profile_config.xml') profile = Profile( XMLState(description.load(), None, 'cpio') ) profile.create() assert profile.dot_profile['kiwi_cpio_name'] == 'LimeJeOS-openSUSE-13.2' def test_add(self): self.profile.add('foo', 'bar') assert self.profile.dot_profile['foo'] == 'bar'
class TestProfile(object): def setup(self): self.tmpfile = mock.Mock() self.tmpfile.name = 'tmpfile' description = XMLDescription('../data/example_dot_profile_config.xml') self.profile = Profile( XMLState(description.load()) ) @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile result = self.profile.create() os.remove(self.tmpfile.name) assert self.profile.dot_profile == { 'kiwi_Volume_1': 'usr_lib|size:1024|usr/lib', 'kiwi_Volume_2': 'LVRoot|freespace:500|', 'kiwi_Volume_3': 'etc_volume|freespace:30|etc', 'kiwi_Volume_4': 'bin_volume|size:all|/usr/bin', 'kiwi_Volume_5': 'usr_bin|size:all|usr/bin', 'kiwi_bootkernel': None, 'kiwi_bootloader': 'grub2', 'kiwi_bootprofile': None, 'kiwi_target_removable': None, 'kiwi_boot_timeout': None, 'kiwi_cmdline': 'splash', 'kiwi_compressed': None, 'kiwi_delete': '', 'kiwi_devicepersistency': None, 'kiwi_bootloader_console': None, 'kiwi_displayname': 'schäfer', 'kiwi_drivers': '', 'kiwi_firmware': 'efi', 'kiwi_fsmountoptions': None, 'kiwi_hybridpersistent_filesystem': None, 'kiwi_hybridpersistent': None, 'kiwi_iname': 'LimeJeOS-openSUSE-13.2', 'kiwi_installboot': None, 'kiwi_iversion': '1.13.2', 'kiwi_keytable': 'us.map.gz', 'kiwi_language': 'en_US', 'kiwi_loader_theme': 'openSUSE', 'kiwi_lvm': 'true', 'kiwi_lvmgroup': 'systemVG', 'kiwi_oemataraid_scan': None, 'kiwi_oembootwait': None, 'kiwi_oemdevicefilter': None, 'kiwi_oemnicfilter': None, 'kiwi_oemkboot': None, 'kiwi_oemmultipath_scan': None, 'kiwi_oempartition_install': None, 'kiwi_oemrebootinteractive': None, 'kiwi_oemreboot': None, 'kiwi_oemrecoveryID': None, 'kiwi_oemrecoveryInPlace': None, 'kiwi_oemrecovery': False, 'kiwi_oemrecoveryPartSize': None, 'kiwi_oemrootMB': 2048, 'kiwi_oemshutdowninteractive': None, 'kiwi_oemshutdown': None, 'kiwi_oemsilentboot': None, 'kiwi_oemsilentinstall': None, 'kiwi_oemsilentverify': None, 'kiwi_oemskipverify': None, 'kiwi_oemswapMB': None, 'kiwi_oemswap': 'true', 'kiwi_oemtitle': 'schäfer', 'kiwi_oemunattended_id': None, 'kiwi_oemunattended': None, 'kiwi_oemvmcp_parmfile': None, 'kiwi_profiles': '', 'kiwi_ramonly': True, 'kiwi_initrd_system': 'kiwi', 'kiwi_btrfs_root_is_snapshot': None, 'kiwi_gpt_hybrid_mbr': None, 'kiwi_showlicense': None, 'kiwi_splash_theme': 'openSUSE', 'kiwi_strip_delete': '', 'kiwi_strip_libs': '', 'kiwi_strip_tools': '', 'kiwi_target_blocksize': None, 'kiwi_timezone': 'Europe/Berlin', 'kiwi_type': 'oem', 'kiwi_vga': None, 'kiwi_startsector': 2048, 'kiwi_wwid_wait_timeout': None, 'kiwi_xendomain': 'dom0' } assert result == [ "kiwi_Volume_1='usr_lib|size:1024|usr/lib'", "kiwi_Volume_2='LVRoot|freespace:500|'", "kiwi_Volume_3='etc_volume|freespace:30|etc'", "kiwi_Volume_4='bin_volume|size:all|/usr/bin'", "kiwi_Volume_5='usr_bin|size:all|usr/bin'", "kiwi_bootloader='grub2'", "kiwi_cmdline='splash'", "kiwi_displayname='schäfer'", "kiwi_firmware='efi'", "kiwi_iname='LimeJeOS-openSUSE-13.2'", "kiwi_initrd_system='kiwi'", "kiwi_iversion='1.13.2'", "kiwi_keytable='us.map.gz'", "kiwi_language='en_US'", "kiwi_loader_theme='openSUSE'", "kiwi_lvm='true'", "kiwi_lvmgroup='systemVG'", "kiwi_oemrootMB='2048'", "kiwi_oemswap='true'", "kiwi_oemtitle='schäfer'", "kiwi_ramonly='true'", "kiwi_splash_theme='openSUSE'", "kiwi_startsector='2048'", "kiwi_timezone='Europe/Berlin'", "kiwi_type='oem'", "kiwi_xendomain='dom0'" ] @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create_displayname_is_image_name(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_pxe_config.xml') profile = Profile( XMLState(description.load()) ) profile.create() os.remove(self.tmpfile.name) assert profile.dot_profile['kiwi_displayname'] == 'LimeJeOS-openSUSE-13.2' @patch('kiwi.system.profile.NamedTemporaryFile') @patch('kiwi.path.Path.which') def test_create_cpio(self, mock_which, mock_temp): mock_which.return_value = 'cp' mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_dot_profile_config.xml') profile = Profile( XMLState(description.load(), None, 'cpio') ) profile.create() os.remove(self.tmpfile.name) assert profile.dot_profile['kiwi_cpio_name'] == 'LimeJeOS-openSUSE-13.2' def test_add(self): self.profile.add('foo', 'bar') assert self.profile.dot_profile['foo'] == 'bar' def test_delete(self): self.profile.add('foo', 'bar') self.profile.delete('foo') assert 'foo' not in self.profile.dot_profile
class TestProfile(object): def setup(self): self.tmpfile = mock.Mock() self.tmpfile.name = 'tmpfile' description = XMLDescription('../data/example_dot_profile_config.xml') self.profile = Profile(XMLState(description.load())) @patch('kiwi.system.profile.NamedTemporaryFile') def test_create(self, mock_temp): mock_temp.return_value = self.tmpfile result = self.profile.create() os.remove(self.tmpfile.name) print(self.profile.dot_profile) assert self.profile.dot_profile == { 'kiwi_allFreeVolume_bin_volume': 'size:all:LVusr_bin', 'kiwi_allFreeVolume_LVusr_bin': 'size:all', 'kiwi_bootkernel': None, 'kiwi_bootloader': 'grub2', 'kiwi_bootprofile': None, 'kiwi_boot_timeout': None, 'kiwi_cmdline': 'splash', 'kiwi_compressed': None, 'kiwi_delete': '', 'kiwi_devicepersistency': None, 'kiwi_bootloader_console': None, 'kiwi_displayname': 'LimeJeOS-openSUSE-13.2', 'kiwi_drivers': '', 'kiwi_firmware': 'efi', 'kiwi_fsmountoptions': None, 'kiwi_hwclock': 'utc', 'kiwi_hybrid': True, 'kiwi_hybridpersistent_filesystem': None, 'kiwi_hybridpersistent': None, 'kiwi_iname': 'LimeJeOS-openSUSE-13.2', 'kiwi_installboot': None, 'kiwi_iversion': '1.13.2', 'kiwi_keytable': 'us.map.gz', 'kiwi_language': 'en_US', 'kiwi_loader_theme': 'openSUSE', 'kiwi_LVM_etc_volume': 'freespace:30:LVetc', 'kiwi_LVM_LVRoot': 'freespace:500', 'kiwi_LVM_LVusr_lib': 'size:1024', 'kiwi_lvm': 'true', 'kiwi_lvmgroup': 'systemVG', 'kiwi_oemataraid_scan': None, 'kiwi_oembootwait': None, 'kiwi_oemdevicefilter': None, 'kiwi_oemkboot': None, 'kiwi_oemmultipath_scan': None, 'kiwi_oempartition_install': None, 'kiwi_oemrebootinteractive': None, 'kiwi_oemreboot': None, 'kiwi_oemrecoveryID': None, 'kiwi_oemrecoveryInPlace': None, 'kiwi_oemrecovery': False, 'kiwi_oemrecoveryPartSize': None, 'kiwi_oemrootMB': 2048, 'kiwi_oemshutdowninteractive': None, 'kiwi_oemshutdown': None, 'kiwi_oemsilentboot': None, 'kiwi_oemsilentinstall': None, 'kiwi_oemsilentverify': None, 'kiwi_oemskipverify': None, 'kiwi_oemswapMB': None, 'kiwi_oemswap': 'true', 'kiwi_oemtitle': None, 'kiwi_oemunattended_id': None, 'kiwi_oemunattended': None, 'kiwi_oemvmcp_parmfile': None, 'kiwi_profiles': '', 'kiwi_ramonly': None, 'kiwi_initrd_system': None, 'kiwi_btrfs_root_is_snapshot': None, 'kiwi_gpt_hybrid_mbr': None, 'kiwi_showlicense': None, 'kiwi_splash_theme': 'openSUSE', 'kiwi_strip_delete': '', 'kiwi_strip_libs': '', 'kiwi_strip_tools': '', 'kiwi_target_blocksize': None, 'kiwi_timezone': 'Europe/Berlin', 'kiwi_type': 'oem', 'kiwi_vga': None, 'kiwi_wwid_wait_timeout': None, 'kiwi_xendomain': None } assert result == [ "kiwi_LVM_LVRoot='freespace:500'", "kiwi_LVM_LVusr_lib='size:1024'", "kiwi_LVM_etc_volume='freespace:30:LVetc'", "kiwi_allFreeVolume_LVusr_bin='size:all'", "kiwi_allFreeVolume_bin_volume='size:all:LVusr_bin'", "kiwi_bootloader='grub2'", "kiwi_cmdline='splash'", "kiwi_displayname='LimeJeOS-openSUSE-13.2'", "kiwi_firmware='efi'", "kiwi_hwclock='utc'", "kiwi_hybrid='true'", "kiwi_iname='LimeJeOS-openSUSE-13.2'", "kiwi_iversion='1.13.2'", "kiwi_keytable='us.map.gz'", "kiwi_language='en_US'", "kiwi_loader_theme='openSUSE'", "kiwi_lvm='true'", "kiwi_lvmgroup='systemVG'", "kiwi_oemrootMB='2048'", "kiwi_oemswap='true'", "kiwi_splash_theme='openSUSE'", "kiwi_timezone='Europe/Berlin'", "kiwi_type='oem'" ] @patch('kiwi.system.profile.NamedTemporaryFile') def test_create_cpio(self, mock_temp): mock_temp.return_value = self.tmpfile description = XMLDescription('../data/example_dot_profile_config.xml') profile = Profile(XMLState(description.load(), None, 'cpio')) profile.create() os.remove(self.tmpfile.name) assert profile.dot_profile[ 'kiwi_cpio_name'] == 'LimeJeOS-openSUSE-13.2' def test_add(self): self.profile.add('foo', 'bar') assert self.profile.dot_profile['foo'] == 'bar' def test_delete(self): self.profile.add('foo', 'bar') self.profile.delete('foo') assert 'foo' not in self.profile.dot_profile