This file is indexed.

/usr/bin/undertaker-kconfigpp is in undertaker 1.6.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /usr/bin/python

"""undertaker-kconfigpp - preprocess 'source' directives in Kconfig files"""

# Copyright (C) 2012 Ralf Hackner <rh@ralf-hackner.de>
# Copyright (C) 2012 Reinhard Tartler <tartler@informatik.uni-erlangen.de>
# Copyright (C) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
#
# The purpose of this script is to have a complex Kconfig tree
# strucuture, such as commonly found in Linux flattened to a single
# file, which helps writing test-cases and similar.
#
# 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 3 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, see <http://www.gnu.org/licenses/>.

import os
import sys

sys.path = [os.path.join(os.path.dirname(sys.path[0]), 'lib', 'python%d.%d' % \
               (sys.version_info[0], sys.version_info[1]), 'site-packages')] + sys.path

import vamos.tools as tools

import re
import logging
from optparse import OptionParser


env_regex    = re.compile(r'"[^$]*\$([\w]+)[^"]*"')
source_regex = re.compile(r"^\s*source\s+\"?([\w/\$\.\-]+)\"?")

def ppFile(filename):
    try:
        logging.info("Processing %s", filename)
        with open(filename, 'r') as mf:
            for line in mf:
                # replace from environment
                while env_regex.search(line):
                    do_break = False
                    for v in env_regex.findall(line):
                        env = os.getenv(v)
                        if env:
                            old_line = line
                            line = line.replace('$'+v, env)
                            assert not old_line == line, "[%s, %s] %s" % (env, v, line)
                        else:
                            logging.debug("[%s] var %s not found in environment (%s)\n",
                                          filename, v, line.strip())
                            do_break = True
                    if do_break: break
                # catch: help section may contain the word "source"
                m = source_regex.match(line)
                if m:
                    f = m.group(1)
                    if os.path.exists(f):
                        ppFile(f)
                    else:
                        logging.debug("[%s] failed to source %s, (%s)\n",
                                      filename, f, line.rstrip())
                else:
                    if line[-1] == '\n':
                        print line,
                    else:
                        print line
    except IOError as e:
        logging.error("Failed to open %s for reading: %s\n", filename, e.strerror)


if __name__ == '__main__':
    parser = OptionParser(usage="%prog [options] <filename>\n\n"
                "preprocess 'source' directives in Kconfig files.\n"
                "The purpose of this script is to have a complex Kconfig tree\n"
                "structure, such as commonly found in Linux flattened to a single\n"
                "file, which helps writing test-cases and similar.")
    parser.add_option('-v', '--verbose', dest='verbose', action='count',
                      help="increase verbosity (specify multiple times for more)")

    (opts, args) = parser.parse_args()

    tools.setup_logging(opts.verbose)

    if len(args) < 1:
        logging.error("usage: kconfigpp file (%d params given)", len(args))
        parser.print_help()
        sys.exit(1)

    ppFile(sys.argv[1])