def _patch_squashfs(root_img, patched_img, *patches):
    with temp_util.temp_dir() as patch_dir:
        LOG.info("unsquash root image to temporary directory")
        subprocess.call(["unsquashfs", "-f", "-d", patch_dir, root_img])
        LOG.info("apply patch to root image")
        patch.patch_apply(patch_dir, patches)
        LOG.info("create new root.squashfs image")
        subprocess.call(["mksquashfs", patch_dir, patched_img])
Esempio n. 2
0
def patch_modules(revert=False):
    puppet_patch_dir = os.path.join(magic_consts.CWD, "patches", "puppet")
    patches = []
    for d in os.listdir(puppet_patch_dir):
        d = os.path.join(puppet_patch_dir, d)
        if not os.path.isdir(d):
            continue
        patches.append(os.path.join(d, "patch"))
    patch.patch_apply(magic_consts.PUPPET_DIR, patches, revert=revert)
Esempio n. 3
0
def patch_modules(revert=False):
    puppet_patch_dir = os.path.join(magic_consts.CWD, "patches", "puppet")
    patches = []
    for d in os.listdir(puppet_patch_dir):
        d = os.path.join(puppet_patch_dir, d)
        if not os.path.isdir(d):
            continue
        patches.append(os.path.join(d, "patch"))
    patch.patch_apply(magic_consts.PUPPET_DIR, patches, revert=revert)
Esempio n. 4
0
def apply_patches(container, prefix, *patches, **kwargs):
    """Apply set of patches to a container's filesystem"""
    revert = kwargs.pop('revert', False)
    # TODO: review all logic here to apply all preprocessing steps to patches
    # beforehand
    files = [os.path.join(prefix, f)
             for f in patch.get_filenames_from_patches(prefix, *patches)]
    if not files:
        LOG.warn("Nothing to patch!")
        return
    with tempfile.temp_dir(prefix='octane_docker_patches.') as tempdir:
        get_files_from_docker(container, files, tempdir)
        patch.patch_apply(os.path.join(tempdir, prefix), patches, revert)
        put_files_to_docker(container, "/", tempdir)