@staticmethod
def generate(config, spec):
    """Produce file block segments for packaging files."""
    for file_ in config.file_extras.files:
        if file_.file_type is not None:
            if file_.file_type_option is not None:
                file_directive = '%{1}({2}) /{0}'.format(file_.dest, file_.
                    file_type, file_.file_type_option)
            else:
                file_directive = '%{1} /{0}'.format(file_.dest, file_.file_type
                    )
        else:
            file_directive = '/{0}'.format(file_.dest)
        spec.blocks.install.append('mkdir -p "%{{buildroot}}/%(dirname {0})"'
            .format(file_.dest))
        spec.blocks.install.append('cp -R %{{SOURCE0}}/{0} %{{buildroot}}/{1}'
            .format(file_.src, file_.dest))
        spec.blocks.files.append(file_directive)
        spec.blocks.post.append(
            'chown -R %{{file_permissions_user}}:%{{file_permissions_group}} /{0}'
            .format(file_.dest))
    return spec
