aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-08-17 16:11:33 +0000
committerNicolas Vigier <boklm@mageia.org>2011-08-17 16:11:33 +0000
commit457131580c3e3f5387d72c4811d81e8ddb3c45f4 (patch)
treefaf0db227992205a00600bdf12c0f662a3efe488 /MgaRepo
parent05733acd4c7a9de98156378045d4e4050cfb65db (diff)
downloadmgarepo-457131580c3e3f5387d72c4811d81e8ddb3c45f4.tar
mgarepo-457131580c3e3f5387d72c4811d81e8ddb3c45f4.tar.gz
mgarepo-457131580c3e3f5387d72c4811d81e8ddb3c45f4.tar.bz2
mgarepo-457131580c3e3f5387d72c4811d81e8ddb3c45f4.tar.xz
mgarepo-457131580c3e3f5387d72c4811d81e8ddb3c45f4.zip
add function to upload binary file
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/binrepo.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py
index 8480fd3..f76584b 100644
--- a/MgaRepo/binrepo.py
+++ b/MgaRepo/binrepo.py
@@ -1,5 +1,5 @@
from MgaRepo import Error, config, mirror, layout
-from MgaRepo.util import execcmd, rellink
+from MgaRepo.util import execcmd, rellink, get_helper
from MgaRepo.svn import SVN
import sys
@@ -12,6 +12,7 @@ import tempfile
import hashlib
import urlparse
import threading
+import httplib2
from cStringIO import StringIO
DEFAULT_TARBALLS_REPO = "/tarballs"
@@ -130,7 +131,7 @@ def find_binaries(paths):
def download_binary(topdir, sha1, filename):
fmt = config.get("global", "download-command",
"wget -c -O '$dest' $url")
- url = config.get("global", "binrepo",
+ url = config.get("binrepo", "download_url",
"http://binrepo.mageia.org/")
url = mirror.normalize_path(url + "/" + sha1)
dest = os.path.join(topdir, 'SOURCES', filename)
@@ -155,6 +156,27 @@ def download_binaries(topdir):
for name, sha1 in entries.iteritems():
download_binary(topdir, sha1, name)
+def upload_binary(topdir, filename):
+ filepath = os.path.join(topdir, 'SOURCES', filename)
+ if not os.path.exists(filepath):
+ raise Error, "'%s' was not found" % spath
+ sha1sum = file_hash(filepath)
+ 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')
+ if resp.status == 200:
+ return
+ host = config.get("binrepo", "upload_host")
+ upload_bin_helper = get_helper("upload-bin")
+ command = "ssh %s %s %s" % (host, upload_bin_helper, filename)
+ try:
+ filein = open(filepath, 'r')
+ except Error, e:
+ raise Error, "Could not open file %s\n" % filepath
+ status, output = execcmd(command, show=True, geterr=True, stdin=filein)
+
def make_symlinks(source, dest):
todo = []
tomove = []