craft_parts.executor.migration module¶
Handle the execution of built-in or user specified step commands.
- craft_parts.executor.migration.already_distributed(item, sub_path)[source]¶
Check if a file/dir is or is under a subpath already distributed to another partition.
- Parameters:
item (
Path)sub_path (
Path)
- Return type:
bool
- craft_parts.executor.migration.clean_backstage(*, part_name, shared_dir, part_states)[source]¶
Clean files added by a part to the backstage directory.
- Parameters:
part_name (
str)shared_dir (
Path)part_states (
dict[str,StageState])
- Return type:
None
Clean files added by a part to a shared directory.
- Parameters:
part_name (
str) – The name of the part that added the files.shared_dir (
Path) – The shared directory to remove files from.part_states (
dict[str,StepState]) – A dictionary mapping each part to the part’s state for the step corresponding to the area being cleaned.overlay_migration_state (
MigrationState|None) – The state of the overlay migration to step.partition (
str|None)
- Return type:
None
Remove migrated overlay files from a shared directory.
- Parameters:
state_file – The migration state file.
shared_dir (
Path) – The shared directory to remove files from.part_states (
dict[str,StepState]) – A dictionary mapping each part to the part’s state for the step corresponding to the area being cleaned.overlay_migration_state (
MigrationState|None)partition (
str|None)
- Return type:
None
- craft_parts.executor.migration.filter_all_whiteouts(files)[source]¶
List and filter all whiteout files.
Found whiteout files are to be removed from the provided sets of files.
- Parameters:
files (
set[str]) – The set of files to be verified.- Return type:
set[str]- Returns:
The set of filtered out whiteout files.
- craft_parts.executor.migration.filter_dangling_whiteouts(files, dirs, *, base_dir)[source]¶
Remove dangling whiteout file and directory names.
Names corresponding to dangling files and directories (i.e. without a backing file in the base layer to be whited out) are to be removed from the provided sets of files and directory names.
- Parameters:
files (
set[str]) – The set of files to be verified.dirs (
set[str]) – The set of directories to be verified.base_dir (
Path|None)
- Return type:
set[str]- Returns:
The set of filtered out whiteout files.
- craft_parts.executor.migration.migrate_files(*, files, dirs, srcdir, destdir, missing_ok=False, follow_symlinks=False, oci_translation=False, fixup_func=<function <lambda>>, permissions=None)[source]¶
Copy or link files from a directory to another.
Files and directories are migrated from one step to the next during the lifecycle processing. Whenever possible, files are hard-linked instead of copied.
- Parameters:
files (
set[str]) – The set of files to migrate.dirs (
set[str]) – The set of directories to migrate.srcdir (
Path) – The directory containing entries to migrate.destdir (
Path) – The directory to migrate entries to.missing_ok (
bool) – Ignore entries that don’t exist.follow_symlinks (
bool) – Migrate symlink targets.oci_translation (
bool) – Convert to OCI whiteout files and opaque dirs.fixup_func (
Callable[...,None]) – A function to run on each migrated file.permissions (
list[Permissions] |None) – A list of permissions definitions to take into account when migrating the files (the original files are not modified).
- Return type:
tuple[set[str],set[str]]- Returns:
A tuple containing sets of migrated files and directories.