aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--MgaRepo/binrepo.py26
-rw-r--r--mgarepo.conf7
2 files changed, 30 insertions, 3 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 = []
diff --git a/mgarepo.conf b/mgarepo.conf
index 3b2f41b..f45aabf 100644
--- a/mgarepo.conf
+++ b/mgarepo.conf
@@ -2,7 +2,6 @@
[global]
repository = svn+ssh://svn.mageia.org/svn/packages/
trunk-dir = cauldron/
-binrepo = http://binrepo.mageia.org/
## uncomment it in case you don't have a account in the Mageia build system:
#mirror = http://svn.mageia.org/svn/packages/cauldron/
@@ -16,7 +15,13 @@ oldurl = svn+ssh://svn.mageia.org/svn/packages/misc
create-srpm = /usr/local/bin/submit_package
upload-srpm = /usr/local/bin/youri.devel
maintdb = /usr/local/bin/wrapper.maintdb
+upload-bin = /usr/local/bin/wrapper.upload-bin
[submit]
host = pkgsubmit.mageia.org
default = Cauldron
+
+[binrepo]
+download_url = http://binrepo.mageia.org/
+upload_host = binrepo.mageia.org
+