[OE-core] [OE-Core][master][PATCH 0/2] Devtool reset --remove-work

2019-11-26 Thread Sai Hari Chandana Kalluri
This patch series contains two patches: 
  
1.  update the devtool reset --remove-work user prints according to previous 
review comments. 
2.  The second patch adds devtool oe-selftest for devtool reset --remove-work.  
  
There are two test cases for devtool reset --remove-work:   
  
a. One that ensures when users runs devtool reset the source is not deleted 
by default.   
b. The second test case ensures devtool reset --remove-work command cleans 
the source directory  

Sai Hari Chandana Kalluri (2):
  reset --remove-work: Modify the remove-work print messages
  oeselftest: devtool reset --remove-work command

 meta/lib/oeqa/selftest/cases/devtool.py | 49 +
 scripts/lib/devtool/standard.py |  8 --
 2 files changed, 54 insertions(+), 3 deletions(-)

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH 1/2] reset --remove-work: Modify the remove-work print messages

2019-11-26 Thread Sai Hari Chandana Kalluri
reset --remove-work: Modify the devtool reset remove-work print messages to
provide more details.

Signed-off-by: Sai Hari Chandana Kalluri 
---
 scripts/lib/devtool/standard.py | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1c0cd8a..10a29e7 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1931,8 +1931,8 @@ def _reset(recipes, no_clean, remove_work, config, 
basepath, workspace):
 if os.path.isdir(srctreebase):
 if os.listdir(srctreebase):
 if remove_work:
-logger.info('-r argument used on %s, removing source 
tree.'
-' You will lose any unsaved work' %pn)
+logger.info('Removing source tree for %s as requested'
+'(-r option).' %pn)
 shutil.rmtree(srctreebase)
 else:
 # We don't want to risk wiping out any work in progress
@@ -2282,7 +2282,9 @@ def register_commands(subparsers, context):
 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset 
all recipes (clear workspace)')
 parser_reset.add_argument('--no-clean', '-n', action="store_true", 
help='Don\'t clean the sysroot to remove recipe output')
-parser_reset.add_argument('--remove-work', '-r', action="store_true", 
help='Clean the sources directory along with append')
+parser_reset.add_argument('--remove-work', '-r', action="store_true",
+help='Also delete the working sources tree (NOTE: will delete'
+'unsaved work')
 parser_reset.set_defaults(func=reset)
 
 parser_finish = subparsers.add_parser('finish', help='Finish working on a 
recipe in your workspace',
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH 2/2] oeselftest: devtool reset --remove-work command

2019-11-26 Thread Sai Hari Chandana Kalluri
Add oeselftest for devtool reset command. DevtoolResetTests class can be used
to test devtool reset command behaviour wrt to source directory in workspace.

The first test test_devtool_reset_package will verify if the source directory
is present for a package once the workspace is reset.

Example usage: oeselftest -r
devtool.DevtoolResetTests.test_devtool_reset_package

The second test test_devtool_reset_remove_work_package will verify if the
source directory is cleaned up during workspace reset.

Example usage: oeselftest -r
devtool.DevtoolResetTests.test_devtool_reset_remove_work_package

Signed-off-by: Sai Hari Chandana Kalluri 
---
 meta/lib/oeqa/selftest/cases/devtool.py | 49 +
 1 file changed, 49 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py 
