def construct_package_url(base_url, dist, arch, sha256):
    """
    Construct a package URL for a debian package using the 'by-hash' path.

    See: https://wiki.debian.org/DebianRepository/Format#indices_acquisition_via_hashsums_.28by-hash.29
    Example: http://us.archive.ubuntu.com/ubuntu/dists/bionic/by-hash/SHA256/
    """
    return "{base_url}/dists/{dist}/binary-{arch}/by-hash/SHA256/{sha256}".format(
        base_url = base_url,
        dist = dist,
        arch = arch,
        sha256 = sha256,
    )