diff options
Diffstat (limited to 'scripts/lib/devtool/deploy.py')
-rw-r--r-- | scripts/lib/devtool/deploy.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py index 92a3cb4cff..ca74a8e51d 100644 --- a/scripts/lib/devtool/deploy.py +++ b/scripts/lib/devtool/deploy.py | |||
@@ -19,7 +19,7 @@ | |||
19 | import os | 19 | import os |
20 | import subprocess | 20 | import subprocess |
21 | import logging | 21 | import logging |
22 | from devtool import exec_build_env_command, setup_tinfoil | 22 | from devtool import exec_build_env_command, setup_tinfoil, DevtoolError |
23 | 23 | ||
24 | logger = logging.getLogger('devtool') | 24 | logger = logging.getLogger('devtool') |
25 | 25 | ||
@@ -34,8 +34,8 @@ def deploy(args, config, basepath, workspace): | |||
34 | import oe.recipeutils | 34 | import oe.recipeutils |
35 | 35 | ||
36 | if not args.recipename in workspace: | 36 | if not args.recipename in workspace: |
37 | logger.error("no recipe named %s in your workspace" % args.recipename) | 37 | raise DevtoolError("no recipe named %s in your workspace" % |
38 | return -1 | 38 | args.recipename) |
39 | try: | 39 | try: |
40 | host, destdir = args.target.split(':') | 40 | host, destdir = args.target.split(':') |
41 | except ValueError: | 41 | except ValueError: |
@@ -50,12 +50,13 @@ def deploy(args, config, basepath, workspace): | |||
50 | try: | 50 | try: |
51 | rd = oe.recipeutils.parse_recipe_simple(tinfoil.cooker, args.recipename, tinfoil.config_data) | 51 | rd = oe.recipeutils.parse_recipe_simple(tinfoil.cooker, args.recipename, tinfoil.config_data) |
52 | except Exception as e: | 52 | except Exception as e: |
53 | logger.error('Exception parsing recipe %s: %s' % (args.recipename, e)) | 53 | raise DevtoolError('Exception parsing recipe %s: %s' % |
54 | return 2 | 54 | (args.recipename, e)) |
55 | recipe_outdir = rd.getVar('D', True) | 55 | recipe_outdir = rd.getVar('D', True) |
56 | if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir): | 56 | if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir): |
57 | logger.error('No files to deploy - have you built the %s recipe? If so, the install step has not installed any files.' % args.recipename) | 57 | raise DevtoolError('No files to deploy - have you built the %s ' |
58 | return -1 | 58 | 'recipe? If so, the install step has not installed ' |
59 | 'any files.' % args.recipename) | ||
59 | 60 | ||
60 | if args.dry_run: | 61 | if args.dry_run: |
61 | print('Files to be deployed for %s on target %s:' % (args.recipename, args.target)) | 62 | print('Files to be deployed for %s on target %s:' % (args.recipename, args.target)) |
@@ -67,7 +68,7 @@ def deploy(args, config, basepath, workspace): | |||
67 | if os.path.exists(deploy_file): | 68 | if os.path.exists(deploy_file): |
68 | if undeploy(args, config, basepath, workspace): | 69 | if undeploy(args, config, basepath, workspace): |
69 | # Error already shown | 70 | # Error already shown |
70 | return -1 | 71 | return 1 |
71 | 72 | ||
72 | extraoptions = '' | 73 | extraoptions = '' |
73 | if args.no_host_check: | 74 | if args.no_host_check: |
@@ -76,8 +77,8 @@ def deploy(args, config, basepath, workspace): | |||
76 | extraoptions += ' -q' | 77 | extraoptions += ' -q' |
77 | ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions, recipe_outdir, args.target, destdir), shell=True) | 78 | ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions, recipe_outdir, args.target, destdir), shell=True) |
78 | if ret != 0: | 79 | if ret != 0: |
79 | logger.error('Deploy failed - rerun with -s to get a complete error message') | 80 | raise DevtoolError('Deploy failed - rerun with -s to get a complete ' |
80 | return ret | 81 | 'error message') |
81 | 82 | ||
82 | logger.info('Successfully deployed %s' % recipe_outdir) | 83 | logger.info('Successfully deployed %s' % recipe_outdir) |
83 | 84 | ||
@@ -99,8 +100,7 @@ def undeploy(args, config, basepath, workspace): | |||
99 | """Entry point for the devtool 'undeploy' subcommand""" | 100 | """Entry point for the devtool 'undeploy' subcommand""" |
100 | deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list') | 101 | deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list') |
101 | if not os.path.exists(deploy_file): | 102 | if not os.path.exists(deploy_file): |
102 | logger.error('%s has not been deployed' % args.recipename) | 103 | raise DevtoolError('%s has not been deployed' % args.recipename) |
103 | return -1 | ||
104 | 104 | ||
105 | if args.dry_run: | 105 | if args.dry_run: |
106 | print('Previously deployed files to be un-deployed for %s on target %s:' % (args.recipename, args.target)) | 106 | print('Previously deployed files to be un-deployed for %s on target %s:' % (args.recipename, args.target)) |
@@ -117,15 +117,16 @@ def undeploy(args, config, basepath, workspace): | |||
117 | 117 | ||
118 | ret = subprocess.call("scp %s %s %s:/tmp" % (extraoptions, deploy_file, args.target), shell=True) | 118 | ret = subprocess.call("scp %s %s %s:/tmp" % (extraoptions, deploy_file, args.target), shell=True) |
119 | if ret != 0: | 119 | if ret != 0: |
120 | logger.error('Failed to copy file list to %s - rerun with -s to get a complete error message' % args.target) | 120 | raise DevtoolError('Failed to copy file list to %s - rerun with -s to ' |
121 | return -1 | 121 | 'get a complete error message' % args.target) |
122 | 122 | ||
123 | ret = subprocess.call("ssh %s %s 'xargs -n1 rm -f </tmp/%s'" % (extraoptions, args.target, os.path.basename(deploy_file)), shell=True) | 123 | ret = subprocess.call("ssh %s %s 'xargs -n1 rm -f </tmp/%s'" % (extraoptions, args.target, os.path.basename(deploy_file)), shell=True) |
124 | if ret == 0: | 124 | if ret == 0: |
125 | logger.info('Successfully undeployed %s' % args.recipename) | 125 | logger.info('Successfully undeployed %s' % args.recipename) |
126 | os.remove(deploy_file) | 126 | os.remove(deploy_file) |
127 | else: | 127 | else: |
128 | logger.error('Undeploy failed - rerun with -s to get a complete error message') | 128 | raise DevtoolError('Undeploy failed - rerun with -s to get a complete ' |
129 | 'error message') | ||
129 | 130 | ||
130 | return ret | 131 | return ret |
131 | 132 | ||