pkgcore.merge.engine module

core engine for livefs modifications

class pkgcore.merge.engine.MergeEngine(mode, tempdir, hooks, csets, preserves, observer, offset=None, disable_plugins=False, parallelism=None)[source]

Bases: object

add_cset(cset_name, func)[source]

Regiser a cset generator for use.

The cset will be released from memory when it’s no longer used.

Parameters:
  • cset_name – what to call the generated cset

  • func – callable to get the cset

add_preserved_cset(cset_name, func)[source]

Register a cset generator for use.

The cset will stay in memory until the engine finishes all steps.

Parameters:
  • cset_name – what to call the generated cset

  • func – callable to get the cset

add_trigger(hook_name, trigger, required_csets)[source]

Register a pkgcore.merge.triggers.base instance to be executed.

Parameters:
static alias_cset(alias, engine, csets)

alias a cset to another

allow_reuse = True
execute_hook(hook)[source]

Execute any triggers bound to a hook point.

static generate_offset_cset(engine, csets, cset_generator)[source]

Generate a cset with offset applied.

static get_install_livefs_intersect(engine, csets)[source]
get_merged_cset(strip_offset=True)[source]
static get_pkg_contents(engine, csets, pkg)[source]

Generate the cset of what files shall be merged to the livefs.

static get_remove_cset(engine, csets)[source]

Generate the cset of what files shall be removed from the livefs.

static get_replace_cset(engine, csets)[source]

Return the cset of what will be replaced going from old->new pkg.

static get_uninstall_livefs_intersect(engine, csets)[source]
get_writable_fsobj(fsobj, prefer_reuse=True, empty=False)[source]
classmethod install(tempdir, pkg, offset=None, observer=None, disable_plugins=False)[source]

Generate a MergeEngine instance configured for installing a pkg.

Parameters:
  • tempdir – tempspace for the merger to use; this space it must control alone, no sharing.

  • pkgpkgcore.package.metadata.package instance to install

  • offset – any livefs offset to force for modifications

  • disable_plugins – if enabled, run just the triggers passed in

Returns:

MergeEngine

install_csets = {'install': functools.partial(<function alias_cset>, 'new_cset'), 'install_existing': 'get_install_livefs_intersect', 'new_cset': functools.partial(<function alias_cset>, 'raw_new_cset'), 'replace': functools.partial(<function alias_cset>, 'new_cset'), 'resolved_install': <function map_new_cset_livefs>}
install_csets_preserve = ['new_cset']
install_hooks = {'final': [], 'merge': [], 'post_merge': [], 'pre_merge': [], 'sanity_check': []}
regenerate_csets()[source]

Internal function, reset non preserverd csets.

Used in transitioning between hook points

classmethod replace(tempdir, old, new, offset=None, observer=None, disable_plugins=False)[source]

Generate a MergeEngine instance configured for replacing a pkg.

Parameters:
  • tempdir – tempspace for the merger to use; this space it must control alone, no sharing.

  • oldpkgcore.package.metadata.package instance to replace, must be from a livefs vdb

  • newpkgcore.package.metadata.package instance

  • offset – any livefs offset to force for modifications

  • disable_plugins – if enabled, run just the triggers passed in

Returns:

MergeEngine

replace_cset(name, new_cset)[source]

Replace the cset referenced by this engine.

Use only if you know what you’re doing.

Parameters:

name – name of the cset

New_cset:

a contentsSet instance to use

replace_csets = {'install': functools.partial(<function alias_cset>, 'new_cset'), 'install_existing': 'get_install_livefs_intersect', 'modifying': <function MergeEngine.<lambda>>, 'new_cset': functools.partial(<function alias_cset>, 'raw_new_cset'), 'old_cset': 'get_uninstall_livefs_intersect', 'replace': 'get_replace_cset', 'resolved_install': <function map_new_cset_livefs>, 'uninstall': 'get_remove_cset', 'uninstall_existing': functools.partial(<function alias_cset>, 'uninstall')}
replace_csets_preserve = ['new_cset', 'old_cset']
replace_hooks = {'final': [], 'merge': [], 'post_merge': [], 'post_unmerge': [], 'pre_merge': [], 'pre_unmerge': [], 'sanity_check': [], 'unmerge': []}
classmethod uninstall(tempdir, pkg, offset=None, observer=None, disable_plugins=False)[source]

Generate a MergeEngine instance configured for uninstalling a pkg.

Parameters:
  • tempdir – tempspace for the merger to use; this space it must control alone, no sharing.

  • pkgpkgcore.package.metadata.package instance to uninstall, must be from a livefs vdb

  • offset – any livefs offset to force for modifications

  • disable_plugins – if enabled, run just the triggers passed in

Returns:

MergeEngine

uninstall_csets = {'old_cset': 'get_uninstall_livefs_intersect', 'uninstall': functools.partial(<function alias_cset>, 'old_cset'), 'uninstall_existing': functools.partial(<function alias_cset>, 'uninstall')}
uninstall_csets_preserve = ['old_cset']
uninstall_hooks = {'final': [], 'post_unmerge': [], 'pre_unmerge': [], 'sanity_check': [], 'unmerge': []}
pkgcore.merge.engine.alias_cset(alias, engine, csets)[source]

alias a cset to another

pkgcore.merge.engine.map_new_cset_livefs(engine, csets, cset_name='new_cset')[source]

Find symlinks on disk that redirect new_cset, and return a livefs localized cset.