summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r--scripts/lib/recipetool/create.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 3c6ef6719f..ef0ba974a9 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -18,6 +18,7 @@ from urllib.parse import urlparse, urldefrag, urlsplit
18import hashlib 18import hashlib
19import bb.fetch2 19import bb.fetch2
20logger = logging.getLogger('recipetool') 20logger = logging.getLogger('recipetool')
21from oe.license import tidy_licenses
21from oe.license_finder import find_licenses 22from oe.license_finder import find_licenses
22 23
23tinfoil = None 24tinfoil = None
@@ -638,7 +639,6 @@ def create_recipe(args):
638 if len(splitline) > 1: 639 if len(splitline) > 1:
639 if splitline[0] == 'origin' and scriptutils.is_src_url(splitline[1]): 640 if splitline[0] == 'origin' and scriptutils.is_src_url(splitline[1]):
640 srcuri = reformat_git_uri(splitline[1]) + ';branch=master' 641 srcuri = reformat_git_uri(splitline[1]) + ';branch=master'
641 srcsubdir = 'git'
642 break 642 break
643 643
644 if args.src_subdir: 644 if args.src_subdir:
@@ -736,7 +736,7 @@ def create_recipe(args):
736 if srcsubdir and not args.binary: 736 if srcsubdir and not args.binary:
737 # (for binary packages we explicitly specify subdir= when fetching to 737 # (for binary packages we explicitly specify subdir= when fetching to
738 # match the default value of S, so we don't need to set it in that case) 738 # match the default value of S, so we don't need to set it in that case)
739 lines_before.append('S = "${WORKDIR}/%s"' % srcsubdir) 739 lines_before.append('S = "${UNPACKDIR}/%s"' % srcsubdir)
740 lines_before.append('') 740 lines_before.append('')
741 741
742 if pkgarch: 742 if pkgarch:
@@ -765,6 +765,7 @@ def create_recipe(args):
765 extrafiles = extravalues.pop('extrafiles', {}) 765 extrafiles = extravalues.pop('extrafiles', {})
766 extra_pn = extravalues.pop('PN', None) 766 extra_pn = extravalues.pop('PN', None)
767 extra_pv = extravalues.pop('PV', None) 767 extra_pv = extravalues.pop('PV', None)
768 run_tasks = extravalues.pop('run_tasks', "").split()
768 769
769 if extra_pv and not realpv: 770 if extra_pv and not realpv:
770 realpv = extra_pv 771 realpv = extra_pv
@@ -825,7 +826,8 @@ def create_recipe(args):
825 extraoutdir = os.path.join(os.path.dirname(outfile), pn) 826 extraoutdir = os.path.join(os.path.dirname(outfile), pn)
826 bb.utils.mkdirhier(extraoutdir) 827 bb.utils.mkdirhier(extraoutdir)
827 for destfn, extrafile in extrafiles.items(): 828 for destfn, extrafile in extrafiles.items():
828 shutil.move(extrafile, os.path.join(extraoutdir, destfn)) 829 fn = destfn.format(pn=pn, pv=realpv)
830 shutil.move(extrafile, os.path.join(extraoutdir, fn))
829 831
830 lines = lines_before 832 lines = lines_before
831 lines_before = [] 833 lines_before = []
@@ -840,7 +842,7 @@ def create_recipe(args):
840 line = line.replace(realpv, '${PV}') 842 line = line.replace(realpv, '${PV}')
841 if pn: 843 if pn:
842 line = line.replace(pn, '${BPN}') 844 line = line.replace(pn, '${BPN}')
843 if line == 'S = "${WORKDIR}/${BPN}-${PV}"': 845 if line == 'S = "${UNPACKDIR}/${BPN}-${PV}"' or 'tmp-recipetool-' in line:
844 skipblank = True 846 skipblank = True
845 continue 847 continue
846 elif line.startswith('SRC_URI = '): 848 elif line.startswith('SRC_URI = '):
@@ -918,6 +920,10 @@ def create_recipe(args):
918 log_info_cond('Recipe %s has been created; further editing may be required to make it fully functional' % outfile, args.devtool) 920 log_info_cond('Recipe %s has been created; further editing may be required to make it fully functional' % outfile, args.devtool)
919 tinfoil.modified_files() 921 tinfoil.modified_files()
920 922
923 for task in run_tasks:
924 logger.info("Running task %s" % task)
925 tinfoil.build_file_sync(outfile, task)
926
921 if tempsrc: 927 if tempsrc:
922 if args.keep_temp: 928 if args.keep_temp:
923 logger.info('Preserving temporary directory %s' % tempsrc) 929 logger.info('Preserving temporary directory %s' % tempsrc)
@@ -945,16 +951,6 @@ def fixup_license(value):
945 return '(' + value + ')' 951 return '(' + value + ')'
946 return value 952 return value
947 953
948def tidy_licenses(value):
949 """Flat, split and sort licenses"""
950 from oe.license import flattened_licenses
951 def _choose(a, b):
952 str_a, str_b = sorted((" & ".join(a), " & ".join(b)), key=str.casefold)
953 return ["(%s | %s)" % (str_a, str_b)]
954 if not isinstance(value, str):
955 value = " & ".join(value)
956 return sorted(list(set(flattened_licenses(value, _choose))), key=str.casefold)
957
958def handle_license_vars(srctree, lines_before, handled, extravalues, d): 954def handle_license_vars(srctree, lines_before, handled, extravalues, d):
959 lichandled = [x for x in handled if x[0] == 'license'] 955 lichandled = [x for x in handled if x[0] == 'license']
960 if lichandled: 956 if lichandled: