]> code.ossystems Code Review - openembedded-core.git/commitdiff
recipetool: avoid second-level subdir when extracting
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Tue, 28 Apr 2015 11:22:36 +0000 (12:22 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 1 May 2015 16:08:10 +0000 (17:08 +0100)
When -x was specified, we were getting the normal unpack subdirectory
which we don't really want - if there's only one subdirectory unpacked
then we should effectively copy just it to the extraction path, not as a
subdirectory under it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
scripts/lib/recipetool/create.py

index 1c71b24bfb5e13d841c9a25f1fce27ee83764238..1d5bfd995c10fbf0e804d0a63406d60bedeb706e 100644 (file)
@@ -1,6 +1,6 @@
 # Recipe creation tool - create command plugin
 #
-# Copyright (C) 2014 Intel Corporation
+# Copyright (C) 2014-2015 Intel Corporation
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 as
@@ -110,11 +110,8 @@ def create_recipe(args):
     if '://' in args.source:
         # Fetch a URL
         srcuri = args.source
-        if args.extract_to:
-            srctree = args.extract_to
-        else:
-            tempsrc = tempfile.mkdtemp(prefix='recipetool-')
-            srctree = tempsrc
+        tempsrc = tempfile.mkdtemp(prefix='recipetool-')
+        srctree = tempsrc
         logger.info('Fetching %s...' % srcuri)
         checksums = fetch_source(args.source, srctree)
         dirlist = os.listdir(srctree)
@@ -240,6 +237,10 @@ def create_recipe(args):
         outlines.append('')
     outlines.extend(lines_after)
 
+    if args.extract_to:
+        shutil.move(srctree, args.extract_to)
+        logger.info('Source extracted to %s' % args.extract_to)
+
     if outfile == '-':
         sys.stdout.write('\n'.join(outlines) + '\n')
     else: