def get_relative_path_to_pack_file(pack_ref, file_path, use_pack_cache=False):
    """
    Retrieve a file path which is relative to the provided pack directory.

    :param pack_ref: Pack reference.
    :type pack_ref: ``str``

    :param file_path: Full absolute path to a pack file.
    :type file_path: ``str``

    :rtype: ``str``
    """
    pack_base_path = get_pack_base_path(
        pack_name=pack_ref, use_pack_cache=use_pack_cache
    )

    if not os.path.isabs(file_path):
        return file_path

    file_path = os.path.abspath(file_path)

    common_prefix = os.path.commonprefix([pack_base_path, file_path])
    if common_prefix != pack_base_path:
        raise ValueError(
            "file_path (%s) is not located inside the pack directory (%s)"
            % (file_path, pack_base_path)
        )

    relative_path = os.path.relpath(file_path, common_prefix)
    return relative_path

    Retrieve a file path which is relative to the provided pack directory.

    :param pack_ref: Pack reference.
    :type pack_ref: ``str``

    :param file_path: Full absolute path to a pack file.
    :type file_path: ``str``

    :rtype: ``str``
    
st2common/st2common/content/utils.py