b/meta/lib/oeqa/selftest/cases/devtool.py
index 57e6662..f6093c0 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -1777,3 +1777,52 @@ class DevtoolUpgradeTests(DevtoolBase):
 #Step 4.5
 checkmodconfg = runCmd("grep %s %s" % (modconfopt, codeconfigfile))
 self.assertEqual(0,checkmodconfg.status,'Modification to configuration 
file failed')
+
+class DevtoolResetTests(DevtoolBase):
+def test_devtool_reset_package(self):
+"""
+Summary:The purpose of this test case is to verify that
+devtool reset cleans the workspace without
+removing the source directory.
+Dependencies:   NA
+Steps:  1. Use devtool modify mdadm to extract source to 
workspace.
+2. Use devtool reset mdadm to verify that workspace is 
reset
+by clearing the sysroot and the append file. But 
source folder
+is not removed by default.
+Expected:   devtool reset by default doesnt clean the source 
folder of the
+package and the user is forced to manual remove it.
+"""
+# Extract a recipe
+tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+self.track_for_cleanup(tempdir)
+self.track_for_cleanup(self.workspacedir)
+self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+
sourcedir=os.path.join(os.path.join(self.workspacedir,"sources"),"mdadm")
+result = runCmd('devtool modify mdadm')
+result = runCmd('devtool reset mdadm')
+self.assertTrue('Leaving source tree', result.output)
+self.assertExists(sourcedir,'the source directory is missing when it 
should be present')
+
+def test_devtool_reset_remove_work_package(self):
+"""
+Summary:The purpose of this test case is to verify that
+devtool reset -r cleans the workspace as well as
+removes the source directory.
+Dependencies:   NA
+Steps:  1. Use devtool modify mdadm to extract source to 
workspace.
+2. Use devtool reset --remove-work mdadm to verify 
that workspace is reset
+by clearing the sysroot and the append file and source 
folder
+removed.
+Expected:   devtool reset --remove-work will clean the source 
folder of the
+package along with the appendfile and sysroot.
+"""
+# Extract a recipe
+tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+self.track_for_cleanup(tempdir)
+self.track_for_cleanup(self.workspacedir)
+self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+
sourcedir=os.path.join(os.path.join(self.workspacedir,"sources"),"mdadm")
+result = runCmd('devtool modify mdadm')
+result = runCmd('devtool reset -r mdadm')
+self.assertTrue('Removing source tree', result.output)
+self.assertNotExists(sourcedir,'the source directory is present when 
it should have been removed')
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH] devtool: Add --remove-work option for devtool reset command

2019-10-07 Thread Sai Hari Chandana Kalluri
Enable --remove-work option for devtool reset command that allows user
to clean up source directory within workspace.

Currently devtool reset command only removes recipes and user is forced
to manually remove the sources directory within the workspace before
running devtool modify again.

Using devtool reset -r or devtool reset --remove-work option, user can
cleanup the sources directory along with the recipe instead of manually
cleaning it.

syntax: devtool reset -r 
Ex: devtool reset -r zip

devtool finish -r  
Ex: devtool finish -r zip meta-yocto-bsp

Signed-off-by: Sai Hari Chandana Kalluri 
---
 scripts/lib/devtool/standard.py | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 60c9a04..1c0cd8a 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1852,7 +1852,7 @@ def status(args, config, basepath, workspace):
 return 0
 
 
-def _reset(recipes, no_clean, config, basepath, workspace):
+def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
 """Reset one or more recipes"""
 import oe.path
 
@@ -1930,10 +1930,15 @@ def _reset(recipes, no_clean, config, basepath, 
workspace):
 srctreebase = workspace[pn]['srctreebase']
 if os.path.isdir(srctreebase):
 if os.listdir(srctreebase):
-# We don't want to risk wiping out any work in progress
-logger.info('Leaving source tree %s as-is; if you no '
-'longer need it then please delete it manually'
-% srctreebase)
+if remove_work:
+logger.info('-r argument used on %s, removing source 
tree.'
+' You will lose any unsaved work' %pn)
+shutil.rmtree(srctreebase)
+else:
+# We don't want to risk wiping out any work in progress
+logger.info('Leaving source tree %s as-is; if you no '
+'longer need it then please delete it 
manually'
+% srctreebase)
 else:
 # This is unlikely, but if it's empty we can just remove it
 os.rmdir(srctreebase)
@@ -1943,6 +1948,10 @@ def _reset(recipes, no_clean, config, basepath, 
workspace):
 def reset(args, config, basepath, workspace):
 """Entry point for the devtool 'reset' subcommand"""
 import bb
+import shutil
+
+recipes = ""
+
 if args.recipename:
 if args.all:
 raise DevtoolError("Recipe cannot be specified if -a/--all is 
used")
@@ -1957,7 +1966,7 @@ def reset(args, config, basepath, workspace):
 else:
 recipes = args.recipename
 
-_reset(recipes, args.no_clean, config, basepath, workspace)
+_reset(recipes, args.no_clean, args.remove_work, config, basepath, 
workspace)
 
 return 0
 
@@ -2009,6 +2018,7 @@ def finish(args, config, basepath, workspace):
 raise DevtoolError('Source tree is not clean:\n\n%s\nEnsure you 
have committed your changes or use -f/--force if you are sure there\'s nothing 
that needs to be committed' % dirty)
 
 no_clean = args.no_clean
+remove_work=args.remove_work
 tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
 try:
 rd = parse_recipe(config, tinfoil, args.recipename, True)
@@ -2160,7 +2170,7 @@ def finish(args, config, basepath, workspace):
 if args.dry_run:
 logger.info('Resetting recipe (dry-run)')
 else:
-_reset([args.recipename], no_clean=no_clean, config=config, 
basepath=basepath, workspace=workspace)
+_reset([args.recipename], no_clean=no_clean, remove_work=remove_work, 
config=config, basepath=basepath, workspace=workspace)
 
 return 0
 
@@ -2272,6 +2282,7 @@ def register_commands(subparsers, context):
 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset 
all recipes (clear workspace)')
 parser_reset.add_argument('--no-clean', '-n', action="store_true", 
help='Don\'t clean the sysroot to remove recipe output')
+parser_reset.add_argument('--remove-work', '-r', action="store_true", 
help='Clean the sources directory along with append')
 parser_reset.set_defaults(func=reset)
 
 parser_finish = subparsers.add_parser('finish', help='Finish working on a 
recipe in your workspace',
@@ -2282,6 +2293,7 @@ def register_commands(subparsers, context):
 parser_finish.add_argument('--mode', '-m', choices=['patch', 'srcrev', 
'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; 
default is %(default)s)', 

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

2019-10-07 Thread Sai Hari Chandana Kalluri
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 
---
 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()
  

[OE-core] [OE-Core][master][PATCH] devtool: Add --remove-work option for devtool reset command

2019-10-04 Thread Sai Hari Chandana Kalluri
Enable --remove-work option for devtool reset command that allows user
to clean up source directory within workspace.

Currently devtool reset command only removes recipes and user is forced
to manually remove the sources directory within the workspace before
running devtool modify again.

Using devtool reset -r or devtool reset --remove-work option, user can
cleanup the sources directory along with the recipe instead of manually
cleaning it.

syntax: devtool reset -r 
Ex: devtool reset -r zip

devtool finish -r  
Ex: devtool finish -r zip meta-yocto-bsp

Signed-off-by: Sai Hari Chandana Kalluri 
---
 scripts/lib/devtool/standard.py | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 60c9a04..1c0cd8a 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1852,7 +1852,7 @@ def status(args, config, basepath, workspace):
 return 0
 
 
-def _reset(recipes, no_clean, config, basepath, workspace):
+def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
 """Reset one or more recipes"""
 import oe.path
 
@@ -1930,10 +1930,15 @@ def _reset(recipes, no_clean, config, basepath, 
workspace):
 srctreebase = workspace[pn]['srctreebase']
 if os.path.isdir(srctreebase):
 if os.listdir(srctreebase):
-# We don't want to risk wiping out any work in progress
-logger.info('Leaving source tree %s as-is; if you no '
-'longer need it then please delete it manually'
-% srctreebase)
+if remove_work:
+logger.info('-r argument used on %s, removing source 
tree.'
+' You will lose any unsaved work' %pn)
+shutil.rmtree(srctreebase)
+else:
+# We don't want to risk wiping out any work in progress
+logger.info('Leaving source tree %s as-is; if you no '
+'longer need it then please delete it 
manually'
+% srctreebase)
 else:
 # This is unlikely, but if it's empty we can just remove it
 os.rmdir(srctreebase)
@@ -1943,6 +1948,10 @@ def _reset(recipes, no_clean, config, basepath, 
workspace):
 def reset(args, config, basepath, workspace):
 """Entry point for the devtool 'reset' subcommand"""
 import bb
+import shutil
+
+recipes = ""
+
 if args.recipename:
 if args.all:
 raise DevtoolError("Recipe cannot be specified if -a/--all is 
used")
@@ -1957,7 +1966,7 @@ def reset(args, config, basepath, workspace):
 else:
 recipes = args.recipename
 
-_reset(recipes, args.no_clean, config, basepath, workspace)
+_reset(recipes, args.no_clean, args.remove_work, config, basepath, 
workspace)
 
 return 0
 
@@ -2009,6 +2018,7 @@ def finish(args, config, basepath, workspace):
 raise DevtoolError('Source tree is not clean:\n\n%s\nEnsure you 
have committed your changes or use -f/--force if you are sure there\'s nothing 
that needs to be committed' % dirty)
 
 no_clean = args.no_clean
+remove_work=args.remove_work
 tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
 try:
 rd = parse_recipe(config, tinfoil, args.recipename, True)
@@ -2160,7 +2170,7 @@ def finish(args, config, basepath, workspace):
 if args.dry_run:
 logger.info('Resetting recipe (dry-run)')
 else:
-_reset([args.recipename], no_clean=no_clean, config=config, 
basepath=basepath, workspace=workspace)
+_reset([args.recipename], no_clean=no_clean, remove_work=remove_work, 
config=config, basepath=basepath, workspace=workspace)
 
 return 0
 
@@ -2272,6 +2282,7 @@ def register_commands(subparsers, context):
 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset 
all recipes (clear workspace)')
 parser_reset.add_argument('--no-clean', '-n', action="store_true", 
help='Don\'t clean the sysroot to remove recipe output')
+parser_reset.add_argument('--remove-work', '-r', action="store_true", 
help='Clean the sources directory along with append')
 parser_reset.set_defaults(func=reset)
 
 parser_finish = subparsers.add_parser('finish', help='Finish working on a 
recipe in your workspace',
@@ -2282,6 +2293,7 @@ def register_commands(subparsers, context):
 parser_finish.add_argument('--mode', '-m', choices=['patch', 'srcrev', 
'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; 
default is %(default)s)', 

[OE-core] [master][PATCH v5 0/3] Devtool: provide easy means of reconfiguring

2019-07-11 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in the
devtool flow. This would allow the user to modify the current configurations and
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire
source tree which is a bit of an over head in time and space. This patch series
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

--- 
  
changelog v2
1. Add a check to verify the set kernel version by user and kernel version  
  
present in work-shared before creating hard links to workspace.
2. Add a check to verify the set kernel version by user and kernel version  
  
present in workspace do not match, when placing a copy of kernel-source
from workspace to work-shared.

changelog v3
1. Use oe.path.copyhardlinktree() to create copy of source from work-shared to
devtool workspace.
2. Split all the changes into appropriate patches. Move all
menuconfig command specific changes under devtool menuconfig command patch
(3/3).
 
changelog v4
1. create a new function that implements the creation of symbolic links for
oe-local-files to workspace within _extract_sourcei(). This avoids code 
duplication
and allows the function to be reused within devtool modify when copying source 
from
work-shared to devtool workspace.
2. use check_workspace_recipe() within menuconfig.py

changelog v5
1. test against devtool oe-selftests and add missing function imports
2. rename function name from symblink_oelocal_files_srctree to 
symlink_oelocal_files_srctree
3. fix indendation

Sai Hari Chandana Kalluri (3):
  devtool/standard.py: Update devtool modify to copy source from
work-shared if its already downloaded
  devtool/standard.py: Create a copy of kernel source within work-shared
if not present
  devtool: provide support for devtool menuconfig command

 scripts/lib/devtool/menuconfig.py |  79 
 scripts/lib/devtool/standard.py   | 147 +++---
 2 files changed, 202 insertions(+), 24 deletions(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [master][PATCH 1/3] devtool/standard.py: Update devtool modify to copy source from work-shared if its already downloaded

2019-07-10 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by
running do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is
already downloaded. If so, then instead of calling do_fetch, copy the
source from work-shared to devtool workspace by creating hard links
else run the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 122 
 1 file changed, 99 insertions(+), 23 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 47ed531..2ac14b8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -461,6 +461,31 @@ def sync(args, config, basepath, workspace):
 finally:
 tinfoil.shutdown()
 
+def symlink_oelocal_files_srctree(rd,srctree):
+   import oe.patch
+   if os.path.abspath(rd.getVar('S')) == os.path.abspath(rd.getVar('WORKDIR')):
+   # If recipe extracts to ${WORKDIR}, symlink the files into the srctree
+   # (otherwise the recipe won't build as expected)
+ local_files_dir = os.path.join(srctree, 'oe-local-files')
+ addfiles = []
+ for root, _, files in os.walk(local_files_dir):
+ relpth = os.path.relpath(root, local_files_dir)
+ if relpth != '.':
+   bb.utils.mkdirhier(os.path.join(srctree, relpth))
+ for fn in files:
+ if fn == '.gitignore':
+ continue
+ destpth = os.path.join(srctree, relpth, fn)
+ if os.path.exists(destpth):
+ os.unlink(destpth)
+ os.symlink('oe-local-files/%s' % fn, destpth)
+ addfiles.append(os.path.join(relpth, fn))
+ if addfiles:
+bb.process.run('git add %s' % ' '.join(addfiles), cwd=srctree)
+ useroptions = []
+ oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=rd)
+ 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)
+
 
 def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, 
workspace, fixed_setup, d, tinfoil, no_overrides=False):
 """Extract sources of a recipe"""
@@ -617,29 +642,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 shutil.move(tempdir_localdir, srcsubdir)
 
 shutil.move(srcsubdir, srctree)
-
-if os.path.abspath(d.getVar('S')) == 
os.path.abspath(d.getVar('WORKDIR')):
-# If recipe extracts to ${WORKDIR}, symlink the files into the 
srctree
-# (otherwise the recipe won't build as expected)
-local_files_dir = os.path.join(srctree, 'oe-local-files')
-addfiles = []
-for root, _, files in os.walk(local_files_dir):
-relpth = os.path.relpath(root, local_files_dir)
-if relpth != '.':
-bb.utils.mkdirhier(os.path.join(srctree, relpth))
-for fn in files:
-if fn == '.gitignore':
-continue
-destpth = os.path.join(srctree, relpth, fn)
-if os.path.exists(destpth):
-os.unlink(destpth)
-os.symlink('oe-local-files/%s' % fn, destpth)
-addfiles.append(os.path.join(relpth, fn))
-if addfiles:
-bb.process.run('git add %s' % ' '.join(addfiles), 
cwd=srctree)
-useroptions = []
-oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
-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)
+symlink_oelocal_files_srctree(d,srctree)
 
 if is_kernel_yocto:
 logger.info('Copying kernel config to srctree')
@@ -707,11 +710,31 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+def get_staging_kver(srcdir):
+ #Kernel version from work-shared
+ kerver = []
+ staging_kerVer=""
+ if os.path.exists(srcdir) and os.listdir(srcdir):
+with open(os.path.join(srcdir,"Makefile")) as f:
+ version = [next(f) for x in range(5)][1:4]
+ for word in version:
+   kerver.append(word.split('= ')[1].split('\n')[0])
+ staging_kerVer = ".".join(kerver)
+ return staging_kerVer
+
+def get_staging_kbranch(srcdir):
+ 

[OE-core] [master][PATCH 2/3] devtool/standard.py: Create a copy of kernel source within work-shared if not present

2019-07-10 Thread Sai Hari Chandana Kalluri
If kernel source is not already downloaded i.e staging kernel dir is
empty, place a copy of the source when the user runs devtool modify
linux-yocto.  This way the kernel source is available for other packages
that use it.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 2ac14b8..0759211 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -491,6 +491,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 """Extract sources of a recipe"""
 import oe.recipeutils
 import oe.patch
+import oe.path
 
 pn = d.getVar('PN')
 
@@ -587,7 +588,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 with open(preservestampfile, 'w') as f:
 f.write(d.getVar('STAMP'))
 try:
-if bb.data.inherits_class('kernel-yocto', d):
+if is_kernel_yocto:
 # We need to generate the kernel config
 task = 'do_configure'
 else:
@@ -614,6 +615,23 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 raise DevtoolError('Something went wrong with source extraction - 
the devtool-source class was not active or did not function correctly:\n%s' % 
str(e))
 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 
'workdir'))
 
+# Check if work-shared is empty, if yes 
+# find source and copy to work-shared
+if is_kernel_yocto:
+  workshareddir = d.getVar('STAGING_KERNEL_DIR')
+  staging_kerVer = get_staging_kver(workshareddir) 
+  kernelVersion = d.getVar('LINUX_VERSION')
+
+  #handle dangling symbolic link in work-shared:
+  if(os.path.islink(workshareddir)):
+ os.unlink(workshareddir)
+
+  if (os.path.exists(workshareddir) and (not 
os.listdir(workshareddir) or kernelVersion!=staging_kerVer)): 
+   shutil.rmtree(workshareddir)
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+  elif (not os.path.exists(workshareddir)):
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+
 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
 srctree_localdir = os.path.join(srctree, 'oe-local-files')
 
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [master][PATCH 3/3] devtool: provide support for devtool menuconfig command

2019-07-10 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run
devtool menuconfig command. This would allow the user to modify the
current configure options and create a config fragment which can be
added to a recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes.
After saving the changes, diffconfig command is run to generate the
fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex:
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 79 +++
 scripts/lib/devtool/standard.py   |  5 +++
 2 files changed, 84 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..20d919b
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,79 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+from devtool import check_workspace_recipe
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  check_workspace_recipe(workspace, args.component)
+  pn =  rd.getVar('PN', True)
+
+  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)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+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')

[OE-core] [PATCH v2] run-postinsts: Fix full execution of scripts at first boot

2019-05-09 Thread Sai Hari Chandana Kalluri
From: Alejandro Enedino Hernandez Samaniego 

run-postinsts runs a given set of scripts during the first boot of the
device, when one of these scripts prints something to stdout (isnt
daemonized correctly), since stdout is not available at that time,
the script execution immediately returns with an error (exit_group()),
this error causes the script to terminate all threads within the process,
causing undesired behavior since the script might still had to execute
some other code.

Replace eval built-in with (), since () executes in a subshell,
even if one of the scripts exits, all threads of that process will only
be within that session, this ensures other scripts meant to be run are
still run afterwards.

[YOCTO #13266]

Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts 
b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
index 95eff04..f84a7e1 100755
--- a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
+++ b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
@@ -67,7 +67,7 @@ exec_postinst_scriptlets() {
echo "Running postinst $i..."
[ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst 
$i..." $append_log
if [ -x $i ]; then
-   eval sh -c $i $append_log
+   (sh -c $i $append_log)
rm $i
else
echo "ERROR: postinst $i failed."
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH v4 1/3] devtool/standard.py: Update devtool modify to copy source from work-shared if its already downloaded

2019-04-18 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by
running do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is
already downloaded. If so, then instead of calling do_fetch, copy the
source from work-shared to devtool workspace by creating hard links
else run the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 121 
 1 file changed, 98 insertions(+), 23 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 0a1e329..33193f8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -471,6 +471,30 @@ def sync(args, config, basepath, workspace):
 finally:
 tinfoil.shutdown()
 
+def symblink_oelocal_files_srctree(rd,srctree):
+   if os.path.abspath(rd.getVar('S')) == os.path.abspath(rd.getVar('WORKDIR')):
+   # If recipe extracts to ${WORKDIR}, symlink the files into the srctree
+   # (otherwise the recipe won't build as expected)
+ local_files_dir = os.path.join(srctree, 'oe-local-files')
+ addfiles = []
+ for root, _, files in os.walk(local_files_dir):
+ relpth = os.path.relpath(root, local_files_dir)
+ if relpth != '.':
+   bb.utils.mkdirhier(os.path.join(srctree, relpth))
+ for fn in files:
+ if fn == '.gitignore':
+ continue
+ destpth = os.path.join(srctree, relpth, fn)
+ if os.path.exists(destpth):
+ os.unlink(destpth)
+ os.symlink('oe-local-files/%s' % fn, destpth)
+ addfiles.append(os.path.join(relpth, fn))
+ if addfiles:
+bb.process.run('git add %s' % ' '.join(addfiles), cwd=srctree)
+ useroptions = []
+ oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
+ 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)
+
 
 def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, 
workspace, fixed_setup, d, tinfoil, no_overrides=False):
 """Extract sources of a recipe"""
@@ -627,29 +651,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 shutil.move(tempdir_localdir, srcsubdir)
 
 shutil.move(srcsubdir, srctree)
-
-if os.path.abspath(d.getVar('S')) == 
os.path.abspath(d.getVar('WORKDIR')):
-# If recipe extracts to ${WORKDIR}, symlink the files into the 
srctree
-# (otherwise the recipe won't build as expected)
-local_files_dir = os.path.join(srctree, 'oe-local-files')
-addfiles = []
-for root, _, files in os.walk(local_files_dir):
-relpth = os.path.relpath(root, local_files_dir)
-if relpth != '.':
-bb.utils.mkdirhier(os.path.join(srctree, relpth))
-for fn in files:
-if fn == '.gitignore':
-continue
-destpth = os.path.join(srctree, relpth, fn)
-if os.path.exists(destpth):
-os.unlink(destpth)
-os.symlink('oe-local-files/%s' % fn, destpth)
-addfiles.append(os.path.join(relpth, fn))
-if addfiles:
-bb.process.run('git add %s' % ' '.join(addfiles), 
cwd=srctree)
-useroptions = []
-oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
-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)
+symblink_oelocal_files_srctree(d,srctree)
 
 if is_kernel_yocto:
 logger.info('Copying kernel config to srctree')
@@ -717,11 +719,31 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+def get_staging_kver(srcdir):
+ #Kernel version from work-shared
+ kerver = []
+ staging_kerVer=""
+ if os.path.exists(srcdir) and os.listdir(srcdir):
+with open(os.path.join(srcdir,"Makefile")) as f:
+ version = [next(f) for x in range(5)][1:4]
+ for word in version:
+   kerver.append(word.split('= ')[1].split('\n')[0])
+ staging_kerVer = ".".join(kerver)
+ return staging_kerVer
+
+def get_staging_kbranch(srcdir):
+  staging_kbranch 

[OE-core] [OE-Core][master][PATCH v4 2/3] devtool/standard.py: Create a copy of kernel source within work-shared if not present

2019-04-18 Thread Sai Hari Chandana Kalluri
If kernel source is not already downloaded i.e staging kernel dir is
empty, place a copy of the source when the user runs devtool modify
linux-yocto.  This way the kernel source is available for other packages
that use it.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 33193f8..9267d6e 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -500,6 +500,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 """Extract sources of a recipe"""
 import oe.recipeutils
 import oe.patch
+import oe.path
 
 pn = d.getVar('PN')
 
@@ -596,7 +597,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 with open(preservestampfile, 'w') as f:
 f.write(d.getVar('STAMP'))
 try:
-if bb.data.inherits_class('kernel-yocto', d):
+if is_kernel_yocto:
 # We need to generate the kernel config
 task = 'do_configure'
 else:
@@ -623,6 +624,18 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 raise DevtoolError('Something went wrong with source extraction - 
the devtool-source class was not active or did not function correctly:\n%s' % 
str(e))
 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 
'workdir'))
 
+# Check if work-shared is empty, if yes 
+# find source and copy to work-shared
+if is_kernel_yocto:
+  workshareddir = d.getVar('STAGING_KERNEL_DIR')
+  staging_kerVer = get_staging_kver(workshareddir) 
+  kernelVersion = d.getVar('LINUX_VERSION')
+  if (os.path.exists(workshareddir) and (not 
os.listdir(workshareddir) or kernelVersion!=staging_kerVer)): 
+   shutil.rmtree(workshareddir)
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+  elif (not os.path.exists(workshareddir)):
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+
 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
 srctree_localdir = os.path.join(srctree, 'oe-local-files')
 
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH v4 3/3] devtool: provide support for devtool menuconfig command

