aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-30 16:34:43 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2016-07-11 11:02:42 +1200
commit5238d497c238a7629b3fa3dfc32cf0b52dc79980 (patch)
tree3d5419321579b4c9d4762d5c76953638bf406f0b
parentaa33e3c26d53f41d094c1a0f563500c7c0508a63 (diff)
downloadopenembedded-core-contrib-5238d497c238a7629b3fa3dfc32cf0b52dc79980.tar.gz
openembedded-core-contrib-5238d497c238a7629b3fa3dfc32cf0b52dc79980.tar.bz2
openembedded-core-contrib-5238d497c238a7629b3fa3dfc32cf0b52dc79980.zip
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>
-rw-r--r--scripts/lib/devtool/standard.py4
-rw-r--r--scripts/lib/recipetool/create.py15
2 files changed, 14 insertions, 5 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ed49a936b95..737ecc13b61 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -65,6 +65,10 @@ def add(args, config, basepath, workspace):
elif os.path.isdir(args.recipename):
logger.warn('Ambiguous argument %s - assuming you mean it to be the recipe name')
+ if args.srctree and os.path.isfile(args.srctree):
+ args.fetchuri = 'file://' + os.path.abspath(args.srctree)
+ args.srctree = ''
+
if args.fetch:
if args.fetchuri:
raise DevtoolError('URI specified as positional argument as well as -f/--fetch')
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 95b16fb3101..f246028a021 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')
sys.exit(1)
- 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)
sys.exit(1)
- srctree = args.source
+ srctree = source
srcuri = ''
if os.path.exists(os.path.join(srctree, '.git')):
# Try to get upstream repo location from origin remote