lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	26 Oct 2006 12:50:51 +0200
From:	Samuel Tardieu <sam@...1149.net>
To:	linux-kernel@...r.kernel.org
Subject:  Re: What about make mergeconfig ?

>>>>> "Benjamin" == Benjamin Herrenschmidt <benh@...nel.crashing.org> writes:

Benjamin> That would merge all entries in the specified file with the
Benjamin> current .config.

You don't need it to be a Makefile target, it can be an external
script. Would this one (untested!) do what you want?

  Sam
-- 
Samuel Tardieu -- sam@...1149.net -- http://www.rfc1149.net/

#! /usr/bin/python
#
# (c) 2006 Samuel Tardieu <sam@...1149.net>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
# Usage: mergeconfig config1 config2 ... > newconfig
#
# To get the formatting back, it is advised to run "make oldconfig" on the
# result.
#
# Be careful in not using the same file as input and output

import sre, sys

_not_set = sre.compile('# (CONFIG_\S+) is not set')
_set = sre.compile('(CONFIG_[^=]+)=(.*)')

def read_config(fn):
    """Read a kernel configuration file and return a dictionary with
    all the options present in the file. If an option is commented out,
    set its value as None."""
    d = {}
    for l in file(fn):
        l = l.rstrip('\r\n')
        x = _not_set.match(l)
        if x: d[x.group(1)] = None
        x = _set.match(l)
        if x: d[x.group(1)] = x.group(2)
    return d

def merge_option(o, v1, v2):
    """Merge option value v1 and v2."""
    if 'y' in [v1, v2]: return 'y'
    if 'm' in [v1, v2]: return 'm'
    if v1 != v2:
        sys.stderr.write('Option %s has two incompatible values: %s and %s' %
                         (o, v1, v2))
        sys.exit(1)
    return v1

def merge_config_into(a, b):
    """Merge configuration dictionary a into configuration dictionary b.
    In addition, this function returns b after the merge."""
    for k, v in a.items():
        try:
            b[v] = merge_option(k, v, b[v])
        except KeyError:
            b[k] = v
    return b

def output_config(d):
    for k, v in d.items():
        if v is None: print '# %s is not set' % k
        else: print '%s=%s' % (k, v)

if __name__ == '__main__':
    output_config (reduce(lambda x, y: merge_config_into(x, read_config(y)),
                          sys.argv[1:], {}))

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