2019-04-18 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run
devtool menuconfig command. This would allow the user to modify the
current configure options and create a config fragment which can be
added to a recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes.
After saving the changes, diffconfig command is run to generate the
fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex:
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 80 +++
 scripts/lib/devtool/standard.py   |  5 +++
 2 files changed, 85 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..0ebcf74
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,80 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+from devtool import check_workspace_recipe
+
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  check_workspace_recipe(workspace, args.component)
+  pn =  rd.getVar('PN', True)
+
+  if not rd.getVarFlag('do_menuconfig','task'):
+ raise DevtoolError("This recipe does not support menuconfig option")
+
+  workspace_dir = os.path.join(basepath,'workspace/sources')
+  kconfigpath = rd.getVar('B')
+  pn_src = os.path.join(workspace_dir,pn)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+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')

[OE-core] [OE-Core][master][PATCH v4 0/3] Devtool: provide easy means of

2019-04-17 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in the
devtool flow. This would allow the user to modify the current configurations and
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire
source tree which is a bit of an over head in time and space. This patch series
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

--- 
  
changelog v2
1. Add a check to verify the set kernel version by user and kernel version  
  
present in work-shared before creating hard links to workspace.
2. Add a check to verify the set kernel version by user and kernel version  
  
present in workspace do not match, when placing a copy of kernel-source
from workspace to work-shared.

