[OE-core] [OE-Core][master][PATCH] menuconfig: Add mechanism for user to append to same devtool fragment after user runs finish

Sai Hari Chandana Kalluri chandana.kalluri at xilinx.com
Mon Oct 7 18:14:18 UTC 2019


In current devtool flow, if user runs devtool modify, menuconfig and
finish, it will create a devtool-fragment.cfg and append to SRC_URI of
the recipe.

When a user runs the same flow multiple times, the devtool-fragment.cfg
created in previous iteration gets replaced with the new fragment
created in the current iteration. As a result, user can lose config
changes made previously.

Provide menuconfig with an option -a or --allow-append that lets users
to continue append to previous iteration of devtool-fragment.cfg.
	Ex. devtool menuconfig linux-xlnx -a

By default, the devtool flow will replace the config fragment unless
specified with the -a option.

Signed-off-by: Sai Hari Chandana Kalluri <chandana.kalluri at xilinx.com>
---
 scripts/lib/devtool/menuconfig.py | 31 ++++++++++++++++++++-----------
 scripts/lib/devtool/standard.py   | 20 +++++++++++++++++++-
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/scripts/lib/devtool/menuconfig.py b/scripts/lib/devtool/menuconfig.py
index 95384c5..d718844 100644
--- a/scripts/lib/devtool/menuconfig.py
+++ b/scripts/lib/devtool/menuconfig.py
@@ -32,10 +32,8 @@ def menuconfig(args, config, basepath, workspace):
     """Entry point for the devtool 'menuconfig' subcommand"""
 
     rd = ""
-    kconfigpath = ""
-    pn_src = ""
     localfilesdir = ""
-    workspace_dir = ""
+    fragname = "devtool-fragment.cfg"
     tinfoil = setup_tinfoil(basepath=basepath)
     try:
         rd = parse_recipe(config, tinfoil, args.component, appends=True, filter_workspace=False)
@@ -48,12 +46,10 @@ def menuconfig(args, config, basepath, workspace):
         if not rd.getVarFlag('do_menuconfig','task'):
             raise DevtoolError("This recipe does not support menuconfig option")
 
-        workspace_dir = os.path.join(config.workspace_path,'sources')
-        kconfigpath = rd.getVar('B')
-        pn_src = os.path.join(workspace_dir,pn)
+        srctree=rd.getVar('S',True)
 
         # add check to see if oe_local_files exists or not
-        localfilesdir = os.path.join(pn_src,'oe-local-files')
+        localfilesdir = os.path.join(srctree,'oe-local-files')
         if not os.path.exists(localfilesdir):
             bb.utils.mkdirhier(localfilesdir)
             # Add gitignore to ensure source tree is clean
@@ -62,18 +58,31 @@ def menuconfig(args, config, basepath, workspace):
                 f.write('# Ignore local files, by default. Remove this file if you want to commit the directory to Git\n')
                 f.write('*\n')
 
+        if args.allow_append:
+            with open(os.path.join(srctree,'.run-devtool-menuconfig'),'w') as f:
+                f.write('RUN-DEVTOOL-MENUCONFIG=1')
+
+
     finally:
-        tinfoil.shutdown()
+      tinfoil.shutdown()
+
+    if args.allow_append:
+	    if not os.path.exists(os.path.join(localfilesdir,'devtool-fragment.cfg')):
+		    fragname = "devtool-fragment.cfg"
+	    else:
+		    fragname = "devtool-fragment_tmp001.cfg"
 
     logger.info('Launching menuconfig')
     exec_build_env_command(config.init_path, basepath, 'bitbake -c menuconfig %s' % pn, watch=True)
-    fragment = os.path.join(localfilesdir, 'devtool-fragment.cfg')
-    res = standard._create_kconfig_diff(pn_src,rd,fragment)
+
+    fragment = os.path.join(localfilesdir, fragname)
+    res = standard._create_kconfig_diff(srctree,rd,fragment)
 
     return 0
 
 def register_commands(subparsers, context):
     """register devtool subcommands from this plugin"""
-    parser_menuconfig = subparsers.add_parser('menuconfig',help='Alter build-time configuration for a recipe', description='Launches the make menuconfig command (for recipes where do_menuconfig is available), allowing users to make changes to the build-time configuration. Creates a config fragment corresponding to changes made.', group='advanced')
+    parser_menuconfig = subparsers.add_parser('menuconfig',help='Alter build-time configuration for a recipe', description='Launches the make menuconfig command(for recipes where do_menuconfig is available), allowing users to make changes to the build-time configuration. Creates a config fragment corresponding to changes made.', group='advanced') 
     parser_menuconfig.add_argument('component', help='compenent to alter config')
+    parser_menuconfig.add_argument('-a','--allow-append',action="store_true",help='append devtool-fragment.cfg to previous iteration fragment')
     parser_menuconfig.set_defaults(func=menuconfig,fixed_setup=context.fixed_setup)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1c0cd8a..a3941d9 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1382,6 +1382,24 @@ def _export_local_files(srctree, rd, destdir, srctreebase):
     removed = OrderedDict()
     local_files_dir = os.path.join(srctreebase, 'oe-local-files')
     git_files = _git_ls_tree(srctree)
+
+    tmpfragname=os.path.join(local_files_dir,'devtool-fragment_tmp001.cfg')
+
+    run_do_menuconfig = 0
+    checkmenuconfig = os.path.join(srctreebase,'.run-devtool-menuconfig')
+    if os.path.exists(checkmenuconfig):
+	    with open(checkmenuconfig,'r') as f:
+		    if 'RUN-DEVTOOL-MENUCONFIG=1' in f.read():
+			    run_do_menuconfig = 1
+	    os.remove(checkmenuconfig)
+
+    if os.path.exists(tmpfragname):
+	    with open(tmpfragname,"r") as fin:
+		    tempfragcontents=fin.read()
+	    with open(os.path.join(local_files_dir,'devtool-fragment.cfg'),"+a") as fout:
+		    fout.write(tempfragcontents)
+	    os.remove(tmpfragname)
+
     if 'oe-local-files' in git_files:
         # If tracked by Git, take the files from srctree HEAD. First get
         # the tree object of the directory
@@ -1400,7 +1418,7 @@ def _export_local_files(srctree, rd, destdir, srctreebase):
         new_set = []
 
     # Special handling for kernel config
-    if bb.data.inherits_class('kernel-yocto', rd):
+    if not run_do_menuconfig and bb.data.inherits_class('kernel-yocto', rd):
         fragment_fn = 'devtool-fragment.cfg'
         fragment_path = os.path.join(destdir, fragment_fn)
         if _create_kconfig_diff(srctree, rd, fragment_path):
-- 
2.7.4



More information about the Openembedded-core mailing list