Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp877919ybz; Fri, 1 May 2020 10:09:23 -0700 (PDT) X-Google-Smtp-Source: APiQypLT2R4GcVmatChge3Si+T5KOdmCg5tkir7AzqDwa3jHByc61KusKNh+K8EcE4H0NUx8JvYx X-Received: by 2002:a17:906:1c8a:: with SMTP id g10mr4273367ejh.342.1588352963726; Fri, 01 May 2020 10:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588352963; cv=none; d=google.com; s=arc-20160816; b=YzL9wA3heXJ5aILw3M5+cGGUl/I8nCSimW7lQWLMcsZZGffZiw515r/D+f6ijAI/ZF dkisYeBnKGJMVcvKFEh0KSBZsdFMI0VaL0MsRob9wgEbaRh8OlScJXNz7o3mGYVdj3IU PfUbwBngrvW4L2djtugVdrM/sqUQ4HgRW3gjW+F9e6FGvq4iMZXDTS0KBqymTpJaNWrF oEK0TKhYzmv04KEjGV6Z8OgmmKY3QFVMEkrm0f5y2zV3CdUUtmh7A1v2kORbDEy5PBnU sFgdkZb6+bwMFL8RR8P4b2faP0TKT9dfZtwzC0m1yA2kd3/t30eROZO7Y+E2qb4VIK40 RYXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=KFhD/4gvQoHqOf+jYLujiV/oZJVUFZYdMZnNsVoxR6A=; b=PiGgJkgB9mPwWbsT5YQAbc8k/hOP9++igoLcyEzQP6rgzyJcWJuvxOGgaJ0wrGltWL j1HNg7qDq0ML2oD6yb7LNOPpJ5PusIULLOQe7jlKcdg5qjK7DDnXIEKOBJBe6Db+cKEj 4wk1y5txNnVgCwTQxKhiOsaFM+16YmmHGpUnzqzlJfn/6OBL1lmbNXjdKgYIehg+FdjI 4tCUz/Nz7Zoyk3CA9Fxho4CiFRvOpIKF4mIc2GjJXg2WvDwIsbmfq7jIwEIdWCLdnv39 YMHnpqLyDnqelMqtKCqLZsH7fPoUWztZlZFFzkJIgO66v1s5l4wQ0eYEbdnMviDWw/Ti QaQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si2106440edy.422.2020.05.01.10.08.58; Fri, 01 May 2020 10:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729447AbgEARHc (ORCPT + 99 others); Fri, 1 May 2020 13:07:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728925AbgEARHb (ORCPT ); Fri, 1 May 2020 13:07:31 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB90120836; Fri, 1 May 2020 17:07:30 +0000 (UTC) Date: Fri, 1 May 2020 13:07:29 -0400 From: Steven Rostedt To: Changbin Du Cc: Masahiro Yamada , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH] streamline_config.pl: add LOCALMODCONFIG_PRESERVE to preserve some kconfigs Message-ID: <20200501130729.3a3e4994@gandalf.local.home> In-Reply-To: <20200501023708.108830-1-changbin.du@gmail.com> References: <20200501023708.108830-1-changbin.du@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 May 2020 10:37:08 +0800 Changbin Du wrote: > Sometimes it is useful to preserve batches of configs when making > localmodconfig. For example, I usually don't want any usb and fs > modules to be disabled. Now we can do it by: > > $ make LOCALMODCONFIG_PRESERVE="drivers/usb;fs" localmodconfig That's too much typing ;-) What about just "KEEP='drivers/usb;fs'"? > > Signed-off-by: Changbin Du > --- > Documentation/admin-guide/README.rst | 8 +++++++- > scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ > 2 files changed, 30 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/README.rst b/Documentation/admin-guide/README.rst > index cc6151fc0845..6deff95362f8 100644 > --- a/Documentation/admin-guide/README.rst > +++ b/Documentation/admin-guide/README.rst > @@ -209,10 +209,16 @@ Configuring the kernel > store the lsmod of that machine into a file > and pass it in as a LSMOD parameter. > > + Also, you can preserve modules in certen folders > + or kconfig files by spcifying there paths in > + parameter LOCALMODCONFIG_PRESERVE. > + > target$ lsmod > /tmp/mylsmod > target$ scp /tmp/mylsmod host:/tmp > > - host$ make LSMOD=/tmp/mylsmod localmodconfig > + host$ make LSMOD=/tmp/mylsmod \ > + LOCALMODCONFIG_PRESERVE="drivers/usb;drivers/gpu;fs" \ > + localmodconfig > > The above also works when cross compiling. > > diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl > index e2f8504f5a2d..ab5d1e10a5d0 100755 > --- a/scripts/kconfig/streamline_config.pl > +++ b/scripts/kconfig/streamline_config.pl > @@ -143,6 +143,7 @@ my %depends; > my %selects; > my %prompts; > my %objects; > +my %config2kfile; > my $var; > my $iflevel = 0; > my @ifdeps; > @@ -201,6 +202,7 @@ sub read_kconfig { > if (/^\s*(menu)?config\s+(\S+)\s*$/) { > $state = "NEW"; > $config = $2; > + $config2kfile{"CONFIG_$config"} = $kconfig; > > # Add depends for 'if' nesting > for (my $i = 0; $i < $iflevel; $i++) { > @@ -592,6 +594,22 @@ while ($repeat) { > > my %setconfigs; > > +my @presevered_kconfigs; > +@presevered_kconfigs = split(/;/,$ENV{LOCALMODCONFIG_PRESERVE}) if (defined($ENV{LOCALMODCONFIG_PRESERVE})); > + > +sub in_presevered_kconfigs { > + my $kconfig = $config2kfile{$_[0]}; > + if (!defined($kconfig)) { > + return 0; > + } > + foreach my $excl (@presevered_kconfigs) { > + if($kconfig =~ /^$excl/) { > + return 1; > + } > + } > + return 0; > +} > + > # Finally, read the .config file and turn off any module enabled that > # we could not find a reason to keep enabled. > foreach my $line (@config_file) { > @@ -644,6 +662,11 @@ foreach my $line (@config_file) { > } > > if (/^(CONFIG.*)=(m|y)/) { > + if (in_presevered_kconfigs($1)) { > + dprint "Preserve config $1"; > + print; > + next; > + } > if (defined($configs{$1})) { > if ($localyesconfig) { > $setconfigs{$1} = 'y'; I'll have to test it out, but I like the idea! -- Steve