def _parse_control_depends(fields):
    """
    Parse the package names of the 'Depends:' directive in a debian control file.

    References:
        https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-controlsyntax
        https://www.debian.org/doc/debian-policy/ch-relationships.html#declaring-relationships-between-packages

    Args:
        fields: a parsed map of field strings from a debian control file.
    Returns:
        A list of package names from the control file Depends directive.
    """
    depends = []

    for entry in [fields.get("Depends", None), fields.get("Pre-Depends", None)]:
        # Skip the fields if they were empty.
        if not entry:
            continue

        # Remove newlines, these are 'folded' fields so newlines are ignored.
        line = entry.replace("\n", "").replace("\r", "")

        # Move through each section extracting the packages names.
        for section in entry.split(","):
            for alternative in section.split("|"):
                depend = alternative.strip().split(" ", 1)[0]
                if depend not in depends:
                    depends.append(depend)

    return depends