Mailinglist Archive: opensuse-buildservice (178 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] [RFC][PATCH] osc build on remote --host
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

Michal Vyskocil
osc/ | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/osc/ b/osc/
index b28e208..32ed197 100644
--- a/osc/
+++ b/osc/
@@ -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',
+ @cmdln.option('--host', metavar='HOST',
+ help='perform the build on a remote server -
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

print 'Building %s for %s/%s' % (args[2], args[0], args[1])
- return, opts, args)
+ if not
+ return, opts, args)
+ else:
+ cwd = os.getcwdu()
+ basename = os.path.basename(cwd)
+ if not ':' in
+ hostname =
+ hostpath = "~/"
+ else:
+ hostname, hostpath =':', 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',

< Previous Next >