示例#1
0
文件: binrepo.py 项目: boklm/mgarepo
def binary_exists(sha1sum):
    dlurl = config.get("binrepo", "download_url",
	    "http://binrepo.mageia.org/")
    dlurl = mirror.normalize_path(dlurl + "/" + sha1sum)
    h = httplib2.Http()
    resp, content = h.request(dlurl, 'HEAD')
    return resp.status == 200
示例#2
0
def package_url(name_or_url, version=None, release=None, distro=None,
        mirrored=True):
    """Returns a tuple with the absolute package URL and its name

    @name_or_url: name, relative path, or URL of the package. In case it is
                  a URL, the URL will just be 'normalized'.
    @version: the version to be fetched from releases/ (requires release)
    @release: the release number to be fetched from releases/$version/
    @distro: the name of the repository branch inside updates/
    @mirrored: return an URL based on the mirror repository, if enabled
    """
    from MgaRepo import mirror
    if "://" in name_or_url:
        pkgdirurl = mirror.normalize_path(name_or_url)
        pkgdirurl = remove_current(pkgdirurl)
        if mirror.using_on(pkgdirurl) and not mirrored:
            pkgdirurl = mirror.relocate_path(mirror.mirror_url(),
                    repository_url(), pkgdirurl)
    else:
        name = name_or_url
        devel_branch, branches_dir = layout_dirs()
        if distro or "/" in name:
            default_branch = branches_dir
            if distro:
                default_branch = os.path.join(default_branch, distro)
        else:
            default_branch = devel_branch # cauldron
        path = os.path.join(default_branch, name)
        parsed = list(urlparse.urlparse(repository_url(mirrored=mirrored)))
        parsed[2] = os.path.join(parsed[2], path)
        pkgdirurl = urlparse.urlunparse(parsed)
    return pkgdirurl
示例#3
0
文件: binrepo.py 项目: boklm/mgarepo
def download_binary(topdir, sha1, filename):
    fmt = config.get("global", "download-command",
	    "wget -c -O '$dest' $url")
    url = config.get("binrepo", "download_url",
	    "http://binrepo.mageia.org/")
    url = mirror.normalize_path(url + "/" + sha1)
    dest = os.path.join(topdir, 'SOURCES', filename)
    if os.path.exists(dest):
	if file_hash(dest) == sha1:
	    return 1
	else:
	    raise Error, "File with incorrect sha1sum: %s" % dest
    context = {"dest": dest, "url": url}
    try:
	cmd = string.Template(fmt).substitute(context)
    except KeyError, e:
	raise Error, "invalid variable %r in download-command "\
		"configuration option" % e