#!/usr/bin/perl -w # Mer Kernel config specification checker # http://wiki.merproject.org/wiki/Adaptation_Guide # CONFIG must be set to one of the permitted values "," seperated and # multiple values permitted # y = set and enabled # m = set and module # n = must be unset (commented out) # # "value" = must be set to "value" # /regexp/ = "value" which matches regexp # # ! = Failure will be warned, not errored # Known issues with the basic parser: # * # in regexps or strings cause issues if there's no trailing # # * can't have "," in /regexp/ use Text::ParseWords; use strict; my $debug = 0; my %config; while () { next if /^\s*(#.*)?$/ ; # skip comments and blank lines chomp; my ($conf, $allowed) = split(' ', $_, 2); # Remove and capture any trailing comment (dubious matching here # since comments in a "" or // will be removed too) my $comment; if ($allowed =~ s/(#\s*)(.*)?$//) { $comment = $2 if $2; } # http://perldoc.perl.org/Text/ParseWords.html my @allowed = parse_line(",", 1, $allowed); my $warning; # Strip leading/trailing space for each value and check for warnings foreach (@allowed) { s/^\s+|\s+$//g; $warning = 1 if $_ eq "!" ; } # Each CONFIG_* has an array of allowed values, a comment and a flag # to say it's only a warning (in which case we print the comment) $config{$conf} = {allowed => \@allowed, comment => $comment, warning => $warning }; } print "\nScanning\n" if $debug; while (<>) { next if /^\s*(#.*)?$/ ; # skip comments and blank lines chomp; my ($conf, $value) = split('=', $_, 2); # Only check CONFIG_* values we know about next unless $config{$conf}; my $c = $config{$conf}; print "$conf matched, checking..." if $debug; $c->{"value"} = $value; # Store the value for later reporting my $allowed = $c->{"allowed"}; for my $allow (@$allowed) { if (substr($allow,1,1) eq '/') { # regexps print "Do a regex match : \"$value\" =~ $allow\n" if $debug; } elsif (substr($allow,1,1) eq '"') { # strings print "Do a string match : $allow == $value\n" if $debug; if ($value eq $allow) {$c->{"valid"} = 1; } } else { # plain y/m values print "match y/m : $value == $allow\n" if $debug; if ($value eq $allow) {$c->{"valid"} = 1; } } } if ($c->{"valid"}) { print "OK\n" if $debug;} } print "Results\n" if $debug; my $fatal = 0; for my $conf (keys %config) { my $c = $config{$conf}; if (! $c->{"valid"}) { # Check for 'n' case foreach my $allow (@{$c->{"allowed"}}) { if (("$allow" eq "n") and ! $c->{"value"}) { $c->{"valid"} = 1; } } } # Now report if (! $c->{"valid"}) { print defined($c->{"warning"}) ? "WARNING: " : "ERROR: "; print "$conf is invalid (marked as optional)\n"; if ($c->{"value"}) { print "Value is: ". $c->{"value"} ."\n"; } else { print "It is unset\n"; } print "Allowed values : ".join(", ", @{$c->{"allowed"}}) ."\n"; print "Comment says: ". $c->{"comment"}."\n\n"; if (! $c->{"warning"}) { $fatal = 1; } } } exit $fatal; __DATA__ CONFIG_ANDROID_LOW_MEMORY_KILLER n # not tested with Mer CONFIG_ANDROID_PARANOID_NETWORK n # not tested with Mer CONFIG_AUDIT n,! # systemd: Either disable here or in cmdline http://cgit.freedesktop.org/systemd/systemd/commit/README?id=77b6e19458f37cfde127ec6aa9494c0ac45ad890 CONFIG_AUTOFS4_FS y,m,! # systemd (optional): http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_BRIDGE y,m,! # connman (optional): support tethering, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=19fe7cad485afa6a7a5cc4aa75615ce8b7b8d376 CONFIG_IP_NF_TARGET_MASQUERADE y,m,! # connman (optional): support tethering, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=19fe7cad485afa6a7a5cc4aa75615ce8b7b8d376 CONFIG_IP_NF_IPTABLES y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=41f37125887cb9208da2441e350e1e3324c17ee6 CONFIG_IP_MULTIPLE_TABLES y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=41f37125887cb9208da2441e350e1e3324c17ee6 CONFIG_NETFILTER_NETLINK_ACCT y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=41f37125887cb9208da2441e350e1e3324c17ee6 CONFIG_NETFILTER_XT_MATCH_NFACCT y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=41f37125887cb9208da2441e350e1e3324c17ee6 CONFIG_NETFILTER_XT_CONNMARK y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=115cb9cbd3cdda00784e58a4ea12b42d128732b4 CONFIG_NETFILTER_XT_TARGET_CONNMARK y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=115cb9cbd3cdda00784e58a4ea12b42d128732b4 CONFIG_NETFILTER_XT_MATCH_CONNMARK y,m,! # connman (optional): for routing and statistic support in sessions, http://git.kernel.org/cgit/network/connman/connman.git/commit/README?id=115cb9cbd3cdda00784e58a4ea12b42d128732b4 CONFIG_CGROUPS y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_CGROUP_FREEZER y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_CGROUP_DEVICE n # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html, gives problems with LXC CONFIG_CGROUP_CPUACCT y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_CGROUP_MEM_RES_CTLR y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_CGROUP_MEM_RES_CTLR_SWAP y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_CGROUP_MEM_RES_CTLR_KMEM y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_CGROUP_PERF n # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html, gives problems with LXC CONFIG_CGROUP_SCHED y,! # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html CONFIG_BLK_CGROUP n # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html, gives problems with LXC CONFIG_NET_CLS_CGROUP n # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html, gives problems with LXC CONFIG_NETPRIO_CGROUP n # systemd (optional): http://0pointer.de/blog/projects/cgroups-vs-cgroups.html, gives problems with LXC CONFIG_DEVTMPFS y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_DUMMY n CONFIG_FHANDLE y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=001809282918f273d372f1ee09d10b783c18a474 CONFIG_SCHEDSTATS y,! # systemd-bootchart (optional): http://cgit.freedesktop.org/systemd/systemd/commit/README?id=f1c24fea94e19cf2108abbeed1d36ded7102ab98 CONFIG_SCHED_DEBUG y,! # systemd-bootchart (optional): http://cgit.freedesktop.org/systemd/systemd/commit/README?id=f1c24fea94e19cf2108abbeed1d36ded7102ab98 CONFIG_NLS_UTF8 y # Ensure that we support UTF8 filenames. CONFIG_BT y,! # Bluez (optional): Needed if bluez used as bluetooth stack CONFIG_UNIX y # UNIX sockets option is required to run Mer CONFIG_SYSVIPC y # Inter Process Communication option is required to run Mer CONFIG_EXT4_FS y,m,! # Mer uses ext4 as rootfs by default CONFIG_FANOTIFY y,! # optional, required for systemd readahead. CONFIG_HOTPLUG y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_INOTIFY_USER y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_IPV6 y,m,! # systemd: http://cgit.freedesktop.org/systemd/systemd/tree/README#n37 CONFIG_RTC_DRV_CMOS y,! # optional, but highly recommended CONFIG_SIGNALFD y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_TIMERFD y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_EPOLL y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_NET y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=41938693e76c32161d2b3b83253ce996468cbf9b CONFIG_SYSFS y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_PROC_FS y # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=06d461ee6f3da6650e6d023d7828455752d70b0b CONFIG_SYSFS_DEPRECATED n # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_TMPFS_POSIX_ACL y,! # systemd (optional): strongly recommended, if you want pam_systemd.so to setup your "seats". http://cgit.freedesktop.org/systemd/systemd/commit/README?id=77b6e19458f37cfde127ec6aa9494c0ac45ad890 CONFIG_TMPFS_XATTR y,! # systemd (optional): strongly recommended, http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_SECCOMP y,! # systemd (optional): strongly recommended, http://cgit.freedesktop.org/systemd/systemd/commit/README?id=f28cbd0382ca53baa99803bbc907a469fbf68128 CONFIG_TUN y,m,! # ofono: http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=README;h=413d789e5f9e96024986f5116d3c8aff0c9f15b8;hb=HEAD#l28 CONFIG_UEVENT_HELPER_PATH "", ! # should be empty, if you want to use systemd without initramfs. Also systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_FW_LOADER_USER_HELPER n # systemd: http://cgit.freedesktop.org/systemd/systemd/commit/README?id=713bc0cfa477ca1df8769041cb3dbc83c10eace2 CONFIG_VT y # Required for virtual consoles CONFIG_LBDAF y,! # ext4 filesystem requires this in order to support filesysetms with huge_file feature, which is enabled by default by mke2fs.ext4 CONFIG_CHECKPOINT_RESTORE y,! # rich-core-dumper (https://github.com/mer-tools/sp-rich-core/) needs this to collect all data for environment recreation. CONFIG_UTS_NS y,! # Needed for LXC CONFIG_IPC_NS y,! # Needed for LXC CONFIG_USER_NS y,! # Needed for LXC CONFIG_PID_NS y,! # Needed for LXC CONFIG_NET_NS y,! # Needed for LXC CONFIG_DEVPTS_MULTIPLE_INSTANCES y,! # Needed for LXC CONFIG_FANOTIFY_ACCESS_PERMISSIONS y,! # Needed by LuneOS CONFIG_IKCONFIG_PROC y # Useful for debugging