def get_cpu_value(repository_ctx):
    """Compute the cpu_value based on the OS name. Doesn't %-escape the result!

    Args:
      repository_ctx: The repository context.
    Returns:
      One of (darwin, freebsd, x64_windows, ppc, s390x, arm, aarch64, k8, piii)
    """
    os_name = repository_ctx.os.name.lower()
    if os_name.startswith("mac os"):
        return "darwin"
    if os_name.find("freebsd") != -1:
        return "freebsd"
    if os_name.find("windows") != -1:
        return "x64_windows"

    # Use uname to figure out whether we are on x86_32 or x86_64
    result = repository_ctx.execute(["uname", "-m"])
    if result.stdout.strip() in ["power", "ppc64le", "ppc", "ppc64"]:
        return "ppc"
    if result.stdout.strip() in ["s390x"]:
        return "s390x"
    if result.stdout.strip() in ["arm", "armv7l"]:
        return "arm"
    if result.stdout.strip() in ["aarch64"]:
        return "aarch64"
    return "k8" if result.stdout.strip() in ["amd64", "x86_64", "x64"] else "piii"