list-packageconfig-flag.py: add a script to list all PACKAGECONFIG's flags
cover list-packageconfig-flag.py: add a script to list all PACKAGECONFIG's flags
Usage: list-packageconfig-flag.py [OPTION] [METADIR]...
list recipes which have PACKAGECONFIG's flags in METADIR
OPTION:
-h, --help display this help and exit
-f, --flag list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:list-packageconfig-flag.py poky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================
libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py -f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================
speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc
//Hongxu
The following changes since commit 67864ca79da08df752487a3a4e1a975546da123d:
systemd: Remove systemd_unitdir if systemd is not in distro features (2013-07-24 11:35:39 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib hongxu/list-pkgconfigflag
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/list-pkgconfigflag
Hongxu Jia (1):
list-packageconfig-flag.py: add a script to list all PACKAGECONFIG's
flags
scripts/contrib/list-packageconfig-flag.py | 180 +++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 scripts/contrib/list-packageconfig-flag.py
Signature · 1 line
1.8.1.2
PATCH 1/1 list-packageconfig-flag.py: add a script to list all PACKAGECONFIG's flags
list-packageconfig-flag.py will walk the METADIR and collect recipes which have PACKAGECONFIG's flags.
The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:list-packageconfig-flag.py poky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================
libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py -f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================
speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc
[YOCTO #4368]
--- scripts/contrib/list-packageconfig-flag.py | 180 +++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 scripts/contrib/list-packageconfig-flag.py
scripts/contrib/list-packageconfig-flag.py new file +180 -0
@@ -0,0 +1,180 @@ +#!/usr/bin/env python + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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. +# +# Copyright (C) 2013 Wind River Systems, Inc. +# +# list recipes which have PACKAGECONFIG's flags in METADIR +# list PACKAGECONFIG's flags and all affected recipes in METADIR +# + +import sys +import getopt +import os +import re + +usage_body = ''' list recipes which have PACKAGECONFIG's flags in METADIR + +OPTION: + -h, --help display this help and exit + -f, --flag list PACKAGECONFIG's flags and all affected recipes in METADIR + +EXAMPLE: +list-packageconfig-flag.py poky/meta poky/meta-yocto +list-packageconfig-flag.py -f poky/meta poky/meta-yocto +''' + +def usage(): + print 'Usage: %s [OPTION] [METADIR]...' % os.path.basename(sys.argv[0]) + print usage_body + +def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags ''' + prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist + +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR ''' + # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdict + +def collect_flags(recipesdict): + ''' Collect PACKAGECONFIG's flags and all affected recipes in recipesdict ''' + # flagsdict = {'flag': ['recipe1', 'recipe2',...]} + flagsdict = {} + for recipename,flaglist in recipesdict.iteritems(): + for flag in flaglist: + if flag in flagsdict: + flagsdict[flag].append(recipename) + else: + flagsdict[flag] = [recipename] + + return flagsdict + +def display_recipes(recipesdict): + ''' Display recipes which have PACKAGECONFIG's flags in recipesdict ''' + recipename_len = len("RECIPE NAME") + 1 + for recipename in recipesdict: + if recipename_len < len(recipename): + recipename_len = len(recipename) + recipename_len += 1 + + header = '%-*s%s' % (recipename_len, str("RECIPE NAME"), str("PACKAGECONFIG's flag")) + print header + print str("").ljust(len(header), '=') + for recipename, flaglist in recipesdict.iteritems(): + print('%-*s%s' % (recipename_len, recipename, ' '.join(flaglist))) + + +def display_flags(flagsdict): + ''' Display PACKAGECONFIG's flags and all affected recipes in flagsdict ''' + flag_len = len("PACKAGECONFIG's flag") + 5 + + header = '%-*s%s' % (flag_len, str("PACKAGECONFIG's flag"), str("RECIPE NAME")) + print header + print str("").ljust(len(header), '=') + + for flag in flagsdict: + print('%-*s%s' % (flag_len, flag, ' '.join(flagsdict[flag]))) + +def filter_subdirs(dirlist): + '''Filter out subdirs in dirlist''' + def dir_is_subdir(dir, dirlist): + for curdir in dirlist: + dirs = dir.split('/') + curdirs = curdir.split('/') + curdirsdepth = len(curdirs) + if curdirsdepth < len(dirs): + if dirs[:curdirsdepth] == curdirs[:curdirsdepth]: + return True + return False + + for curdir in dirlist[:]: + if dir_is_subdir(curdir, dirlist): + dirlist.remove(curdir) + +def main(): + metadirs = [] + listtype = 'recipes' + recipesdict = {} + flagsdict = {} + + # Collect and validate input + try: + opts, args = getopt.getopt(sys.argv[1:], "hf", ["help", "flag"]) + except getopt.GetoptError, err: + print >> sys.stderr,'%s' % str(err) + usage() + sys.exit(2) + for opt, value in opts: + if opt in ('-h', '--help'): + usage() + sys.exit(0) + elif opt in ('-f', '--flag'): + listtype = 'flags' + else: + assert False, "unhandled option" + + for metadir in args: + if os.path.isdir(metadir): + metadir = os.path.abspath(metadir) + if metadir not in metadirs: + metadirs.append(metadir) + else: + print >> sys.stderr, 'ERROR: meta directory \'%s\' is not a directory' % (metadir) + sys.exit(3) + + if len(metadirs) == 0: + print >> sys.stderr, 'ERROR: no metadir specified' + usage() + sys.exit(4) + else: + # Filter out subdirs to save time + filter_subdirs(metadirs) + + # Collect recipes which have PACKAGECONFIG's flags in metadirs + for metadir in metadirs: + recipesdict.update(process_recipes(metadir)) + + if listtype == 'flags': + # Collect PACKAGECONFIG's flags and all affected recipes in recipesdict + flagsdict = collect_flags(recipesdict) + display_flags(flagsdict) + elif listtype == 'recipes': + display_recipes(recipesdict) + +if __name__ == "__main__": + main()
Signature · 1 line
1.8.1.2
Quoted 18 lines · Hongxu Jia
list-packageconfig-flag.pywill walk the METADIR and collect recipes which have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================
Quoted 7 lines
speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc[YOCTO #4368]
Signed-off-by Hongxu Jia <[email protected]>
Cool! :-)
Quoted 1 line
scripts/contrib/list-packageconfig-flag.py | 180 +++++++++++++++++++++++++++++
I'd drop .py extension and use +x permission.
Quoted 71 lines
1 file changed, 180 insertions(+) create mode 100755 scripts/contrib/list-packageconfig-flag.pyscripts/contrib/list-packageconfig-flag.py new file +62
-0@@ -0,0 +1,180 @@ +#!/usr/bin/env python + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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. +# +# Copyright (C) 2013 Wind River Systems, Inc. +# +# list recipes which have PACKAGECONFIG's flags in METADIR +# list PACKAGECONFIG's flags and all affected recipes in METADIR +# + +import sys +import getopt +import os +import re + +usage_body = ''' list recipes which have PACKAGECONFIG's flags in METADIR + +OPTION: + -h, --help display this help and exit + -f, --flag list PACKAGECONFIG's flags and all affected recipes in METADIR + +EXAMPLE: +list-packageconfig-flag.py poky/meta poky/meta-yocto +list-packageconfig-flag.py -f poky/meta poky/meta-yocto +''' + +def usage(): + print 'Usage: %s [OPTION] [METADIR]...' % os.path.basename(sys.argv[0]) + print usage_body + +def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags ''' + prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist + +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR '''
scripts/contrib/list-packageconfig-flag.py line 72
Quoted 10 lines
scripts/contrib/list-packageconfig-flag.py new file +10
-0+ # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdict
In case a PACKAGECONFIG is add by a class. I think this case is missing here.
Signature · 3 lines
Otavio Salvador O.S. Systems http://www.ossystems.com.br http://projetos.ossystems.com.br Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
Quoted 23 lines · Otavio Salvador
Quoted 22 lines · Hongxu Jia
list-packageconfig-flag.pywill walk the METADIR and collect recipes which have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc
Quoted 8 lines
Quoted 3 lines
[YOCTO #4368]
Signed-off-by Hongxu Jia <[email protected]>Cool! :-)
Quoted 1 line
scripts/contrib/list-packageconfig-flag.py | 180 +++++++++++++++++++++++++++++I'd drop .py extension and use +x permission.
Most scripts in scripts/contrib have '.py' or '.sh' extension, is it the rule to be followed or not?
It looks like the following 'new file mode 10755' means +x permission is used.
Quoted 74 lines
Quoted 74 lines
1 file changed, 180 insertions(+)create mode 100755
scripts/contrib/list-packageconfig-flag.pyscripts/contrib/list-packageconfig-flag.py new file +65
-0@@ -0,0 +1,180 @@ +#!/usr/bin/env python + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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. +# +# Copyright (C) 2013 Wind River Systems, Inc. +# +# list recipes which have PACKAGECONFIG's flags in METADIR +# list PACKAGECONFIG's flags and all affected recipes in METADIR +# + +import sys +import getopt +import os +import re + +usage_body = ''' list recipes which have PACKAGECONFIG's flags in METADIR + +OPTION: + -h, --help display this help and exit + -f, --flag list PACKAGECONFIG's flags and all affected recipes in METADIR + +EXAMPLE: +list-packageconfig-flag.py poky/meta poky/meta-yocto +list-packageconfig-flag.py -f poky/meta poky/meta-yocto +''' + +def usage(): + print 'Usage: %s [OPTION] [METADIR]...' % os.path.basename(sys.argv[0]) + print usage_body + +def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags ''' + prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist + +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR ''' + # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir):
Quoted 8 lines
scripts/contrib/list-packageconfig-flag.py line 72
Quoted 7 lines
scripts/contrib/list-packageconfig-flag.py new file +7
-0+ for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdictIn case a PACKAGECONFIG is add by a class. I think this case is missing here.
Agree, sorry for the missing, I will add it.
Thanks,
Hongxu
Quoted 1 line
Quoted 37 lines · Hongxu Jia
Quoted 36 lines · Otavio Salvador
Quoted 23 lines · Hongxu Jia
list-packageconfig-flag.pywill walk the METADIR and collect recipes which
have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in
METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all
affected recipes in METADIREXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================
libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat
strace_4.8.bb libaio acl
connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================Quoted 7 lines
speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc[YOCTO #4368]
Signed-off-by Hongxu Jia <[email protected]>Cool! :-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
scripts/contrib/list-packageconfig-flag.py | 180+++++++++++++++++++++++++++++
I'd drop .py extension and use +x permission.
Most scripts in
scripts/contribhave '.py' or '.sh' extension, is it the rule to be followed or not?
I'd prefer to not have the .py and .sh extensions. The script language is a technical detail and it does not seem important to be evident. But I'd say for now, keep it and we can change it in a later patch.
Quoted 2 lines
It looks like the following 'new file mode 10755' means +x permission is used.
Missed.
Quoted 90 lines
Quoted 81 lines
Quoted 81 lines
1 file changed, 180 insertions(+)create mode 100755
scripts/contrib/list-packageconfig-flag.pyscripts/contrib/list-packageconfig-flag.py new file +14
-0@@ -0,0 +1,180 @@ +#!/usr/bin/env python + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 SoftwareFoundation.
scripts/contrib/list-packageconfig-flag.py new file +13
-0+# +# Copyright (C) 2013 Wind River Systems, Inc. +# +# list recipes which have PACKAGECONFIG's flags in METADIR +# list PACKAGECONFIG's flags and all affected recipes in METADIR +# + +import sys +import getopt +import os +import re + +usage_body = ''' list recipes which have PACKAGECONFIG's flags inMETADIR
scripts/contrib/list-packageconfig-flag.py new file +4
-0+ +OPTION: + -h, --help display this help and exit + -f, --flag list PACKAGECONFIG's flags and all affected recipes inMETADIR
scripts/contrib/list-packageconfig-flag.py new file +8
-0+ +EXAMPLE: +list-packageconfig-flag.py poky/meta poky/meta-yocto +list-packageconfig-flag.py -f poky/meta poky/meta-yocto +''' + +def usage(): + print 'Usage: %s [OPTION] [METADIR]...' %
os.path.basename(sys.argv[0])scripts/contrib/list-packageconfig-flag.py new file +28
-0+ print usage_body + +def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags ''' + prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist + +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR ''' + # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0:Quoted 8 lines
scripts/contrib/list-packageconfig-flag.py line 72
Quoted 5 lines
scripts/contrib/list-packageconfig-flag.py new file +5
-0+ flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdictIn case a PACKAGECONFIG is add by a class. I think this case is missing here.
Quoted 1 line
Agree, sorry for the missing, I will add it.
Thanks.
Signature · 3 lines
Otavio Salvador O.S. Systems http://www.ossystems.com.br http://projetos.ossystems.com.br Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
Hi Hongxu,
Great idea! This should be very useful indeed.
Just a few feedback points:
Quoted 22 lines · On Thursday 01 August 2013 19:04:05 Hongxu Jia wrote:
list-packageconfig-flag.pywill walk the METADIR and collect recipes which have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc
Quoted 7 lines
[YOCTO #4368]
Signed-off-by Hongxu Jia <[email protected]>--- scripts/contrib/list-packageconfig-flag.py | 180 +++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 scripts/contrib/list-packageconfig-flag.py
I think the script ought to be called "list-packageconfig-flags" rather than "list-packageconfig-flag".
scripts/contrib/list-packageconfig-flag.py line 43
Quoted 3 lines
...
scripts/contrib/list-packageconfig-flag.py new file +2
-0+def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags '''
This should say "collect available PACKAGECONFIG flags". The same applies to other messages/comments.
Quoted 19 lines
scripts/contrib/list-packageconfig-flag.py new file +18
-0+ prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR '''
scripts/contrib/list-packageconfig-flag.py line 72
Quoted 10 lines
scripts/contrib/list-packageconfig-flag.py new file +10
-0+ # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdict
So, this is fairly simple and works for most cases; however it would probably be a bit more robust if the script used bitbake's own parser to extract the flags. The "tinfoil" module should help with this. We can always address this in a follow-up patch later on, though - I can certainly show you some examples of how to do this or I can do it, whichever you prefer.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 31 lines · Paul Eggleton
Hi Hongxu,
Great idea! This should be very useful indeed.
Just a few feedback points:
Quoted 24 lines · On Thursday 01 August 2013 19:04:05 Hongxu Jia wrote:
list-packageconfig-flag.pywill walk the METADIR and collect recipes which have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.inc[YOCTO #4368]
Quoted 8 lines
Quoted 5 lines
Signed-off-by Hongxu Jia <[email protected]>--- scripts/contrib/list-packageconfig-flag.py | 180+++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+)
create mode 100755scripts/contrib/list-packageconfig-flag.pyI think the script ought to be called "list-packageconfig-flags" rather than "list-packageconfig-flag".
Agree, I will rename it.
Quoted 6 lines
scripts/contrib/list-packageconfig-flag.py line 43
Quoted 3 lines
...
scripts/contrib/list-packageconfig-flag.py new file +2
-0+def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags '''This should say "collect available PACKAGECONFIG flags". The same applies to other messages/comments.
Agree
Quoted 26 lines
Quoted 26 lines
scripts/contrib/list-packageconfig-flag.py new file +25
-0+ prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR ''' + # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist:
Quoted 8 lines
scripts/contrib/list-packageconfig-flag.py line 72
Quoted 3 lines
scripts/contrib/list-packageconfig-flag.py new file +3
-0+ recipesdict[name] = flaglist + + return recipesdictSo, this is fairly simple and works for most cases; however it would probably be a bit more robust if the script used bitbake's own parser to extract the flags. The "tinfoil" module should help with this. We can always address this in a follow-up patch later on, though - I can certainly show you some examples of how to do this or I can do it, whichever you prefer.
Great, this is what I hope to do in the follow-up, I am very pleased to do the investigate on bitbake parser, very thankful to share some examples of how to do this with me.
Should this simple patch be accepted? And I will include bitbake parser in follow-up patch.
Or
Drop this patch and waiting till bitbake parser has been included.
Thanks,
Hongxu
Quoted 3 lines
Cheers,
Paul
Quoted 11 lines · On Friday 02 August 2013 17:14:34 Hongxu Jia wrote:
Quoted 6 lines · Paul Eggleton
So, this is fairly simple and works for most cases; however it would probably be a bit more robust if the script used bitbake's own parser to extract the flags. The "tinfoil" module should help with this. We can always address this in a follow-up patch later on, though - I can certainly show you some examples of how to do this or I can do it, whichever you prefer.
Great, this is what I hope to do in the follow-up, I am very pleased to do the investigate on bitbake parser, very thankful to share some examples of how to do this with me.
Sure - we use the parser in the layer index. The latest in-development code has a module that does most of the work:
Specifically, you can call bb.cache.Cache.loadDataFull() for each recipe file and that will give you a datastore you can query for information.
I'm not sure, but you may wish to use bitbake's cache to get the list of recipes rather than just walking the directory tree so the utility has the same understanding of PN and preferred versions as bitbake. If you do want to go down this route I've put together this example:
https://gist.github.com/bluelightning/6138980
Hope this helps.
Quoted 4 lines
Should this simple patch be accepted? And I will include bitbake parser in follow-up patch.
Or
Drop this patch and waiting till bitbake parser has been included.
I'd say let's accept this simple version for now after the naming/message corrections (especially since it's a contrib script) and then follow up with another patch when you have the bitbake-based version working.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Hi Paul,
I have updated the pull branch to rename the script and correct the comments as your suggestions.
The suggestion about using bitbake parser to make the script more robust, I need some time to do the investigation and I am very pleased to do that, I will address this in follow-up pathch, would you think it's proper or not?
Thanks,
Hongxu
Quoted 83 lines · Paul Eggleton
Hi Hongxu,
Great idea! This should be very useful indeed.
Just a few feedback points:
Quoted 22 lines · On Thursday 01 August 2013 19:04:05 Hongxu Jia wrote:
list-packageconfig-flag.pywill walk the METADIR and collect recipes which have PACKAGECONFIG's flags.The default display is to list recipes which have PACKAGECONFIG's flags in METADIR. If option '-f' is used, it will list PACKAGECONFIG's flags and all affected recipes in METADIR
EXAMPLE:
list-packageconfig-flag.pypoky/meta poky/meta-yocto
RECIPE NAME PACKAGECONFIG's flag
=========================================libarchive_2.8.5.bb acl xattr largefile zlib bz2 xz openssl libxml2 expat strace_4.8.bb libaio acl connman.inc wifi bluetooth 3g tist openvpn vpnc l2tp pptp wispr
list-packageconfig-flag.py-f poky/meta poky/meta-yocto
PACKAGECONFIG's flag RECIPE NAME
====================================speex gstreamer1.0-plugins-good.inc keyutils rpm_5.4.9.bb gallium-egl mesa.incQuoted 7 lines
[YOCTO #4368]
Signed-off-by Hongxu Jia <[email protected]>--- scripts/contrib/list-packageconfig-flag.py | 180+++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+)
create mode 100755scripts/contrib/list-packageconfig-flag.pyI think the script ought to be called "list-packageconfig-flags" rather than "list-packageconfig-flag".
scripts/contrib/list-packageconfig-flag.py line 43
Quoted 3 lines
...
scripts/contrib/list-packageconfig-flag.py new file +2
-0+def parse_recipe(recipe): + ''' Parse a recipe to collect PACKAGECONFIG's flags '''This should say "collect available PACKAGECONFIG flags". The same applies to other messages/comments.
Quoted 19 lines
scripts/contrib/list-packageconfig-flag.py new file +18
-0+ prog = re.compile(r' *PACKAGECONFIG\[(?P<flag>.*)\] *=.*') + try: + r = open(recipe) + except IOError as (errno, strerror): + print >> sys.stderr, 'WARNING: Failed to open recipe', recipe + + flaglist = [] + for line in r: + # Strip any comments from the line + line = line.rsplit('#')[0] + m = prog.match(line) + if m: + flaglist.append(m.group('flag')) + r.close() + + return flaglist +def process_recipes(metadir): + ''' Collect recipes which have PACKAGECONFIG's flags in METADIR '''scripts/contrib/list-packageconfig-flag.py line 72
Quoted 10 lines
scripts/contrib/list-packageconfig-flag.py new file +10
-0+ # recipesdict = {'recipe': ['flag1', 'flag2',...]} + recipesdict = {} + for root,dirs,files in os.walk(metadir): + for name in files: + if name.find(".bb") >= 0 or name.find(".inc") >= 0: + flaglist = parse_recipe(os.path.join(root,name)) + if flaglist: + recipesdict[name] = flaglist + + return recipesdictSo, this is fairly simple and works for most cases; however it would probably be a bit more robust if the script used bitbake's own parser to extract the flags. The "tinfoil" module should help with this. We can always address this in a follow-up patch later on, though - I can certainly show you some examples of how to do this or I can do it, whichever you prefer.
Cheers,
Paul
Quoted 2 lines · On Friday 02 August 2013 18:03:05 Hongxu Jia wrote:
I have updated the pull branch to rename the script and correct the comments as your suggestions.
There still seem to be a lot of instances of "PACKAGECONFIG's flags" on the branch.
Quoted 3 lines
The suggestion about using bitbake parser to make the script more robust, I need some time to do the investigation and I am very pleased to do that, I will address this in follow-up pathch, would you think it's proper or not?
Yes, that's fine.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 5 lines · Paul Eggleton
Quoted 2 lines · On Friday 02 August 2013 18:03:05 Hongxu Jia wrote:
I have updated the pull branch to rename the script and correct the comments as your suggestions.
There still seem to be a lot of instances of "PACKAGECONFIG's flags" on the branch.
Thanks Paul for the reviewing, I am sorry for the missing, I have updated the pull branch again.
Thanks,
Hongxu
Quoted 8 lines
Quoted 3 lines
The suggestion about using bitbake parser to make the script more robust, I need some time to do the investigation and I am very pleased to do that, I will address this in follow-up pathch, would you think it's proper or not?
Yes, that's fine.
Cheers,
Paul