craft_parts.executor.collisions module

Helpers to detect conflicting staging files from multiple parts.

class craft_parts.executor.collisions.StageCandidate(part_name, contents, source_dir, permissions, is_overlay)[source]

Bases: object

Representation of a set of files and directories that want to be staged.

Parameters:
  • part_name (str)

  • contents (set[str])

  • source_dir (Path)

  • permissions (list[Permissions])

  • is_overlay (bool)

contents: set[str]
is_overlay: bool
part_name: str
permissions: list[Permissions]
source_dir: Path
craft_parts.executor.collisions.check_for_stage_collisions(part_list, partitions)[source]

Verify whether parts have conflicting files to stage.

If the partitions feature is enabled, then check if parts have conflicting files to

stage for each partition.

If the partitions feature is disabled, only check for conflicts in the default

stage directory.

Parameters:
  • part_list (list[Part]) – The list of parts to check.

  • partitions (list[str] | None) – An optional list of partition names.

Raises:
  • PartConflictError – If conflicts are found.

  • FeatureError – If partitions are specified but the feature is not enabled or if partitions are not specified and the feature is enabled.

Return type:

None

Simulate a symlink resolution (only one level).

We do not want to really resolve the symlink with os.path.realpath() since it might point to another symlink (and so on).

Convert the path as if were under rel_dirname and rel_dirname were at the root.

Parameters:
  • path (str)

  • rel_dirname (str)

Return type:

str

craft_parts.executor.collisions.paths_collide(path1, path2, permissions_path1=None, permissions_path2=None, *, rel_dirname='', path1_is_overlay=False, path2_is_overlay=False)[source]

Check whether the provided paths conflict to each other.

If both paths have Permissions definitions, they are considered to be conflicting if the permissions are incompatible (as defined by permissions.permissions_are_compatible()).

Parameters:
  • path1 (str) – Path of the first element to compare.

  • path2 (str) – Path of the second element to compare.

  • permissions_path1 (list[Permissions] | None) – The list of Permissions that affect path1.

  • permissions_path2 (list[Permissions] | None) – The list of Permissions that affect path2.

  • rel_dirname (str) – relative path of the directory the item is.

  • path1_is_overlay (bool) – Indicates if path1 comes from the overlay.

  • path2_is_overlay (bool) – Indicates if path2 comes from the overlay.

Return type:

bool