devtool deploy-target: optionally specify package
PATCH v2 1/1 devtool deploy-target: optionally specify package
Instead of installing an entire recipe's build output (i.e. ${D}), allow the user to optionally specify the name of one package at a time from said recipe to be installed (i.e. ${PKGDEST}/<package>).
NOTE: mixing "deploy-target" commands that have this new --package option and "deploy-target" commands without --package against the same recipe is not ideal.
---
updates since v1:
- The behaviour of deploy-target is to start by trying to remove any previous such deploy-targets with the same deploy-name which have already been deployed on the target. That meant that, with v1, if someone tried to deploy two packages from the same recipe, the second deployment would undeploy the first deployment, then deploy the second. By incorporating the package name into the on-target deploy-name, multiple such deployments can exist at the same time from the same recipe.
--- scripts/lib/devtool/deploy.py | 42 ++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-)
scripts/lib/devtool/deploy.py +31 -11
@@ -169,11 +169,20 @@ def deploy(args, config, basepath, workspace): except Exception as e: raise DevtoolError('Exception parsing recipe %s: %s' % (args.recipename, e)) - recipe_outdir = rd.getVar('D') + if args.package: + recipe_outdir = os.path.join(rd.getVar('PKGDEST'), args.package) + else: + recipe_outdir = rd.getVar('D') if not os.path.exists(recipe_outdir) or not os.listdir(recipe_outdir): - raise DevtoolError('No files to deploy - have you built the %s ' - 'recipe? If so, the install step has not installed ' - 'any files.' % args.recipename) + if args.package: + raise DevtoolError('No files to deploy - have you built the %s ' + 'package of the %s recipe? If so, the install ' + 'step has not installed any files.' + % (args.package, args.recipename)) + else: + raise DevtoolError('No files to deploy - have you built the %s ' + 'recipe? If so, the install step has not installed ' + 'any files.' % args.recipename) if args.strip and not args.dry_run: # Fakeroot copy to new destination
@@ -246,7 +255,10 @@ def deploy(args, config, basepath, workspace): shutil.rmtree(tmpdir) # Now run the script - 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) + filename = args.recipename + if args.package: + filename = filename + '.' + args.package + ret = exec_fakeroot(rd, 'tar cf - . | ssh %s %s %s \'sh %s %s %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, filename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True) if ret != 0: raise DevtoolError('Deploy failed - rerun with -s to get a complete ' 'error message')
@@ -300,13 +312,19 @@ def undeploy(args, config, basepath, workspace): shutil.rmtree(tmpdir) # Now run the script - ret = subprocess.call('ssh %s %s %s \'sh %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, args.recipename), shell=True) + filename = args.recipename + if args.package: + filename = filename + '.' + args.package + ret = subprocess.call('ssh %s %s %s \'sh %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, filename), shell=True) if ret != 0: raise DevtoolError('Undeploy failed - rerun with -s to get a complete ' 'error message') if not args.all and not args.dry_run: - logger.info('Successfully undeployed %s' % args.recipename) + if args.package: + logger.info('Successfully undeployed %s' % args.package) + else: + logger.info('Successfully undeployed %s' % args.recipename) return 0
@@ -314,8 +332,8 @@ def register_commands(subparsers, context): """Register devtool subcommands from the deploy plugin""" parser_deploy = subparsers.add_parser('deploy-target', - help='Deploy recipe output files to live target machine', - description='Deploys a recipe\'s build output (i.e. the output of the do_install task) to a live target machine over ssh. By default, any existing files will be preserved instead of being overwritten and will be restored if you run devtool undeploy-target. Note: this only deploys the recipe itself and not any runtime dependencies, so it is assumed that those have been installed on the target beforehand.', + help='Deploy build output to a live target machine', + description='Deploys either the full recipe\'s build output (i.e. the output of the do_install task) or a package of a recipe to a live target machine over ssh. By default, any existing files will be preserved instead of being overwritten and will be restored if you run devtool undeploy-target. Note: this only deploys the specified item itself and not any runtime dependencies, so it is assumed that those have been installed on the target beforehand.', group='testbuild') parser_deploy.add_argument('recipename', help='Recipe to deploy') parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]')
@@ -325,6 +343,7 @@ def register_commands(subparsers, context): parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') parser_deploy.add_argument('-P', '--port', help='Specify port to use for connection to the target') + parser_deploy.add_argument('--package', help='Specify a recipe\'s package to deploy', dest='package') strip_opts = parser_deploy.add_mutually_exclusive_group(required=False) strip_opts.add_argument('-S', '--strip',
@@ -337,8 +356,8 @@ def register_commands(subparsers, context): parser_deploy.set_defaults(func=deploy) parser_undeploy = subparsers.add_parser('undeploy-target', - help='Undeploy recipe output files in live target machine', - description='Un-deploys recipe output files previously deployed to a live target machine by devtool deploy-target.', + help='Undeploy output files from a live target machine', + description='Un-deploys output files previously deployed to a live target machine by devtool deploy-target.', group='testbuild') parser_undeploy.add_argument('recipename', help='Recipe to undeploy (if not using -a/--all)', nargs='?') parser_undeploy.add_argument('target', help='Live target machine running an ssh server: user@hostname')
@@ -347,4 +366,5 @@ def register_commands(subparsers, context): parser_undeploy.add_argument('-a', '--all', help='Undeploy all recipes deployed on the target', action='store_true') parser_undeploy.add_argument('-n', '--dry-run', help='List files to be undeployed only', action='store_true') parser_undeploy.add_argument('-P', '--port', help='Specify port to use for connection to the target') + parser_undeploy.add_argument('--package', help='Specify a recipe\'s package to undeploy', dest='package') parser_undeploy.set_defaults(func=undeploy)
Signature · 1 line
2.17.0.582.gccdcbd54c
ping?
Quoted 179 lines · Trevor Woerner
Instead of installing an entire recipe's build output (i.e. ${D}), allow the
user to optionally specify the name of one package at a time from said recipe
to be installed (i.e. ${PKGDEST}/<package>).NOTE: mixing "deploy-target" commands that have this new --package option and
"deploy-target" commands without --package against the same recipe is not ideal.Signed-off-by Trevor Woerner <[email protected]>---
updates since v1:
- The behaviour of deploy-target is to start by trying to remove any
previous
such deploy-targets with the same deploy-name which have already been deployed on the target. That meant that, with v1, if someone tried to deploy two packages from the same recipe, the second deployment would undeploy the first deployment, then deploy the second. By incorporating
the
package name into the on-target deploy-name, multiple such deployments
can
exist at the same time from the same recipe.--- scripts/lib/devtool/deploy.py | 42 ++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-)scripts/lib/devtool/deploy.py +4
-1@@ -169,11 +169,20 @@ def deploy(args, config, basepath, workspace): except Exception as e: raise DevtoolError('Exception parsing recipe %s: %s' % (args.recipename, e)) - recipe_outdir = rd.getVar('D') + if args.package: + recipe_outdir = os.path.join(rd.getVar('PKGDEST'), args.package) + else: + recipe_outdir = rd.getVar('D') if not os.path.exists(recipe_outdir) or not
os.listdir(recipe_outdir):
- raise DevtoolError('No files to deploy - have you built the
%s '
- 'recipe? If so, the install step has not
installed 'scripts/lib/devtool/deploy.py +2
-1- 'any files.' % args.recipename) + if args.package: + raise DevtoolError('No files to deploy - have you builtthe %s '
+ 'package of the %s recipe? If so, the
install 'scripts/lib/devtool/deploy.py +4
-0+ 'step has not installed any files.' + % (args.package, args.recipename)) + else: + raise DevtoolError('No files to deploy - have you builtthe %s '
+ 'recipe? If so, the install step has not
installed 'scripts/lib/devtool/deploy.py +5
-1+ 'any files.' % args.recipename) if args.strip and not args.dry_run: # Fakeroot copy to new destination@@ -246,7 +255,10 @@ def deploy(args, config, basepath, workspace): shutil.rmtree(tmpdir) # Now run the script - 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) + filename = args.recipename + if args.package: + filename = filename + '.' + args.package + ret = exec_fakeroot(rd, 'tar cf - . | ssh %s %s %s \'sh %s %s %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, filename, destdir,tmpfilelist), cwd=recipe_outdir, shell=True)
if ret != 0:
raise DevtoolError('Deploy failed - rerun with -s to get a
complete '
'error message')scripts/lib/devtool/deploy.py +4
-1@@ -300,13 +312,19 @@ def undeploy(args, config, basepath, workspace): shutil.rmtree(tmpdir) # Now run the script - ret = subprocess.call('ssh %s %s %s \'sh %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, args.recipename), shell=True) + filename = args.recipename + if args.package: + filename = filename + '.' + args.package + ret = subprocess.call('ssh %s %s %s \'sh %s %s\'' % (ssh_port, extraoptions, args.target, tmpscript, filename), shell=True) if ret != 0: raise DevtoolError('Undeploy failed - rerun with -s to get acomplete '
'error message')if not args.all and not args.dry_run:
scripts/lib/devtool/deploy.py +4
-3- logger.info('Successfully undeployed %s' % args.recipename) + if args.package: + logger.info('Successfully undeployed %s' % args.package) + else: + logger.info('Successfully undeployed %s' % args.recipename) return 0@@ -314,8 +332,8 @@ def register_commands(subparsers, context): """Register devtool subcommands from the deploy plugin""" parser_deploy = subparsers.add_parser('deploy-target', - help='Deploy recipe output files to live target machine', - description='Deploys arecipe\'s build output (i.e. the output of the
do_installtask) to a live target machine over ssh. By default, any existing files will be preserved instead of being overwritten and will be restored if you run devtool undeploy-target. Note: this only deploys the recipe itself and not any runtime dependencies, so it is assumed that those have been installed on the target beforehand.',
+ help='Deploy build output to a
live target machine',
+ description='Deploys either the
full recipe\'s build output (i.e. the output of thedo_installtask) or a package of a recipe to a live target machine over ssh. By default, any existing files will be preserved instead of being overwritten and will be restored if you run devtool undeploy-target. Note: this only deploys the specified item itself and not any runtime dependencies, so it is assumed that those have been installed on the target beforehand.',
group='testbuild')
parser_deploy.add_argument('recipename', help='Recipe to deploy')parser_deploy.add_argument('target', help='Live target machine
running an ssh server: user@hostname[:destdir]')scripts/lib/devtool/deploy.py +1
-0@@ -325,6 +343,7 @@ def register_commands(subparsers, context): parser_deploy.add_argument('-p', '--no-preserve', help='Do not preserve existing files', action='store_true') parser_deploy.add_argument('--no-check-space', help='Do not check for available space before deploying', action='store_true') parser_deploy.add_argument('-P', '--port', help='Specify port to use for connection to the target') + parser_deploy.add_argument('--package', help='Specify a recipe\'spackage to deploy', dest='package')
strip_opts= parser_deploy.add_mutually_exclusive_group(required=
False)strip_opts.add_argument('-S', '--strip',scripts/lib/devtool/deploy.py +0
-2@@ -337,8 +356,8 @@ def register_commands(subparsers, context): parser_deploy.set_defaults(func=deploy) parser_undeploy = subparsers.add_parser('undeploy-target', - help='Undeploy recipe output files in live target machine', - description='Un-deploysrecipe output files previously deployed to a live target machine by devtool deploy-target.',
+ help='Undeploy output files
from a live target machine',
+ description='Un-deploys
output files previously deployed to a live target machine by devtool deploy-target.',
group='testbuild')
parser_undeploy.add_argument('recipename', help='Recipe to undeploy
(if not using -a/--all)', nargs='?')
parser_undeploy.add_argument('target', help='Live target machine
running an ssh server: user@hostname')scripts/lib/devtool/deploy.py +0
-0@@ -347,4 +366,5 @@ def register_commands(subparsers, context): parser_undeploy.add_argument('-a', '--all', help='Undeploy all recipes deployed on the target', action='store_true') parser_undeploy.add_argument('-n', '--dry-run', help='List files to be undeployed only', action='store_true') parser_undeploy.add_argument('-P', '--port', help='Specify port touse for connection to the target')
+ parser_undeploy.add_argument('--package', help='Specify a recipe\'s
package to undeploy', dest='package')
parser_undeploy.set_defaults(func=undeploy)
--
2.17.0.582.gccdcbd54c