From d8a6cc7ef7ec79d9eaa26e18dcc7dea74ad7b985 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Wed, 17 Aug 2011 12:23:48 +0000 Subject: add functions to download from new binrepo --- MgaRepo/binrepo.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'MgaRepo/binrepo.py') diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py index 2a6f437..8480fd3 100644 --- a/MgaRepo/binrepo.py +++ b/MgaRepo/binrepo.py @@ -127,6 +127,34 @@ def find_binaries(paths): new.append(path) return new +def download_binary(topdir, sha1, filename): + fmt = config.get("global", "download-command", + "wget -c -O '$dest' $url") + url = config.get("global", "binrepo", + "http://binrepo.mageia.org/") + url = mirror.normalize_path(url + "/" + sha1) + dest = os.path.join(topdir, 'SOURCES', filename) + if os.path.exists(dest): + return 1 + 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 + try: + status, output = execcmd(cmd, show=True) + except Error, e: + raise Error, "Could not download file %s\n" % url + +def download_binaries(topdir): + spath = sources_path(topdir) + if not os.path.exists(spath): + raise Error, "'%s' was not found" % spath + entries = parse_sources(spath) + for name, sha1 in entries.iteritems(): + download_binary(topdir, sha1, name) + def make_symlinks(source, dest): todo = [] tomove = [] -- cgit v1.2.1