def maintdb(maintdb_args): host = config.get("maintdb", "host", "maintdb.mageia.org") maintdb_helper = get_helper("maintdb") cmd_args = ' '.join(maintdb_args) command = "ssh %s %s %s" % (host, maintdb_helper, cmd_args) execcmd(command, show=True) sys.exit(0)
def list_targets(option, opt, val, parser): host = config.get("submit", "host") if host is None: raise Error, "no submit host defined in mgarepo.conf" createsrpm = get_helper("create-srpm") #TODO make it configurable command = "ssh %s %s --list" % (host, createsrpm) execcmd(command, show=True) sys.exit(0)
def upload_binary(topdir, filename): filepath = os.path.join(topdir, 'SOURCES', filename) if not os.path.exists(filepath): raise Error, "'%s' was not found" % filepath sha1sum = file_hash(filepath) if binary_exists(sha1sum): 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
def submit(urls, target, define=[], submithost=None, atonce=False, sid=None): if submithost is None: submithost = config.get("submit", "host") if submithost is None: # extract the submit host from the svn host type, rest = urllib.splittype(pkgdirurl) host, path = urllib.splithost(rest) user, host = urllib.splituser(host) submithost, port = urllib.splitport(host) del type, user, port, path, rest # runs a create-srpm in the server through ssh, which will make a # copy of the rpm in the export directory createsrpm = get_helper("create-srpm") baseargs = ["ssh", submithost, createsrpm, "-t", target] if not sid: sid = uuid.uuid4() define.append("sid=%s" % sid) for entry in reversed(define): baseargs.append("--define") baseargs.append(entry) cmdsargs = [] if len(urls) == 1: # be compatible with server-side mgarepo versions older than 1.6.90 url, rev = layout.split_url_revision(urls[0]) baseargs.append("-r") baseargs.append(str(rev)) baseargs.append(url) cmdsargs.append(baseargs) elif atonce: cmdsargs.append(baseargs + urls) else: cmdsargs.extend((baseargs + [url]) for url in urls) for cmdargs in cmdsargs: command = subprocess.list2cmdline(cmdargs) status, output = execcmd(command) if status == 0: print "Package submitted!" else: sys.stderr.write(output) sys.exit(status)