changelog v3
1. Use oe.path.copyhardlinktree() to create copy of source from work-shared to
devtool workspace.
2. Split all the changes into appropriate patches. Move all
menuconfig command specific changes under devtool menuconfig command patch
(3/3).
 
changelog v4
1. create a new function that implements the creation of symbolic links for
oe-local-files to workspace within _extract_sourcei(). This avoids code 
duplication
and allows the function to be reused within devtool modify when copying source 
from
work-shared to devtool workspace.
2. use check_workspace_recipe() within menuconfig.py

Sai Hari Chandana Kalluri (3):
  devtool/standard.py: Update devtool modify to copy source from
work-shared if its already downloaded
  devtool/standard.py: Create a copy of kernel source within work-shared
if not present
  devtool: provide support for devtool menuconfig command

 scripts/lib/devtool/menuconfig.py |  80 +
 scripts/lib/devtool/standard.py   | 141 +++---
 2 files changed, 197 insertions(+), 24 deletions(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH v3 2/3] devtool/standard.py: Create a copy of kernel source within work-shared if not present

2019-03-29 Thread Sai Hari Chandana Kalluri
If kernel source is not already downloaded i.e staging kernel dir is
empty, place a copy of the source when the user runs devtool modify
linux-yocto. This way the kernel source is available for other packages
that use it.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 2338135..dc15c89 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -476,6 +476,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 """Extract sources of a recipe"""
 import oe.recipeutils
 import oe.patch
+import oe.path
 
 pn = d.getVar('PN')
 
@@ -572,7 +573,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 with open(preservestampfile, 'w') as f:
 f.write(d.getVar('STAMP'))
 try:
-if bb.data.inherits_class('kernel-yocto', d):
+if is_kernel_yocto:
 # We need to generate the kernel config
 task = 'do_configure'
 else:
@@ -599,6 +600,18 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 raise DevtoolError('Something went wrong with source extraction - 
the devtool-source class was not active or did not function correctly:\n%s' % 
str(e))
 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 
'workdir'))
 
+# Check if work-shared is empty, if yes 
+# find source and copy to work-shared
+if is_kernel_yocto:
+  workshareddir = d.getVar('STAGING_KERNEL_DIR')
+  staging_kerVer = get_staging_kver(workshareddir) 
+  kernelVersion = d.getVar('LINUX_VERSION')
+  if (os.path.exists(workshareddir) and (not 
os.listdir(workshareddir) or kernelVersion!=staging_kerVer)): 
+   shutil.rmtree(workshareddir)
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+  elif (not os.path.exists(workshareddir)):
+   oe.path.copyhardlinktree(srcsubdir,workshareddir)
+
 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
 srctree_localdir = os.path.join(srctree, 'oe-local-files')
 
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH v3 1/3] devtool/standard.py: Update devtool modify to copy source from work-shared if its already downloaded

2019-03-29 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by
running do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is
already downloaded. If so, then instead of calling do_fetch, copy the
source from work-shared to devtool workspace by creating hard links
else run the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 94 +
 1 file changed, 94 insertions(+)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ea09bbf..2338135 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -717,11 +717,31 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+def get_staging_kver(srcdir):
