path: root/scripts/lib/recipetool/create.py
diff options
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-07-07 11:57:08 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-12 23:10:04 +0100
commit71350003790c38e84b0e525a71a2fe5d24e3d083 (patch)
treea0bf323098eeba2b91fe861a749853841e2cbead /scripts/lib/recipetool/create.py
parent7998dc3597657229507e5c140fceef1e485ac402 (diff)
recipetool: create: support specifying a file as the local source
It is currently possible to specify a file (e.g. a tarball) on the local disk as the source, but you have to know to put file:// in front of it. There's really no need to force users to jump through that hoop if they really want to do this so check if the specified source is a file and prefix it with file:// if that's the case. Also ensure the same works for "devtool add" at the same time. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 95b16fb310..f246028a02 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -351,11 +351,16 @@ def create_recipe(args):
extravalues = {}
checksums = (None, None)
tempsrc = ''
+ source = args.source
srcsubdir = ''
srcrev = '${AUTOREV}'
- if '://' in args.source:
+ if os.path.isfile(source):
+ source = 'file://%s' % os.path.abspath(source)
+ if '://' in source:
# Fetch a URL
- fetchuri = reformat_git_uri(urldefrag(args.source)[0])
+ fetchuri = reformat_git_uri(urldefrag(source)[0])
if args.binary:
# Assume the archive contains the directory structure verbatim
# so we need to extract to a subdirectory
@@ -426,10 +431,10 @@ def create_recipe(args):
if args.extract_to:
logger.error('--extract-to cannot be specified if source is a directory')
- if not os.path.isdir(args.source):
- logger.error('Invalid source directory %s' % args.source)
+ if not os.path.isdir(source):
+ logger.error('Invalid source directory %s' % source)
- srctree = args.source
+ srctree = source
srcuri = ''
if os.path.exists(os.path.join(srctree, '.git')):
# Try to get upstream repo location from origin remote