Checkout/update a buildpack, given its URL.

    Buildpacks are checked out into folders whose names start with something
    nicely readable, followed by an MD5 hash of the full URL (thus
    distinguishing two buildpacks with the same 'name' but different URLs).

def update_buildpack(url, packs_dir=PACKS_HOME, vcs_type=None):
    """
    Checkout/update a buildpack, given its URL.

    Buildpacks are checked out into folders whose names start with something
    nicely readable, followed by an MD5 hash of the full URL (thus
    distinguishing two buildpacks with the same 'name' but different URLs).
    """
    defrag = _defrag(urllib.parse.urldefrag(url))
    bpfolder = repo.basename(url) + '-' + hash_text(defrag.url)
    dest = os.path.join(packs_dir, bpfolder)
    # TODO: check for whether the buildpack in the folder is really the same as
    # the one we've been asked to add.
    mkdir(packs_dir)
    bp = BuildPack(dest, url, vcs_type=vcs_type)
    bp.update()
    return bp