+ #Kernel version from work-shared
+ kerver = []
+ staging_kerVer=""
+ if os.path.exists(srcdir) and os.listdir(srcdir):
+with open(os.path.join(srcdir,"Makefile")) as f:
+ version = [next(f) for x in range(5)][1:4]
+ for word in version:
+   kerver.append(word.split('= ')[1].split('\n')[0])
+ staging_kerVer = ".".join(kerver)
+ return staging_kerVer
+
+def get_staging_kbranch(srcdir):
+  staging_kbranch = ""
+  if os.path.exists(srcdir) and os.listdir(srcdir):
+  (branch, _) = bb.process.run('git branch | grep \* | cut -d \' \' 
-f2', cwd=srcdir)
+  staging_kbranch = "".join(branch.split('\n')[0])
+  return staging_kbranch
+
 def modify(args, config, basepath, workspace):
 """Entry point for the devtool 'modify' subcommand"""
 import bb
 import oe.recipeutils
 import oe.patch
+import oe.path
 
 if args.recipename in workspace:
 raise DevtoolError("recipe %s is already in your workspace" %
@@ -763,6 +783,80 @@ def modify(args, config, basepath, workspace):
 initial_rev = None
 commits = []
 check_commits = False
+
+if bb.data.inherits_class('kernel-yocto', rd):
+   #Current set kernel version
+   kernelVersion = rd.getVar('LINUX_VERSION')
+   srcdir = rd.getVar('STAGING_KERNEL_DIR')
+   kbranch = rd.getVar('KBRANCH')
+
+   staging_kerVer = get_staging_kver(srcdir)
+   staging_kbranch = get_staging_kbranch(srcdir)
+   if (os.path.exists(srcdir) and os.listdir(srcdir)) and 
(kernelVersion in staging_kerVer and staging_kbranch == kbranch):
+  oe.path.copyhardlinktree(srcdir,srctree)
+  workdir = rd.getVar('WORKDIR')
+  srcsubdir = rd.getVar('S')
+  localfilesdir = os.path.join(srctree,'oe-local-files') 
+  # Move local source files into separate subdir
+  recipe_patches = [os.path.basename(patch) for patch in 
oe.recipeutils.get_recipe_patches(rd)]
+  local_files = oe.recipeutils.get_recipe_local_files(rd)
+
+  for key in local_files.copy():
+if key.endswith('scc'):
+  sccfile = open(local_files[key], 'r')
+  for l in sccfile:
+  line = l.split()
+  if line and line[0] in ('kconf', 'patch'):
+cfg = 
os.path.join(os.path.dirname(local_files[key]), line[-1])
+if not cfg in local_files.values():
+local_files[line[-1]] = cfg
+shutil.copy2(cfg, workdir)
+  sccfile.close()
+
+  # Ignore local files with subdir={BP}
+  srcabspath = os.path.abspath(srcsubdir)
+  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))]
+  if local_files:
+   for fname in local_files:
+  _move_file(os.path.join(workdir, fname), 
os.path.join(srctree, 'oe-local-files', fname))
+   with open(os.path.join(srctree, 'oe-local-files', 
'.gitignore'), 'w') as f:
+  f.write('# Ignore local files, by default. 
Remove this file ''if you want to commit the directory to Git\n*\n')
+
+  if os.path.abspath(rd.getVar('S')) == 
os.path.abspath(rd.getVar('WORKDIR')):
+  # If recipe extracts to ${WORKDIR}, symlink the 

[OE-core] [OE-Core][master][PATCH v3 0/3] Devtool: provide easy means of

2019-03-29 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in 
the 
devtool flow. This would allow the user to modify the current configurations 
and 
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire  
  
source tree which is a bit of an over head in time and space. This patch series 
   
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the 
user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

--- 
  
changelog v2
1. Add a check to verify the set kernel version by user and kernel version  
  
present in work-shared before creating hard links to workspace.
2. Add a check to verify the set kernel version by user and kernel version  
  
present in workspace do not match, when placing a copy of kernel-source
from workspace to work-shared. 
Sai Hari Chandana Kalluri (3):
  devtool modify: Update devtool modify to copy source from work-shared
if its already downloaded.
  devtool modify: Create a copy of kernel source within work-shared if
not present
  devtool: provide support for devtool menuconfig command.

changelog v3
1. Use oe.path.copyhardlinktree() to create copy of source from work-shared to
devtool workspace.
2. Split all the changes into appropriate patches. Move all
menuconfig command specific changes under devtool menuconfig command patch
(3/3).

Sai Hari Chandana Kalluri (3):
  devtool/standard.py: Update devtool modify to copy source from
work-shared if its already downloaded
  devtool/standard.py: Create a copy of kernel source within work-shared
if not present
  devtool: provide support for devtool menuconfig command

 scripts/lib/devtool/menuconfig.py |  80 ++
 scripts/lib/devtool/standard.py   | 114 +-
 2 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][master][PATCH v3 3/3] devtool: provide support for devtool menuconfig command

