summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/devtool/standard.py56
1 files changed, 55 insertions, 1 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ad2c4f7235..f2beb6f2f2 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -20,6 +20,7 @@ import os
20import sys 20import sys
21import re 21import re
22import shutil 22import shutil
23import subprocess
23import tempfile 24import tempfile
24import logging 25import logging
25import argparse 26import argparse
@@ -775,6 +776,10 @@ def modify(args, config, basepath, workspace):
775 if bb.data.inherits_class('kernel', rd): 776 if bb.data.inherits_class('kernel', rd):
776 f.write('SRCTREECOVEREDTASKS = "do_validate_branches do_kernel_checkout ' 777 f.write('SRCTREECOVEREDTASKS = "do_validate_branches do_kernel_checkout '
777 'do_fetch do_unpack do_patch do_kernel_configme do_kernel_configcheck"\n') 778 'do_fetch do_unpack do_patch do_kernel_configme do_kernel_configcheck"\n')
779 f.write('\ndo_configure_append() {\n'
780 ' cp ${B}/.config ${S}/.config.baseline\n'
781 ' ln -sfT ${B}/.config ${S}/.config\n'
782 '}\n')
778 if initial_rev: 783 if initial_rev:
779 f.write('\n# initial_rev: %s\n' % initial_rev) 784 f.write('\n# initial_rev: %s\n' % initial_rev)
780 for commit in commits: 785 for commit in commits:
@@ -916,6 +921,33 @@ def _export_patches(srctree, rd, start_rev, destdir):
916 return (updated, added, existing_patches) 921 return (updated, added, existing_patches)
917 922
918 923
924def _create_kconfig_diff(srctree, rd, outfile):
925 """Create a kconfig fragment"""
926 # Only update config fragment if both config files exist
927 orig_config = os.path.join(srctree, '.config.baseline')
928 new_config = os.path.join(srctree, '.config')
929 if os.path.exists(orig_config) and os.path.exists(new_config):
930 cmd = ['diff', '--new-line-format=%L', '--old-line-format=',
931 '--unchanged-line-format=', orig_config, new_config]
932 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
933 stderr=subprocess.PIPE)
934 stdout, stderr = pipe.communicate()
935 if pipe.returncode == 1:
936 logger.info("Updating config fragment %s" % outfile)
937 with open(outfile, 'w') as fobj:
938 fobj.write(stdout)
939 elif pipe.returncode == 0:
940 logger.info("Would remove config fragment %s" % outfile)
941 if os.path.exists(outfile):
942 # Remove fragment file in case of empty diff
943 logger.info("Removing config fragment %s" % outfile)
944 os.unlink(outfile)
945 else:
946 raise bb.process.ExecutionError(cmd, pipe.returncode, stdout, stderr)
947 return True
948 return False
949
950
919def _export_local_files(srctree, rd, destdir): 951def _export_local_files(srctree, rd, destdir):
920 """Copy local files from srctree to given location. 952 """Copy local files from srctree to given location.
921 Returns three-tuple of dicts: 953 Returns three-tuple of dicts:
@@ -936,6 +968,7 @@ def _export_local_files(srctree, rd, destdir):
936 updated = OrderedDict() 968 updated = OrderedDict()
937 added = OrderedDict() 969 added = OrderedDict()
938 removed = OrderedDict() 970 removed = OrderedDict()
971 local_files_dir = os.path.join(srctree, 'oe-local-files')
939 git_files = _git_ls_tree(srctree) 972 git_files = _git_ls_tree(srctree)
940 if 'oe-local-files' in git_files: 973 if 'oe-local-files' in git_files:
941 # If tracked by Git, take the files from srctree HEAD. First get 974 # If tracked by Git, take the files from srctree HEAD. First get
@@ -946,11 +979,32 @@ def _export_local_files(srctree, rd, destdir):
946 env=dict(os.environ, GIT_WORK_TREE=destdir, 979 env=dict(os.environ, GIT_WORK_TREE=destdir,
947 GIT_INDEX_FILE=tmp_index)) 980 GIT_INDEX_FILE=tmp_index))
948 new_set = _git_ls_tree(srctree, tree, True).keys() 981 new_set = _git_ls_tree(srctree, tree, True).keys()
949 elif os.path.isdir(os.path.join(srctree, 'oe-local-files')): 982 elif os.path.isdir(local_files_dir):
950 # If not tracked by Git, just copy from working copy 983 # If not tracked by Git, just copy from working copy
951 new_set = _ls_tree(os.path.join(srctree, 'oe-local-files')) 984 new_set = _ls_tree(os.path.join(srctree, 'oe-local-files'))
952 bb.process.run(['cp', '-ax', 985 bb.process.run(['cp', '-ax',
953 os.path.join(srctree, 'oe-local-files', '.'), destdir]) 986 os.path.join(srctree, 'oe-local-files', '.'), destdir])
987 else:
988 new_set = []
989
990 # Special handling for kernel config
991 if bb.data.inherits_class('kernel-yocto', rd):
992 fragment_fn = 'devtool-fragment.cfg'
993 fragment_path = os.path.join(destdir, fragment_fn)
994 if _create_kconfig_diff(srctree, rd, fragment_path):
995 if os.path.exists(fragment_path):
996 if fragment_fn not in new_set:
997 new_set.append(fragment_fn)
998 # Copy fragment to local-files
999 if os.path.isdir(local_files_dir):
1000 shutil.copy2(fragment_path, local_files_dir)
1001 else:
1002 if fragment_fn in new_set:
1003 new_set.remove(fragment_fn)
1004 # Remove fragment from local-files
1005 if os.path.exists(os.path.join(local_files_dir, fragment_fn)):
1006 os.unlink(os.path.join(local_files_dir, fragment_fn))
1007
954 if new_set is not None: 1008 if new_set is not None:
955 for fname in new_set: 1009 for fname in new_set:
956 if fname in existing_files: 1010 if fname in existing_files: