From 2afb6eb22e10f4d0ae2e414a867891650fb84809 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Tue, 4 Dec 2018 14:51:58 -0800 Subject: [PATCH] Add a print command to fs_config_generator.py This prints the uid map in a very simple format, with AID_CONSTANTuid on each line. This is super easy for other tools to parse, and generate their own mappings, without requiring edits to fs_config_generator.py itself. Test: make, treehugger Change-Id: I10e24ac29d440a24d43580880343d122ae1cdf02 --- tools/fs_config/fs_config_generator.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py index db484a09b7..0a8def8e03 100755 --- a/tools/fs_config/fs_config_generator.py +++ b/tools/fs_config/fs_config_generator.py @@ -1294,6 +1294,28 @@ class GroupGen(PasswdGen): print "%s::%s:" % (logon, uid) +@generator('print') +class PrintGen(BaseGenerator): + """Prints just the constants and values, separated by spaces, in an easy to + parse format for use by other scripts. + + Each line is just the identifier and the value, separated by a space. + """ + + def add_opts(self, opt_group): + opt_group.add_argument( + 'aid-header', help='An android_filesystem_config.h file.') + + def __call__(self, args): + + hdr_parser = AIDHeaderParser(args['aid-header']) + aids = hdr_parser.aids + + aids.sort(key=lambda item: int(item.normalized_value)) + + for aid in aids: + print '%s %s' % (aid.identifier, aid.normalized_value) + def main(): """Main entry point for execution."""