2019-03-28 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run
devtool menuconfig command. This would allow the user to modify the
current configure options and create a config fragment which can be
added to a recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes.
After saving the changes, diffconfig command is run to generate the
fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex: 
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 80 +++
 scripts/lib/devtool/standard.py   |  5 +++
 2 files changed, 85 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..f8a24aa
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,80 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  pn =  rd.getVar('PN', True)
+  if pn not in workspace:
+ raise DevtoolError("Run devtool modify before calling menuconfig for 
%s" %pn)
+
+  if not rd.getVarFlag('do_menuconfig','task'):
+ raise DevtoolError("This package does not support menuconfig option")
+
+  workspace_dir = os.path.join(basepath,'workspace/sources')
+  kconfigpath = rd.getVar('B')
+  pn_src = os.path.join(workspace_dir,pn)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+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 mad

[OE-core] [OE-Core][master][PATCH] standard.py: Provide an additional option for devtool reset

2019-02-08 Thread Sai Hari Chandana Kalluri
The devtool reset command cleans the sysroot for a recipe in workspace.
It also removes the append file but leaves the source code as in
workspace. The source is not cleaned intentionally and the user has to
manually remove it before calling devtool modify again.

Provide the user with an option to remove the source code from workspace
by adding a flag to the devtool reset command. The --rm-source option for
the devtool reset command will also clean the source code from the
workspace along with the sysroot and the append file.
Ex: devtool reset --rm-source zip or devtool reset -r zip

Signed-off-by: Sai Hari Chandana Kalluri 
---
 scripts/lib/devtool/standard.py | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index b7d4d47..e3bb0d1 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1751,7 +1751,7 @@ def status(args, config, basepath, workspace):
 return 0
 
 
-def _reset(recipes, no_clean, config, basepath, workspace):
+def _reset(recipes, no_clean, rm_source, config, basepath, workspace):
 """Reset one or more recipes"""
 import oe.path
 
@@ -1828,11 +1828,14 @@ def _reset(recipes, no_clean, config, basepath, 
workspace):
 
 srctreebase = workspace[pn]['srctreebase']
 if os.path.isdir(srctreebase):
-if os.listdir(srctreebase):
+if os.listdir(srctreebase) and not rm_source:
 # We don't want to risk wiping out any work in progress
 logger.info('Leaving source tree %s as-is; if you no '
 'longer need it then please delete it manually'
 % srctreebase)
+elif rm_source:
+ logger.info('Cleaning source tree from workspace ')
+ shutil.rmtree(srctreebase)
 else:
 # This is unlikely, but if it's empty we can just remove it
 os.rmdir(srctreebase)
@@ -1856,7 +1859,7 @@ def reset(args, config, basepath, workspace):
 else:
 recipes = args.recipename
 
-_reset(recipes, args.no_clean, config, basepath, workspace)
+_reset(recipes, args.no_clean, args.rm_source, config, basepath, workspace)
 
 return 0
 
@@ -2157,6 +2160,7 @@ def register_commands(subparsers, context):
 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset 
all recipes (clear workspace)')
 parser_reset.add_argument('--no-clean', '-n', action="store_true", 
help='Don\'t clean the sysroot to remove recipe output')
+parser_reset.add_argument('--rm-source', '-r', action="store_true", 
help='Remove source code from the workspace')
 parser_reset.set_defaults(func=reset)
 
 parser_finish = subparsers.add_parser('finish', help='Finish working on a 
recipe in your workspace',
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH v2 3/3] devtool: provide support for devtool menuconfig command.

2019-01-27 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run devtool
menuconfig command. This would allow the user to modify the current
configure options and create a config fragment which can be added to a
recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one
if needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex: 
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 80 +++
 1 file changed, 80 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..38133db
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,80 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  pn =  rd.getVar('PN', True)
+  if pn not in workspace:
+ raise DevtoolError("Run devtool modify before calling menuconfig for 
%s" %pn)
+
+  if not rd.getVarFlag('do_menuconfig','task'):
+ raise DevtoolError("This package does not support menuconfig option")
+
+  workspace_dir = os.path.join(basepath,'workspace/sources')
+  kconfigpath = rd.getVar('B')
+  pn_src = os.path.join(workspace_dir,pn)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+return 0
+
+def register_commands(subparsers, context):
+"""register devtool subcommands from this plugin"""
+parser_menuconfig = subparsers.add_parser('menuconfig',help='allows 
altering the system component configuration', description='launches the make 
menuconfig command, allows user to make changes to configuration. creates a 
config fragment', group='advanced') 
+parser_menuconfig.add_argument('component', help='compenent to alter 
config')
+
parser_menuco

[OE-core] [OE-Core][PATCH v2 2/3] devtool modify: Create a copy of kernel source within work-shared if not present

2019-01-26 Thread Sai Hari Chandana Kalluri
If kernel source is not already downloaded i.e staging kernel dir is
empty, place a copy of the source when the user runs devtool modify linux-yocto.
This way the kernel source is available for other packages that use it.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
changelog v2: 

1. Add a check to verify the set kernel version by user and kernel version 
present in workspace do not match before placing a copy of kernel-source 
from workspace to work-shared.

---

 scripts/lib/devtool/standard.py | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ba1afa4..24a0168 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -572,7 +572,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 with open(preservestampfile, 'w') as f:
 f.write(d.getVar('STAMP'))
 try:
-if bb.data.inherits_class('kernel-yocto', d):
+if is_kernel_yocto:
 # We need to generate the kernel config
 task = 'do_configure'
 else:
@@ -599,6 +599,18 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 raise DevtoolError('Something went wrong with source extraction - 
the devtool-source class was not active or did not function correctly:\n%s' % 
str(e))
 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 
'workdir'))
 
+# Check if work-shared is empty, if yes 
+# find source and copy to work-shared
+if is_kernel_yocto:
+  workshareddir = d.getVar('STAGING_KERNEL_DIR')
+  staging_kerVer = get_staging_kver(workshareddir) 
+  kernelVersion = d.getVar('LINUX_VERSION')
+  if (os.path.exists(workshareddir) and (not 
os.listdir(workshareddir) or kernelVersion!=staging_kerVer)): 
+   shutil.rmtree(workshareddir)
+   copy_src_to_ws(srcsubdir,workshareddir)
+  elif (not os.path.exists(workshareddir)):
+   copy_src_to_ws(srcsubdir,workshareddir)
+
 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
 srctree_localdir = os.path.join(srctree, 'oe-local-files')
 
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH v2 0/3] Devtool: provide easy means of reconfiguring

2019-01-25 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in 
the 
devtool flow. This would allow the user to modify the current configurations 
and 
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire  
  
source tree which is a bit of an over head in time and space. This patch series 
   
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the 
user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

--- 
  
changelog v2
1. Add a check to verify the set kernel version by user and kernel version  
  
present in work-shared before creating hard links to workspace.
2. Add a check to verify the set kernel version by user and kernel version  
  
present in workspace do not match, when placing a copy of kernel-source
from workspace to work-shared. 
Sai Hari Chandana Kalluri (3):
  devtool modify: Update devtool modify to copy source from work-shared
if its already downloaded.
  devtool modify: Create a copy of kernel source within work-shared if
not present
  devtool: provide support for devtool menuconfig command.

Sai Hari Chandana Kalluri (3):
  devtool modify: Update devtool modify to copy source from work-shared
if its already downloaded.
  devtool modify: Create a copy of kernel source within work-shared if
not present
  devtool: provide support for devtool menuconfig command.

 scripts/lib/devtool/menuconfig.py |  80 +++
 scripts/lib/devtool/standard.py   | 162 --
 2 files changed, 237 insertions(+), 5 deletions(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH v2 1/3] devtool modify: Update devtool modify to copy source from work-shared if its already downloaded.

2019-01-25 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by running
do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is already
downloaded. If so, then instead of calling do_fetch, copy the source
from work-shared to devtool workspace by creating hard links. Else run
the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
changelog v2: 
1. Add a check to verify the set kernel version by user and kernel version
present in work-shared before creating hard links. This is to ensure that right
kernel version is present in workspace.
---
 scripts/lib/devtool/standard.py | 148 ++--
 1 file changed, 144 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index b7d4d47..ba1afa4 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -717,6 +717,72 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+# Function links a file from src location to dest location
+def copy_file(c,dest):
+import errno
+destdir = os.path.dirname(dest)
+if os.path.islink(c):
+   linkto = os.readlink(c)
+   if os.path.lexists(dest):
+if not os.path.islink(dest):
+raise OSError(errno.EEXIST, "Link %s already exists as a file" 
% dest, dest)
+if os.readlink(dest) == linkto:
+return dest
+raise OSError(errno.EEXIST, "Link %s already exists to a different 
location? (%s vs %s)" % (dest, os.readlink(dest), linkto), dest)
+   os.symlink(linkto, dest)
+else:
+   try:
+   os.link(c, dest)
+   except OSError as err:
+   if err.errno == errno.EXDEV:
+bb.utils.copyfile(c, dest)
+   else:
+raise
+
+# Function creates folders in a given target location
+def copy_dirs(root,dirs,target):
+for d in dirs:
+destdir =  os.path.join(target,d)
+if os.path.islink(os.path.join(root,d)):
+ linkto = os.readlink(os.path.join(root,d))
+ os.symlink(linkto,destdir) 
+else:
+ bb.utils.mkdirhier(target+d)
+
+# Function to link src dir to dest dir
+def copy_src_to_ws(srcdir,srctree):
+target = srctree
+if os.path.exists(target):
+raise DevtoolError('source already in your workspace')
+
+bb.utils.mkdirhier(target)
+for root,dirs,files in os.walk(srcdir):
+#convert abspath to relpath for root
+destdir = root.replace(srcdir,"")
+target = srctree+destdir+"/"
+copy_dirs(root,dirs,target)  
+for f in files:
+   copy_file(os.path.join(root,f),os.path.join(target,f))
+
+def get_staging_kver(srcdir):
+ #Kernel version from work-shared
+ kerver = []
+ staging_kerVer=""
+ if os.path.exists(srcdir) and os.listdir(srcdir):
+with open(os.path.join(srcdir,"Makefile")) as f:
+ version = [next(f) for x in range(5)][1:4]
+ for word in version:
+   kerver.append(word.split('= ')[1].split('\n')[0])
+ staging_kerVer = ".".join(kerver)
+ return staging_kerVer
+
+def get_staging_kbranch(srcdir):
+  staging_kbranch = ""
+  if os.path.exists(srcdir) and os.listdir(srcdir):
+  (branch, _) = bb.process.run('git branch | grep \* | cut -d \' \' 
-f2', cwd=srcdir)
+  staging_kbranch = "".join(branch.split('\n')[0])
+  return staging_kbranch
+
 def modify(args, config, basepath, workspace):
 """Entry point for the devtool 'modify' subcommand"""
 import bb
@@ -763,6 +829,78 @@ def modify(args, config, basepath, workspace):
 initial_rev = None
 commits = []
 check_commits = False
+
+if bb.data.inherits_class('kernel-yocto', rd):
+   #Current set kernel version
+   kernelVersion = rd.getVar('LINUX_VERSION')
+   srcdir = rd.getVar('STAGING_KERNEL_DIR')
+   kbranch = rd.getVar('KBRANCH')
+
+   staging_kerVer = get_staging_kver(srcdir)
+   staging_kbranch = get_staging_kbranch(srcdir)
+   if (os.path.exists(srcdir) and os.listdir(srcdir)) and 
(kernelVersion in staging_kerVer and staging_kbranch == kbranch):
+  copy_src_to_ws(srcdir,srctree)
+  workdir = rd.getVar('WORKDIR')
+  srcsubdir = rd.getVar('S')
+  localfilesdir = os.path.join(srctree,'oe-local-files') 
+  # Move local source files into separate subdir
+  recipe_patches = [os.path.basename(patch) for pa

[OE-core] [OE-Core][PATCH 3/3] devtool: provide support for devtool menuconfig command.

2018-12-05 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run devtool
menuconfig command. This would allow the user to modify the current
configure options and create a config fragment which can be added to a
recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one
if needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex: 
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 80 +++
 1 file changed, 80 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..38133db
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,80 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  pn =  rd.getVar('PN', True)
+  if pn not in workspace:
+ raise DevtoolError("Run devtool modify before calling menuconfig for 
%s" %pn)
+
+  if not rd.getVarFlag('do_menuconfig','task'):
+ raise DevtoolError("This package does not support menuconfig option")
+
+  workspace_dir = os.path.join(basepath,'workspace/sources')
+  kconfigpath = rd.getVar('B')
+  pn_src = os.path.join(workspace_dir,pn)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+return 0
+
+def register_commands(subparsers, context):
+"""register devtool subcommands from this plugin"""
+parser_menuconfig = subparsers.add_parser('menuconfig',help='allows 
altering the system component configuration', description='launches the make 
menuconfig command, allows user to make changes to configuration. creates a 
config fragment', group='advanced') 
+parser_menuconfig.add_argument('component', help='compenent to alter 
config')
+
parser_menuco

[OE-core] [OE-Core][PATCH 1/3] devtool modify: Update devtool modify to copy source from work-shared if its already downloaded.

2018-12-05 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by running
do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is already
downloaded. If so, then instead of calling do_fetch, copy the source from
work-shared to devtool workspace by creating hard links to be more efficient.
Else run the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 124 ++--
 1 file changed, 120 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index d14b7a6..3a8222a 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -712,6 +712,53 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+# Function links a file from src location to dest location
+def copy_file(c,dest):
+import errno
+destdir = os.path.dirname(dest)
+if os.path.islink(c):
+   linkto = os.readlink(c)
+   if os.path.lexists(dest):
+if not os.path.islink(dest):
+raise OSError(errno.EEXIST, "Link %s already exists as a file" 
% dest, dest)
+if os.readlink(dest) == linkto:
+return dest
+raise OSError(errno.EEXIST, "Link %s already exists to a different 
location? (%s vs %s)" % (dest, os.readlink(dest), linkto), dest)
+   os.symlink(linkto, dest)
+else:
+   try:
+   os.link(c, dest)
+   except OSError as err:
+   if err.errno == errno.EXDEV:
+bb.utils.copyfile(c, dest)
+   else:
+raise
+
+# Function creates folders in a given target location
+def copy_dirs(root,dirs,target):
+for d in dirs:
+destdir =  os.path.join(target,d)
+if os.path.islink(os.path.join(root,d)):
+ linkto = os.readlink(os.path.join(root,d))
+ os.symlink(linkto,destdir) 
+else:
+ bb.utils.mkdirhier(target+d)
+
+# Function to link src dir to dest dir
+def copy_src_to_ws(srcdir,srctree):
+target = srctree
+if os.path.exists(target):
+raise DevtoolError('source already in your workspace')
+
+bb.utils.mkdirhier(target)
+for root,dirs,files in os.walk(srcdir):
+#convert abspath to relpath for root
+destdir = root.replace(srcdir,"")
+target = srctree+destdir+"/"
+copy_dirs(root,dirs,target)  
+for f in files:
+   copy_file(os.path.join(root,f),os.path.join(target,f))
+
 def modify(args, config, basepath, workspace):
 """Entry point for the devtool 'modify' subcommand"""
 import bb
@@ -758,6 +805,73 @@ def modify(args, config, basepath, workspace):
 initial_rev = None
 commits = []
 check_commits = False
+
+if bb.data.inherits_class('kernel-yocto', rd):
+   srcdir = rd.getVar('STAGING_KERNEL_DIR')
+   if os.path.exists(srcdir) and os.listdir(srcdir):
+  copy_src_to_ws(srcdir,srctree)
+
+  workdir = rd.getVar('WORKDIR')
+  srcsubdir = rd.getVar('S')
+  localfilesdir = os.path.join(srctree,'oe-local-files') 
+  # Move local source files into separate subdir
+  recipe_patches = [os.path.basename(patch) for patch in 
oe.recipeutils.get_recipe_patches(rd)]
+  local_files = oe.recipeutils.get_recipe_local_files(rd)
+
+  for key in local_files.copy():
+if key.endswith('scc'):
+  sccfile = open(local_files[key], 'r')
+  for l in sccfile:
+  line = l.split()
+  if line and line[0] in ('kconf', 'patch'):
+local_files[line[-1]] = 
os.path.join(os.path.dirname(local_files[key]), line[-1])
+
shutil.copy2(os.path.join(os.path.dirname(local_files[key]), line[-1]), workdir)
+  sccfile.close()
+
+  # Ignore local files with subdir={BP}
+  srcabspath = os.path.abspath(srcsubdir)
+  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))]
+  if local_files:
+   for fname in local_files:
+  copy_src_to_ws(os.path.join(workdir, fname), 
os.path.join(srctree, 'oe-local-files', fname))
+   with open(os.path.join(srctree, 'oe-local-files', 
'.gitignore'), '

[OE-core] [OE-Core][PATCH 2/3] devtool modify: Create a copy of kernel source

2018-12-05 Thread Sai Hari Chandana Kalluri
If kernel source is not already downloaded i.e staging kernel dir is
empty, place a copy of the source when the user runs devtool modify linux-yocto.
This way the kernel source is available for other packages that use it.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 3a8222a..06a0619 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -567,7 +567,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 with open(preservestampfile, 'w') as f:
 f.write(d.getVar('STAMP'))
 try:
-if bb.data.inherits_class('kernel-yocto', d):
+if is_kernel_yocto:
 # We need to generate the kernel config
 task = 'do_configure'
 else:
@@ -594,6 +594,14 @@ def _extract_source(srctree, keep_temp, devbranch, sync, 
config, basepath, works
 raise DevtoolError('Something went wrong with source extraction - 
the devtool-source class was not active or did not function correctly:\n%s' % 
str(e))
 srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 
'workdir'))
 
+# Check if work-shared is empty, if yes 
+# find source and copy to work-shared
+if is_kernel_yocto:
+  workshareddir = d.getVar('STAGING_KERNEL_DIR')
+  if os.path.exists(workshareddir) and not 
os.listdir(workshareddir):
+   os.rmdir(workshareddir)
+   copy_src_to_ws(srcsubdir,workshareddir)
+
 tempdir_localdir = os.path.join(tempdir, 'oe-local-files')
 srctree_localdir = os.path.join(srctree, 'oe-local-files')
 
-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH 0/3] Devtool: provide easy means of reconfiguring the kernel

2018-12-04 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in 
the 
devtool flow. This would allow the user to modify the current configurations 
and 
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire
source tree which is a bit of an over head in time and space. This patch series
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

Sai Hari Chandana Kalluri (3):
  devtool modify: Update devtool modify to copy source from work-shared
if its already downloaded.
  devtool modify: Create a copy of kernel source within work-shared if
not present
  devtool: provide support for devtool menuconfig command.

 scripts/lib/devtool/menuconfig.py |  80 +++
 scripts/lib/devtool/standard.py   | 134 --
 2 files changed, 209 insertions(+), 5 deletions(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH 1/3] devtool modify: Update devtool modify to copy source from work-shared if its already downloaded.

2018-12-04 Thread Sai Hari Chandana Kalluri
In the regular devtool modify flow, the kernel source is fetched by running
do_fetch task. This is an overhead in time and space.

This patch updates modify command to check if the kernel source is already
downloaded. If so, then instead of calling do_fetch, copy the source from
work-shared to devtool workspace by creating hard links to be more efficient.
Else run the usual devtool modify flow and call do_fetch task.

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/standard.py | 124 ++--
 1 file changed, 120 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index d14b7a6..3a8222a 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -712,6 +712,53 @@ def _check_preserve(config, recipename):
 tf.write(line)
 os.rename(newfile, origfile)
 
+# Function links a file from src location to dest location
+def copy_file(c,dest):
+import errno
+destdir = os.path.dirname(dest)
+if os.path.islink(c):
+   linkto = os.readlink(c)
+   if os.path.lexists(dest):
+if not os.path.islink(dest):
+raise OSError(errno.EEXIST, "Link %s already exists as a file" 
% dest, dest)
+if os.readlink(dest) == linkto:
+return dest
+raise OSError(errno.EEXIST, "Link %s already exists to a different 
location? (%s vs %s)" % (dest, os.readlink(dest), linkto), dest)
+   os.symlink(linkto, dest)
+else:
+   try:
+   os.link(c, dest)
+   except OSError as err:
+   if err.errno == errno.EXDEV:
+bb.utils.copyfile(c, dest)
+   else:
+raise
+
+# Function creates folders in a given target location
+def copy_dirs(root,dirs,target):
+for d in dirs:
+destdir =  os.path.join(target,d)
+if os.path.islink(os.path.join(root,d)):
+ linkto = os.readlink(os.path.join(root,d))
+ os.symlink(linkto,destdir) 
+else:
+ bb.utils.mkdirhier(target+d)
+
+# Function to link src dir to dest dir
+def copy_src_to_ws(srcdir,srctree):
+target = srctree
+if os.path.exists(target):
+raise DevtoolError('source already in your workspace')
+
+bb.utils.mkdirhier(target)
+for root,dirs,files in os.walk(srcdir):
+#convert abspath to relpath for root
+destdir = root.replace(srcdir,"")
+target = srctree+destdir+"/"
+copy_dirs(root,dirs,target)  
+for f in files:
+   copy_file(os.path.join(root,f),os.path.join(target,f))
+
 def modify(args, config, basepath, workspace):
 """Entry point for the devtool 'modify' subcommand"""
 import bb
@@ -758,6 +805,73 @@ def modify(args, config, basepath, workspace):
 initial_rev = None
 commits = []
 check_commits = False
+
+if bb.data.inherits_class('kernel-yocto', rd):
+   srcdir = rd.getVar('STAGING_KERNEL_DIR')
+   if os.path.exists(srcdir) and os.listdir(srcdir):
+  copy_src_to_ws(srcdir,srctree)
+
+  workdir = rd.getVar('WORKDIR')
+  srcsubdir = rd.getVar('S')
+  localfilesdir = os.path.join(srctree,'oe-local-files') 
+  # Move local source files into separate subdir
+  recipe_patches = [os.path.basename(patch) for patch in 
oe.recipeutils.get_recipe_patches(rd)]
+  local_files = oe.recipeutils.get_recipe_local_files(rd)
+
+  for key in local_files.copy():
+if key.endswith('scc'):
+  sccfile = open(local_files[key], 'r')
+  for l in sccfile:
+  line = l.split()
+  if line and line[0] in ('kconf', 'patch'):
+local_files[line[-1]] = 
os.path.join(os.path.dirname(local_files[key]), line[-1])
+
shutil.copy2(os.path.join(os.path.dirname(local_files[key]), line[-1]), workdir)
+  sccfile.close()
+
+  # Ignore local files with subdir={BP}
+  srcabspath = os.path.abspath(srcsubdir)
+  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))]
+  if local_files:
+   for fname in local_files:
+  copy_src_to_ws(os.path.join(workdir, fname), 
os.path.join(srctree, 'oe-local-files', fname))
+   with open(os.path.join(srctree, 'oe-local-files', 
'.gitignore'), '

[OE-core] [OE-Core][PATCH 0/3] Devtool: provide easy means of reconfiguring the kernel

2018-12-04 Thread Sai Hari Chandana Kalluri
This patch series provides support for the user to run menuconfig command in 
the 
devtool flow. This would allow the user to modify the current configurations 
and 
generate a config fragment to update the recipe using devtool finish. Devtool
menuconfig command will work on all packages that contain menuconfig as a task.

1. The implementation checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one if
needed, this directory is needed to store the final generated config fragment so
that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Currently, when the user runs devtool modify command, it checks out the entire
source tree which is a bit of an over head in time and space. This patch series
also provides a way to create a copy(hard links) of the kernel source, if
present, from work-shared to workspace to be more efficient .

Also, if the kernel source is not present in the staging kernel dir and the user
fetches the source tree in workspace using devtool modify, then this patch
series creates a copy of source from workspace to work-shared. This is
necessary for packages that may use the kernel source.

[YOCTO #10416]

Sai Hari Chandana Kalluri (3):
  devtool modify: Update devtool modify to copy source from work-shared
if its already downloaded.
  devtool modify: Create a copy of kernel source within work-shared if
not present
  devtool: provide support for devtool menuconfig command.

 scripts/lib/devtool/menuconfig.py |  80 +++
 scripts/lib/devtool/standard.py   | 134 --
 2 files changed, 209 insertions(+), 5 deletions(-)
 create mode 100644 scripts/lib/devtool/menuconfig.py

-- 
2.7.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [OE-Core][PATCH 3/3] devtool: provide support for devtool menuconfig command.

2018-12-04 Thread Sai Hari Chandana Kalluri
All packages that support the menuconfig task will be able to run devtool
menuconfig command. This would allow the user to modify the current
configure options and create a config fragment which can be added to a
recipe using devtool finish.

1. The patch checks if devtool menuconfig command is called for a valid
package.
2. It checks for oe-local-files dir within source and creates one
if needed, this directory is needed to store the final generated config
fragment so that devtool finish can update the recipe.
3. Menuconfig command is called for users to make necessary changes. After
saving the changes, diffconfig command is run to generate the fragment.

Syntax:
devtool menuconfig 
 Ex: devtool menuconfig linux-yocto

The config fragment is saved as devtool-fragment.cfg within
oe-local-files dir.

Ex: 
/sources/linux-yocto/oe-local-files/devtool-fragment.cfg

Run devtool finish to update the recipe by appending the config fragment
to SRC_URI and place a copy of the fragment within the layer where the
recipe resides.
Ex: devtool finish linux-yocto meta

[YOCTO #10416]

Signed-off-by: Sai Hari Chandana Kalluri 
Signed-off-by: Alejandro Enedino Hernandez Samaniego 
---
 scripts/lib/devtool/menuconfig.py | 80 +++
 1 file changed, 80 insertions(+)
 create mode 100644 scripts/lib/devtool/menuconfig.py

diff --git a/scripts/lib/devtool/menuconfig.py 
b/scripts/lib/devtool/menuconfig.py
new file mode 100644
index 000..38133db
--- /dev/null
+++ b/scripts/lib/devtool/menuconfig.py
@@ -0,0 +1,80 @@
+# OpenEmbedded Development tool - menuconfig command plugin
+#
+# Copyright (C) 2018 Xilinx
+# Written by: Chandana Kalluri 
+#
+# 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
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Devtool menuconfig plugin"""
+
+import os
+import bb
+import logging
+import argparse
+import re
+import glob
+from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, 
exec_build_env_command
+
+logger = logging.getLogger('devtool')
+
+def menuconfig(args, config, basepath, workspace):
+"""Entry point for the devtool 'menuconfig' subcommand"""
+
+rd = "" 
+kconfigpath = ""
+pn_src = ""
+localfilesdir = ""
+workspace_dir = ""
+tinfoil = setup_tinfoil(basepath=basepath)
+try:
+  rd = parse_recipe(config, tinfoil, args.component, appends=True, 
filter_workspace=False)
+  if not rd:
+ return 1
+
+  pn =  rd.getVar('PN', True)
+  if pn not in workspace:
+ raise DevtoolError("Run devtool modify before calling menuconfig for 
%s" %pn)
+
+  if not rd.getVarFlag('do_menuconfig','task'):
+ raise DevtoolError("This package does not support menuconfig option")
+
+  workspace_dir = os.path.join(basepath,'workspace/sources')
+  kconfigpath = rd.getVar('B')
+  pn_src = os.path.join(workspace_dir,pn)
+
+  #add check to see if oe_local_files exists or not
+  localfilesdir = os.path.join(pn_src,'oe-local-files') 
+  if not os.path.exists(localfilesdir):
+  bb.utils.mkdirhier(localfilesdir)
+  #Add gitignore to ensure source tree is clean
+  gitignorefile = os.path.join(localfilesdir,'.gitignore')
+  with open(gitignorefile, 'w') as f:
+  f.write('# Ignore local files, by default. Remove this file 
if you want to commit the directory to Git\n')
+  f.write('*\n')
+
+finally:
+  tinfoil.shutdown()
+
+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)
+
+return 0
+
+def register_commands(subparsers, context):
+"""register devtool subcommands from this plugin"""
+parser_menuconfig = subparsers.add_parser('menuconfig',help='allows 
altering the system component configuration', description='launches the make 
menuconfig command, allows user to make changes to configuration. creates a 
config fragment', group='advanced') 
+parser_menuconfig.add_argument('component', help='compenent to alter 
config')
+
parser_menuco