How to use the kiwi.command.Command.run function in kiwi

To help you get started, we’ve selected a few kiwi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OSInside / kiwi / kiwi / storage / subformat / vdi.py View on Github external
def create_image_format(self):
        """
        Create vdi disk format
        """
        Command.run(
            [
                'qemu-img', 'convert', '-f', 'raw', self.diskname,
                '-O', self.image_format
            ] + self.options + [
                self.get_target_file_path_for_format(self.image_format)
            ]
github OSInside / kiwi / kiwi / bootloader / config / grub2.py View on Github external
def _create_embedded_fat_efi_image(self):
        Path.create(self.boot_dir + '/boot/' + self.arch)
        efi_fat_image = ''.join(
            [self.boot_dir + '/boot/', self.arch, '/efi']
        )
        Command.run(
            ['qemu-img', 'create', efi_fat_image, '15M']
        )
        Command.run(
            ['mkdosfs', '-n', 'BOOT', efi_fat_image]
        )
        Command.run(
            [
                'mcopy', '-Do', '-s', '-i', efi_fat_image,
                self.boot_dir + '/EFI', '::'
            ]
github OSInside / kiwi / kiwi / storage / disk.py View on Github external
]
            )
            try:
                Command.run(
                    ['bash', '-c', bash_command]
                )
            except Exception:
                # unfortunately fdasd reports that it can't read in the
                # partition table which I consider a bug in fdasd. However
                # the table was correctly created and therefore we continue.
                # Problem is that we are not able to detect real errors
                # with the fdasd operation at that point.
                log.debug('potential fdasd errors were ignored')
        else:
            log.debug('Initialize %s disk', self.table_type)
            Command.run(
                [
                    'sgdisk', '--zap-all', self.storage_provider.get_device()
                ]
github OSInside / kiwi / kiwi / system / users.py View on Github external
def setup_home_for_user(self, user_name, group_name, home_path):
        """
        Setup user home directory

        :param str user_name: user name
        :param str group_name: group name
        :param str home_path: path name
        """
        user_and_group = user_name + ':' + group_name
        Command.run(
            ['chroot', self.root_dir, 'chown', '-R', user_and_group, home_path]
        )
github OSInside / kiwi / kiwi / system / size.py View on Github external
def accumulate_files(self):
        """
        Calculate sum of all files in the source tree

        :return: number of files

        :rtype: int
        """
        bash_comand = [
            'find', self.source_dir, '|', 'wc', '-l'
        ]
        wc_call = Command.run(
            [
                'bash', '-c', ' '.join(bash_comand)
            ]
        )
        return int(wc_call.output.rstrip('\n'))
github OSInside / kiwi / kiwi / package_manager / dnf.py View on Github external
def process_delete_requests(self, force=False):
        """
        Process package delete requests (chroot)

        :param bool force: force deletion: true|false

        :raises KiwiRequestError: if none of the packages to delete is
            installed.
        :return: process results in command type

        :rtype: namedtuple
        """
        delete_items = []
        for delete_item in self.package_requests:
            try:
                Command.run(['chroot', self.root_dir, 'rpm', '-q', delete_item])
                delete_items.append(delete_item)
            except Exception:
                # ignore packages which are not installed
                pass
        if not delete_items:
            raise KiwiRequestError(
                'None of the requested packages to delete are installed'
            )
        self.cleanup_requests()
        if force:
            delete_options = ['--nodeps', '--allmatches', '--noscripts']
            return Command.call(
                [
                    'chroot', self.root_dir, 'rpm', '-e'
                ] + delete_options + delete_items,
                self.command_env
github OSInside / kiwi / kiwi / utils / compress.py View on Github external
def get_format(self):
        """
        Detect compression format

        :return: compression format name or None if it couldn't be inferred

        :rtype: Optional[str]
        """
        for zipper in self.supported_zipper:
            cmd = [zipper, '-l', self.source_filename]
            try:
                Command.run(cmd)
                return zipper
            except Exception as exc:
                log.debug(
                    'Error running "{cmd:s}", got a {exc_t:s}: {exc:s}'
                    .format(
                        cmd=' '.join(cmd),
                        exc_t=type(exc).__name__,
                        exc=str(exc)
                    )
github OSInside / kiwi / kiwi / system / setup.py View on Github external
appropriate permission definitions from the /etc/permissions*
        files. It's possible to provide those files as overlay files
        in the image description to apply a certain permission setup
        when needed. Otherwise the default setup as provided on the
        package level applies.

        It's required that the image root system has chkstat installed.
        If not present KIWI skips this step and continuous with a
        warning.
        """
        chkstat = Path.which(
            'chkstat', root_dir=self.root_dir, access_mode=os.X_OK
        )
        if chkstat:
            log.info('Check/Fix File Permissions')
            Command.run(
                ['chroot', self.root_dir, 'chkstat', '--system', '--set']
            )
        else:
            log.warning(
                'chkstat not found in image. File Permissions Check skipped'
            )
github OSInside / kiwi / kiwi / partitioner / dasd.py View on Github external
self.partition_id += 1
        fdasd_input = NamedTemporaryFile()
        with open(fdasd_input.name, 'w') as partition:
            log.debug(
                '%s: fdasd: n p cur_position +%sM w q',
                name, format(mbsize)
            )
            if mbsize == 'all_free':
                partition.write('n\np\n\n\nw\nq\n')
            else:
                partition.write('n\np\n\n+%dM\nw\nq\n' % mbsize)
        bash_command = ' '.join(
            ['cat', fdasd_input.name, '|', 'fdasd', '-f', self.disk_device]
        )
        try:
            Command.run(
                ['bash', '-c', bash_command]
            )
        except Exception:
            # unfortunately fdasd reports that it can't read in the partition
            # table which I consider a bug in fdasd. However the table was
            # correctly created and therefore we continue. Problem is that we
            # are not able to detect real errors with the fdasd operation at
            # that point.
            log.debug('potential fdasd errors were ignored')
github OSInside / kiwi / kiwi / utils / block.py View on Github external
def get_blkid(self, id_type):
        """
        Retrieve information for specified metadata ID from block device

        :param string id_type: metadata ID, see man blkid for details

        :return: ID of the block device

        :rtype: str
        """
        blkid_result = Command.run(
            ['blkid', self.device, '-s', id_type, '-o', 'value']
        )
        return blkid_result.output.strip(os.linesep)