Skip to contentSkip to conversation

localmodconfig: Updates for 4.7

PATCH New Steven Rostedt 1 participant 7 messages Apr 26, 2016 Kconfig

lore
Share & tools
lore
#0 lore raw

cover localmodconfig: Updates for 4.7

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-kconfig.git
for-next

Head SHA1: 5bcba792bb304e8341217d759ec486969a3b4258

Benjamin Poirier (6):
localmodconfig: Fix parsing of Kconfig "source" statements
localmodconfig: Recognize more keywords that end a menu entry
localmodconfig: Fix parsing of "help" text
localmodconfig: Add missing $ to reference a variable
localmodconfig: Reset certificate paths
localmodconfig: Fix whitespace repeat count after "tristate"

----

 scripts/kconfig/streamline_config.pl | 44 ++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/6 localmodconfig: Fix parsing of Kconfig "source" statements

From: Benjamin Poirier <[email protected]>

The parameter of Kconfig "source" statements does not need to be quoted. The current regex causes many kconfig files to be skipped and hence, dependencies to be missed.

Also fix the whitespace repeat count.

---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
index f3d3fb42b873..7036ae306db6 100755
@@ -188,7 +188,7 @@ sub read_kconfig {
 	$cont = 0;
 
 	# collect any Kconfig sources
-	if (/^source\s*"(.*)"/) {
+	if (/^source\s+"?([^"]+)/) {
 	    my $kconfig = $1;
 	    # prevent reading twice.
 	    if (!defined($read_kconfigs{$kconfig})) {
Signature · 1 line
2.8.0.rc3
#2 lore raw

PATCH 2/6 localmodconfig: Recognize more keywords that end a menu entry

In reply to Steven Rostedt

From: Benjamin Poirier <[email protected]>

Based on the list in Documentation/kbuild/kconfig-language.txt

This removes junk from %depends because parsing of a menu entry spilled over to another menu entry.

---
 scripts/kconfig/streamline_config.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/kconfig/streamline_config.pl +2 -2
index 7036ae306db6..64d750cc5ae4 100755
@@ -256,8 +256,8 @@ sub read_kconfig {
 
 	    $iflevel-- if ($iflevel);
 
-	# stop on "help"
-	} elsif (/^\s*help\s*$/) {
+	# stop on "help" and keywords that end a menu entry
+	} elsif (/^\s*help\s*$/ || /^(comment|choice|menu)\b/) {
 	    $state = "NONE";
 	}
     }
Signature · 1 line
2.8.0.rc3
#3 lore raw

PATCH 3/6 localmodconfig: Fix parsing of "help" text

In reply to Steven Rostedt

From: Benjamin Poirier <[email protected]>

Help text may start with "help" or "---help---". This patch fixes read_kconfig() to recognize the second variant.

This removes useless junk from %depends and %selects. That junk is due to help text that contains the words "selects" and "depends".

---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
index 64d750cc5ae4..b2f904a24c5c 100755
@@ -257,7 +257,7 @@ sub read_kconfig {
 	    $iflevel-- if ($iflevel);
 
 	# stop on "help" and keywords that end a menu entry
-	} elsif (/^\s*help\s*$/ || /^(comment|choice|menu)\b/) {
+	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) {
 	    $state = "NONE";
 	}
     }
Signature · 1 line
2.8.0.rc3
#4 lore raw

PATCH 4/6 localmodconfig: Add missing $ to reference a variable

In reply to Steven Rostedt

From: Benjamin Poirier <[email protected]>

That is clearly what the original intention was. This does not change the output .config but it prevents some useless processing.

! eq "m" is changed to the simpler eq "y"; symbols with values other than m|y are not included in %orig_configs.

---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
index b2f904a24c5c..01b53eccfe2f 100755
@@ -454,7 +454,7 @@ sub parse_config_depends
 	    $p =~ s/^[^$valid]*[$valid]+//;
 
 	    # We only need to process if the depend config is a module
-	    if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") {
+	    if (!defined($orig_configs{$conf}) || $orig_configs{$conf} eq "y") {
 		next;
 	    }
 
Signature · 1 line
2.8.0.rc3
#5 lore raw

PATCH 5/6 localmodconfig: Reset certificate paths

In reply to Steven Rostedt

From: Benjamin Poirier <[email protected]>

When using make localmodconfig and friends, if the input config comes from a kernel that was built in a different environment (for example, the canonical case of using localmodconfig to trim a distribution kernel config) the key files for module signature checking will not be available and should be regenerated or omitted. Otherwise, the user will be faced with annoying errors when trying to build with the generated .config:

make[1]: *** No rule to make target 'keyring.crt', needed by 'certs/x509_certificate_list'. Stop. Makefile:1576: recipe for target 'certs/' failed

---
 scripts/kconfig/streamline_config.pl | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
scripts/kconfig/streamline_config.pl +34 -0
index 01b53eccfe2f..95a6f2b888d4 100755
@@ -610,6 +610,40 @@ foreach my $line (@config_file) {
 	next;
     }
 
+    if (/CONFIG_MODULE_SIG_KEY="(.+)"/) {
+        my $orig_cert = $1;
+        my $default_cert = "certs/signing_key.pem";
+
+        # Check that the logic in this script still matches the one in Kconfig
+        if (!defined($depends{"MODULE_SIG_KEY"}) ||
+            $depends{"MODULE_SIG_KEY"} !~ /"\Q$default_cert\E"/) {
+            print STDERR "WARNING: MODULE_SIG_KEY assertion failure, ",
+                "update needed to ", __FILE__, " line ", __LINE__, "\n";
+            print;
+        } elsif ($orig_cert ne $default_cert && ! -f $orig_cert) {
+            print STDERR "Module signature verification enabled but ",
+                "module signing key \"$orig_cert\" not found. Resetting ",
+                "signing key to default value.\n";
+            print "CONFIG_MODULE_SIG_KEY=\"$default_cert\"\n";
+        } else {
+            print;
+        }
+        next;
+    }
+
+    if (/CONFIG_SYSTEM_TRUSTED_KEYS="(.+)"/) {
+        my $orig_keys = $1;
+
+        if (! -f $orig_keys) {
+            print STDERR "System keyring enabled but keys \"$orig_keys\" ",
+                "not found. Resetting keys to default value.\n";
+            print "CONFIG_SYSTEM_TRUSTED_KEYS=\"\"\n";
+        } else {
+            print;
+        }
+        next;
+    }
+
     if (/^(CONFIG.*)=(m|y)/) {
 	if (defined($configs{$1})) {
 	    if ($localyesconfig) {
Signature · 1 line
2.8.0.rc3
#6 lore raw

PATCH 6/6 localmodconfig: Fix whitespace repeat count after "tristate"

In reply to Steven Rostedt

From: Benjamin Poirier <[email protected]>

Also recognize standalone "prompt".

Before this patch we incorrectly identified some symbols as not having a prompt and potentially needing to be selected by something else.

Note that this patch could theoretically change the resulting .config, causing it to have fewer symbols turned on. However, given the current set of Kconfig files, this situation does not occur because the symbols newly added to %prompts are absent from %selects.

---
 scripts/kconfig/streamline_config.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/streamline_config.pl +1 -1
index 95a6f2b888d4..b8c7b29affc5 100755
@@ -237,7 +237,7 @@ sub read_kconfig {
 	    }
 
 	# configs without prompts must be selected
-	} elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
+	} elsif ($state ne "NONE" && /^\s*(tristate\s+\S|prompt\b)/) {
 	    # note if the config has a prompt
 	    $prompts{$config} = 1;
 
Signature · 1 line
2.8.0.rc3