The new argument for osc build --host will perform the build on a remote host. It is a shortcut for rsync -az -e ssh `pwd` user@hostname:/remote/dir ssh user@hostname "cd /remote/dir/package; osc build *build-args" iow it copy the current directory to the /remote/directory on hostname (if not specified, the ~/ is supplied) and then run the osc build on hostname. All build arguments are supplied to the remote osc build. There are known issues: * arguments like --oldpackages, --keep-pkgs, --prefer-pkgs does not work yet * using it with --rsync-dest and --rsync-src might be tricky and produce unexpected results * osc chroot should be extended to perform it on a remote machine * the OSC_ variables do not survive ssh (but we can introduce more sane switches for that purpose) * global arguments do not survive, but I doubt they are necessary * rsync can get more arguments * maybe other things I am waiting on a feedback Regards Michal Vyskocil --- osc/commandline.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/osc/commandline.py b/osc/commandline.py index b28e208..32ed197 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -5082,6 +5082,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='take previous build from DIR (special values: _self, _link)') @cmdln.option('--shell', action='store_true', help=SUPPRESS_HELP) + @cmdln.option('--host', metavar='HOST', + help='perform the build on a remote server - user@server:~/remote/directory') def do_build(self, subcmd, opts, *args): """${cmd_name}: Build a package on your local machine @@ -5180,7 +5182,29 @@ Please submit there instead, or use --nodevelproject to force direct submission. raise oscerr.WrongOptions('--offline and --preload are mutually exclusive') print 'Building %s for %s/%s' % (args[2], args[0], args[1]) - return osc.build.main(self.get_api_url(), opts, args) + if not opts.host: + return osc.build.main(self.get_api_url(), opts, args) + else: + cwd = os.getcwdu() + basename = os.path.basename(cwd) + if not ':' in opts.host: + hostname = opts.host + hostpath = "~/" + else: + hostname, hostpath = opts.host.split(':', 1) + + rsync_cmd = ['rsync', '-az', '-e', 'ssh', cwd, "%s:%s" % (hostname, hostpath)] + print 'Run: %s' % " ".join(rsync_cmd) + subprocess.check_call(rsync_cmd) + + # we use all arguments behind build and drop --host 'HOST' + hostargs = sys.argv[sys.argv.index('build')+1:] + hostargs.pop(hostargs.index('--host')+1) + hostargs.pop(hostargs.index('--host')) + + ssh_cmd = ['ssh', hostname, '"cd %s/%s; osc build %s"' % (hostpath, basename, " ".join(hostargs))] + print 'Run: %s' % " ".join(ssh_cmd) + return subprocess.check_call(ssh_cmd) @cmdln.option('--local-package', action='store_true', -- 1.7.11.4