diff options
-rw-r--r-- | scripts/lib/devtool/standard.py | 122 |
1 files changed, 99 insertions, 23 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 47ed531b03..20c2b0b4c1 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -461,6 +461,31 @@ def sync(args, config, basepath, workspace): | |||
461 | finally: | 461 | finally: |
462 | tinfoil.shutdown() | 462 | tinfoil.shutdown() |
463 | 463 | ||
464 | def symlink_oelocal_files_srctree(rd,srctree): | ||
465 | import oe.patch | ||
466 | if os.path.abspath(rd.getVar('S')) == os.path.abspath(rd.getVar('WORKDIR')): | ||
467 | # If recipe extracts to ${WORKDIR}, symlink the files into the srctree | ||
468 | # (otherwise the recipe won't build as expected) | ||
469 | local_files_dir = os.path.join(srctree, 'oe-local-files') | ||
470 | addfiles = [] | ||
471 | for root, _, files in os.walk(local_files_dir): | ||
472 | relpth = os.path.relpath(root, local_files_dir) | ||
473 | if relpth != '.': | ||
474 | bb.utils.mkdirhier(os.path.join(srctree, relpth)) | ||
475 | for fn in files: | ||
476 | if fn == '.gitignore': | ||
477 | continue | ||
478 | destpth = os.path.join(srctree, relpth, fn) | ||
479 | if os.path.exists(destpth): | ||
480 | os.unlink(destpth) | ||
481 | os.symlink('oe-local-files/%s' % fn, destpth) | ||
482 | addfiles.append(os.path.join(relpth, fn)) | ||
483 | if addfiles: | ||
484 | bb.process.run('git add %s' % ' '.join(addfiles), cwd=srctree) | ||
485 | useroptions = [] | ||
486 | oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=rd) | ||
487 | bb.process.run('git %s commit -a -m "Committing local file symlinks\n\n%s"' % (' '.join(useroptions), oe.patch.GitApplyTree.ignore_commit_prefix), cwd=srctree) | ||
488 | |||
464 | 489 | ||
465 | def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False): | 490 | def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False): |
466 | """Extract sources of a recipe""" | 491 | """Extract sources of a recipe""" |
@@ -617,29 +642,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works | |||
617 | shutil.move(tempdir_localdir, srcsubdir) | 642 | shutil.move(tempdir_localdir, srcsubdir) |
618 | 643 | ||
619 | shutil.move(srcsubdir, srctree) | 644 | shutil.move(srcsubdir, srctree) |
620 | 645 | symlink_oelocal_files_srctree(d,srctree) | |
621 | if os.path.abspath(d.getVar('S')) == os.path.abspath(d.getVar('WORKDIR')): | ||
622 | # If recipe extracts to ${WORKDIR}, symlink the files into the srctree | ||
623 | # (otherwise the recipe won't build as expected) | ||
624 | local_files_dir = os.path.join(srctree, 'oe-local-files') | ||
625 | addfiles = [] | ||
626 | for root, _, files in os.walk(local_files_dir): | ||
627 | relpth = os.path.relpath(root, local_files_dir) | ||
628 | if relpth != '.': | ||
629 | bb.utils.mkdirhier(os.path.join(srctree, relpth)) | ||
630 | for fn in files: | ||
631 | if fn == '.gitignore': | ||
632 | continue | ||
633 | destpth = os.path.join(srctree, relpth, fn) | ||
634 | if os.path.exists(destpth): | ||
635 | os.unlink(destpth) | ||
636 | os.symlink('oe-local-files/%s' % fn, destpth) | ||
637 | addfiles.append(os.path.join(relpth, fn)) | ||
638 | if addfiles: | ||
639 | bb.process.run('git add %s' % ' '.join(addfiles), cwd=srctree) | ||
640 | useroptions = [] | ||
641 | oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d) | ||
642 | bb.process.run('git %s commit -a -m "Committing local file symlinks\n\n%s"' % (' '.join(useroptions), oe.patch.GitApplyTree.ignore_commit_prefix), cwd=srctree) | ||
643 | 646 | ||
644 | if is_kernel_yocto: | 647 | if is_kernel_yocto: |
645 | logger.info('Copying kernel config to srctree') | 648 | logger.info('Copying kernel config to srctree') |
@@ -707,11 +710,31 @@ def _check_preserve(config, recipename): | |||
707 | tf.write(line) | 710 | tf.write(line) |
708 | os.rename(newfile, origfile) | 711 | os.rename(newfile, origfile) |
709 | 712 | ||
713 | def get_staging_kver(srcdir): | ||
714 | # Kernel version from work-shared | ||
715 | kerver = [] | ||
716 | staging_kerVer="" | ||
717 | if os.path.exists(srcdir) and os.listdir(srcdir): | ||
718 | with open(os.path.join(srcdir,"Makefile")) as f: | ||
719 | version = [next(f) for x in range(5)][1:4] | ||
720 | for word in version: | ||
721 | kerver.append(word.split('= ')[1].split('\n')[0]) | ||
722 | staging_kerVer = ".".join(kerver) | ||
723 | return staging_kerVer | ||
724 | |||
725 | def get_staging_kbranch(srcdir): | ||
726 | staging_kbranch = "" | ||
727 | if os.path.exists(srcdir) and os.listdir(srcdir): | ||
728 | (branch, _) = bb.process.run('git branch | grep \* | cut -d \' \' -f2', cwd=srcdir) | ||
729 | staging_kbranch = "".join(branch.split('\n')[0]) | ||
730 | return staging_kbranch | ||
731 | |||
710 | def modify(args, config, basepath, workspace): | 732 | def modify(args, config, basepath, workspace): |
711 | """Entry point for the devtool 'modify' subcommand""" | 733 | """Entry point for the devtool 'modify' subcommand""" |
712 | import bb | 734 | import bb |
713 | import oe.recipeutils | 735 | import oe.recipeutils |
714 | import oe.patch | 736 | import oe.patch |
737 | import oe.path | ||
715 | 738 | ||
716 | if args.recipename in workspace: | 739 | if args.recipename in workspace: |
717 | raise DevtoolError("recipe %s is already in your workspace" % | 740 | raise DevtoolError("recipe %s is already in your workspace" % |
@@ -753,6 +776,59 @@ def modify(args, config, basepath, workspace): | |||
753 | initial_rev = None | 776 | initial_rev = None |
754 | commits = [] | 777 | commits = [] |
755 | check_commits = False | 778 | check_commits = False |
779 | |||
780 | if bb.data.inherits_class('kernel-yocto', rd): | ||
781 | # Current set kernel version | ||
782 | kernelVersion = rd.getVar('LINUX_VERSION') | ||
783 | srcdir = rd.getVar('STAGING_KERNEL_DIR') | ||
784 | kbranch = rd.getVar('KBRANCH') | ||
785 | |||
786 | staging_kerVer = get_staging_kver(srcdir) | ||
787 | staging_kbranch = get_staging_kbranch(srcdir) | ||
788 | if (os.path.exists(srcdir) and os.listdir(srcdir)) and (kernelVersion in staging_kerVer and staging_kbranch == kbranch): | ||
789 | oe.path.copyhardlinktree(srcdir,srctree) | ||
790 | workdir = rd.getVar('WORKDIR') | ||
791 | srcsubdir = rd.getVar('S') | ||
792 | localfilesdir = os.path.join(srctree,'oe-local-files') | ||
793 | # Move local source files into separate subdir | ||
794 | recipe_patches = [os.path.basename(patch) for patch in oe.recipeutils.get_recipe_patches(rd)] | ||
795 | local_files = oe.recipeutils.get_recipe_local_files(rd) | ||
796 | |||
797 | for key in local_files.copy(): | ||
798 | if key.endswith('scc'): | ||
799 | sccfile = open(local_files[key], 'r') | ||
800 | for l in sccfile: | ||
801 | line = l.split() | ||
802 | if line and line[0] in ('kconf', 'patch'): | ||
803 | cfg = os.path.join(os.path.dirname(local_files[key]), line[-1]) | ||
804 | if not cfg in local_files.values(): | ||
805 | local_files[line[-1]] = cfg | ||
806 | shutil.copy2(cfg, workdir) | ||
807 | sccfile.close() | ||
808 | |||
809 | # Ignore local files with subdir={BP} | ||
810 | srcabspath = os.path.abspath(srcsubdir) | ||
811 | local_files = [fname for fname in local_files if os.path.exists(os.path.join(workdir, fname)) and (srcabspath == workdir or not os.path.join(workdir, fname).startswith(srcabspath + os.sep))] | ||
812 | if local_files: | ||
813 | for fname in local_files: | ||
814 | _move_file(os.path.join(workdir, fname), os.path.join(srctree, 'oe-local-files', fname)) | ||
815 | with open(os.path.join(srctree, 'oe-local-files', '.gitignore'), 'w') as f: | ||
816 | f.write('# Ignore local files, by default. Remove this file ''if you want to commit the directory to Git\n*\n') | ||
817 | |||
818 | symlink_oelocal_files_srctree(rd,srctree) | ||
819 | |||
820 | task = 'do_configure' | ||
821 | res = tinfoil.build_targets(pn, task, handle_events=True) | ||
822 | |||
823 | # Copy .config to workspace | ||
824 | kconfpath = rd.getVar('B') | ||
825 | logger.info('Copying kernel config to workspace') | ||
826 | shutil.copy2(os.path.join(kconfpath, '.config'),srctree) | ||
827 | |||
828 | # Set this to true, we still need to get initial_rev | ||
829 | # by parsing the git repo | ||
830 | args.no_extract = True | ||
831 | |||
756 | if not args.no_extract: | 832 | if not args.no_extract: |
757 | initial_rev, _ = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) | 833 | initial_rev, _ = _extract_source(srctree, args.keep_temp, args.branch, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) |
758 | if not initial_rev: | 834 | if not initial_rev: |