diff options
author | Tim Orling <timothy.t.orling@linux.intel.com> | 2017-02-19 00:08:18 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-01 23:27:06 +0000 |
commit | ea8b9d5d7b67a8ffa3838d1d879b773f4aae115d (patch) | |
tree | e44fb00570351bcf9a5551278a15d237c09f432b /scripts | |
parent | 129fbf324a34f2535206458a48ab067d7de9e354 (diff) | |
download | poky-ea8b9d5d7b67a8ffa3838d1d879b773f4aae115d.tar.gz |
scripts/lib/devtool/deploy.py: add --port/-P argument for target connection
Enable using, e.g. host port 2222 for connection to qemu target.
Defaults to 22 for standard ssh/scp port.
[YOCTO #11079]
(From OE-Core rev: a2bfa2cc9ee19f617f7d3b6447896e45eb855d2e)
Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/devtool/deploy.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py index 9ec04e366a..b3730ae833 100644 --- a/scripts/lib/devtool/deploy.py +++ b/scripts/lib/devtool/deploy.py | |||
@@ -192,6 +192,14 @@ def deploy(args, config, basepath, workspace): | |||
192 | if not args.show_status: | 192 | if not args.show_status: |
193 | extraoptions += ' -q' | 193 | extraoptions += ' -q' |
194 | 194 | ||
195 | scp_port = '' | ||
196 | ssh_port = '' | ||
197 | if not args.port: | ||
198 | raise DevtoolError("If you specify -P/--port then you must provide the port to be used to connect to the target") | ||
199 | else: | ||
200 | scp_port = "-P %s" % args.port | ||
201 | ssh_port = "-p %s" % args.port | ||
202 | |||
195 | # In order to delete previously deployed files and have the manifest file on | 203 | # In order to delete previously deployed files and have the manifest file on |
196 | # the target, we write out a shell script and then copy it to the target | 204 | # the target, we write out a shell script and then copy it to the target |
197 | # so we can then run it (piping tar output to it). | 205 | # so we can then run it (piping tar output to it). |
@@ -213,7 +221,7 @@ def deploy(args, config, basepath, workspace): | |||
213 | for fpath, fsize in filelist: | 221 | for fpath, fsize in filelist: |
214 | f.write('%s %d\n' % (fpath, fsize)) | 222 | f.write('%s %d\n' % (fpath, fsize)) |
215 | # Copy them to the target | 223 | # Copy them to the target |
216 | ret = subprocess.call("scp %s %s/* %s:%s" % (extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True) | 224 | ret = subprocess.call("scp %s %s %s/* %s:%s" % (scp_port, extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True) |
217 | if ret != 0: | 225 | if ret != 0: |
218 | raise DevtoolError('Failed to copy script to %s - rerun with -s to ' | 226 | raise DevtoolError('Failed to copy script to %s - rerun with -s to ' |
219 | 'get a complete error message' % args.target) | 227 | 'get a complete error message' % args.target) |
@@ -221,7 +229,7 @@ def deploy(args, config, basepath, workspace): | |||
221 | shutil.rmtree(tmpdir) | 229 | shutil.rmtree(tmpdir) |
222 | 230 | ||
223 | # Now run the script | 231 | # Now run the script |
224 | ret = exec_fakeroot(rd, 'tar cf - . | ssh %s %s \'sh %s %s %s %s\'' % (extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True) | 232 | ret = exec_fakeroot(rd, 'tar cf - . | ssh %s %s %s \'sh %s %s %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True) |
225 | if ret != 0: | 233 | if ret != 0: |
226 | raise DevtoolError('Deploy failed - rerun with -s to get a complete ' | 234 | raise DevtoolError('Deploy failed - rerun with -s to get a complete ' |
227 | 'error message') | 235 | 'error message') |
@@ -251,6 +259,14 @@ def undeploy(args, config, basepath, workspace): | |||
251 | if not args.show_status: | 259 | if not args.show_status: |
252 | extraoptions += ' -q' | 260 | extraoptions += ' -q' |
253 | 261 | ||
262 | scp_port = '' | ||
263 | ssh_port = '' | ||
264 | if not args.port: | ||
265 | raise DevtoolError("If you specify -P/--port then you must provide the port to be used to connect to the target") | ||
266 | else: | ||
267 | scp_port = "-P %s" % args.port | ||
268 | ssh_port = "-p %s" % args.port | ||
269 | |||
254 | args.target = args.target.split(':')[0] | 270 | args.target = args.target.split(':')[0] |
255 | 271 | ||
256 | tmpdir = tempfile.mkdtemp(prefix='devtool') | 272 | tmpdir = tempfile.mkdtemp(prefix='devtool') |
@@ -261,7 +277,7 @@ def undeploy(args, config, basepath, workspace): | |||
261 | with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f: | 277 | with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f: |
262 | f.write(shellscript) | 278 | f.write(shellscript) |
263 | # Copy it to the target | 279 | # Copy it to the target |
264 | ret = subprocess.call("scp %s %s/* %s:%s" % (extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True) | 280 | ret = subprocess.call("scp %s %s %s/* %s:%s" % (scp_port, extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True) |
265 | if ret != 0: | 281 | if ret != 0: |
266 | raise DevtoolError('Failed to copy script to %s - rerun with -s to ' | 282 | raise DevtoolError('Failed to copy script to %s - rerun with -s to ' |
267 | 'get a complete error message' % args.target) | 283 | 'get a complete error message' % args.target) |
@@ -269,7 +285,7 @@ def undeploy(args, config, basepath, workspace): | |||
269 | shutil.rmtree(tmpdir) | 285 | shutil.rmtree(tmpdir) |
270 | 286 | ||
271 | # Now run the script | 287 | # Now run the script |
272 | ret = subprocess.call('ssh %s %s \'sh %s %s\'' % (extraoptions, args.target, tmpscript, args.recipename), shell=True) | 288 | ret = subprocess.call('ssh %s %s %s \'sh %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, args.recipename), shell=True) |
273 | if ret != 0: | 289 | if ret != 0: |
274 | raise DevtoolError('Undeploy failed - rerun with -s to get a complete ' | 290 | raise DevtoolError('Undeploy failed - rerun with -s to get a complete ' |
275 | 'error message') | 291 | 'error message') |
@@ -292,6 +308,7 @@ def register_commands(subparsers, context): | |||
292 | parser_deploy.add_argument('-n', '--dry-run', help='List files to be deployed only', action='store_true') | 308 | parser_deploy.add_argument('-n', '--dry-run', help='List files to be deployed only', action='store_true') |
293 | parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') | 309 | parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') |
294 | parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') | 310 | parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') |
311 | parser_deploy.add_argument('-P', '--port', default='22', help='Port to use for connection to the target') | ||
295 | parser_deploy.set_defaults(func=deploy) | 312 | parser_deploy.set_defaults(func=deploy) |
296 | 313 | ||
297 | parser_undeploy = subparsers.add_parser('undeploy-target', | 314 | parser_undeploy = subparsers.add_parser('undeploy-target', |
@@ -304,4 +321,5 @@ def register_commands(subparsers, context): | |||
304 | parser_undeploy.add_argument('-s', '--show-status', help='Show progress/status output', action='store_true') | 321 | parser_undeploy.add_argument('-s', '--show-status', help='Show progress/status output', action='store_true') |
305 | parser_undeploy.add_argument('-a', '--all', help='Undeploy all recipes deployed on the target', action='store_true') | 322 | parser_undeploy.add_argument('-a', '--all', help='Undeploy all recipes deployed on the target', action='store_true') |
306 | parser_undeploy.add_argument('-n', '--dry-run', help='List files to be undeployed only', action='store_true') | 323 | parser_undeploy.add_argument('-n', '--dry-run', help='List files to be undeployed only', action='store_true') |
324 | parser_undeploy.add_argument('-P', '--port', default='22', help='Port to use for connection to the target') | ||
307 | parser_undeploy.set_defaults(func=undeploy) | 325 | parser_undeploy.set_defaults(func=undeploy) |