diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/recipetool/append.py | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py index ed4ce4a805..0aca2cae66 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py | |||
@@ -245,21 +245,6 @@ def check_do_install(rd, targetpath): | |||
245 | def appendfile(args): | 245 | def appendfile(args): |
246 | import oe.recipeutils | 246 | import oe.recipeutils |
247 | 247 | ||
248 | if not args.targetpath.startswith('/'): | ||
249 | logger.error('Target path should start with /') | ||
250 | return 2 | ||
251 | |||
252 | if os.path.isdir(args.newfile): | ||
253 | logger.error('Specified new file "%s" is a directory' % args.newfile) | ||
254 | return 2 | ||
255 | |||
256 | if not os.path.exists(args.destlayer): | ||
257 | logger.error('Destination layer directory "%s" does not exist' % args.destlayer) | ||
258 | return 2 | ||
259 | if not os.path.exists(os.path.join(args.destlayer, 'conf', 'layer.conf')): | ||
260 | logger.error('conf/layer.conf not found in destination layer "%s"' % args.destlayer) | ||
261 | return 2 | ||
262 | |||
263 | stdout = '' | 248 | stdout = '' |
264 | try: | 249 | try: |
265 | (stdout, _) = bb.process.run('LANG=C file -b %s' % args.newfile, shell=True) | 250 | (stdout, _) = bb.process.run('LANG=C file -b %s' % args.newfile, shell=True) |
@@ -349,13 +334,33 @@ def appendfile(args): | |||
349 | return 3 | 334 | return 3 |
350 | 335 | ||
351 | 336 | ||
337 | def layer(layerpath): | ||
338 | if not os.path.exists(os.path.join(layerpath, 'conf', 'layer.conf')): | ||
339 | raise argparse.ArgumentTypeError('{0!r} must be a path to a valid layer'.format(layerpath)) | ||
340 | return layerpath | ||
341 | |||
342 | |||
343 | def existing_file(filepath): | ||
344 | if not os.path.exists(filepath): | ||
345 | raise argparse.ArgumentTypeError('{0!r} must be an existing path'.format(filepath)) | ||
346 | elif os.path.isdir(filepath): | ||
347 | raise argparse.ArgumentTypeError('{0!r} must be a file, not a directory'.format(filepath)) | ||
348 | return filepath | ||
349 | |||
350 | |||
351 | def target_path(targetpath): | ||
352 | if not os.path.isabs(targetpath): | ||
353 | raise argparse.ArgumentTypeError('{0!r} must be an absolute path, not relative'.format(targetpath)) | ||
354 | return targetpath | ||
355 | |||
356 | |||
352 | def register_command(subparsers): | 357 | def register_command(subparsers): |
353 | parser_appendfile = subparsers.add_parser('appendfile', | 358 | parser_appendfile = subparsers.add_parser('appendfile', |
354 | help='Create/update a bbappend to replace a file', | 359 | help='Create/update a bbappend to replace a file', |
355 | description='Creates a bbappend (or updates an existing one) to replace the specified file that appears in the target system, determining the recipe that packages the file and the required path and name for the bbappend automatically. Note that the ability to determine the recipe packaging a particular file depends upon the recipe\'s do_packagedata task having already run prior to running this command (which it will have when the recipe has been built successfully, which in turn will have happened if one or more of the recipe\'s packages is included in an image that has been built successfully).') | 360 | description='Creates a bbappend (or updates an existing one) to replace the specified file that appears in the target system, determining the recipe that packages the file and the required path and name for the bbappend automatically. Note that the ability to determine the recipe packaging a particular file depends upon the recipe\'s do_packagedata task having already run prior to running this command (which it will have when the recipe has been built successfully, which in turn will have happened if one or more of the recipe\'s packages is included in an image that has been built successfully).') |
356 | parser_appendfile.add_argument('destlayer', help='Base directory of the destination layer to write the bbappend to') | 361 | parser_appendfile.add_argument('destlayer', help='Base directory of the destination layer to write the bbappend to', type=layer) |
357 | parser_appendfile.add_argument('targetpath', help='Path to the file to be replaced (as it would appear within the target image, e.g. /etc/motd)') | 362 | parser_appendfile.add_argument('targetpath', help='Path to the file to be replaced (as it would appear within the target image, e.g. /etc/motd)', type=target_path) |
358 | parser_appendfile.add_argument('newfile', help='Custom file to replace the target file with') | 363 | parser_appendfile.add_argument('newfile', help='Custom file to replace the target file with', type=existing_file) |
359 | parser_appendfile.add_argument('-r', '--recipe', help='Override recipe to apply to (default is to find which recipe already packages the file)') | 364 | parser_appendfile.add_argument('-r', '--recipe', help='Override recipe to apply to (default is to find which recipe already packages the file)') |
360 | parser_appendfile.add_argument('-m', '--machine', help='Make bbappend changes specific to a machine only', metavar='MACHINE') | 365 | parser_appendfile.add_argument('-m', '--machine', help='Make bbappend changes specific to a machine only', metavar='MACHINE') |
361 | parser_appendfile.add_argument('-w', '--wildcard-version', help='Use wildcard to make the bbappend apply to any recipe version', action='store_true') | 366 | parser_appendfile.add_argument('-w', '--wildcard-version', help='Use wildcard to make the bbappend apply to any recipe version', action='store_true') |