* [RFC/PATCH 1/2] kconfig: add KBUILD_USERCONFIG option
2015-08-27 13:08 [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs Felipe Contreras
@ 2015-08-27 13:08 ` Felipe Contreras
2015-08-27 13:08 ` [RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig Felipe Contreras
2015-08-28 12:55 ` [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs John Stoffel
2 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2015-08-27 13:08 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, Yann E. MORIN, Linus Torvalds, Felipe Contreras
This allows us to specify a user defconfig which is added on top of the
default defconfig, which makes it easier for users to keep a simpler
defconfig, without duplicating all the options already present in the
arch defconfig.
Here a very simple defconfig I've been using for several years on top of
x86_64_defconfig. It works because I can rely on the fact that
x86_64_defconfig is properly maintained.
CONFIG_KERNEL_LZO=y
CONFIG_OPROFILE=m
CONFIG_MCORE2=y
CONFIG_COMPAT_VDSO=y
CONFIG_PATA_ACPI=y
CONFIG_ATA_GENERIC=y
CONFIG_LOGO=n
CONFIG_BTRFS_FS=m
CONFIG_FUSE_FS=m
CONFIG_NFS_FS=m
CONFIG_NFSD=m
CONFIG_CIFS=m
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KSM=y
CONFIG_PARAVIRT=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_USBNET=m
CONFIG_USB_NET_CDC_EEM=m
CONFIG_USB_UAS=m
CONFIG_SND_HDA_INPUT_JACK=y
CONFIG_SND_HDA_CODEC_REALTEK=y
CONFIG_SND_HDA_CODEC_HDMI=y
CONFIG_SND_HDA_CODEC_CMEDIA=y
CONFIG_SND_HDA_CODEC_SI3054=y
CONFIG_DM_CRYPT=m
CONFIG_CRYPTO_SHA256=y
CONFIG_BLK_DEV_CRYPTOLOOP=m
CONFIG_BRIDGE=m
CONFIG_TUN=m
CONFIG_ISO9660_FS=m
CONFIG_UDF_FS=m
CONFIG_ENCLOSURE_SERVICES=m
CONFIG_SCSI_ENCLOSURE=m
CONFIG_DEBUG_KERNEL=n
CONFIG_X86_VERBOSE_BOOTUP=n
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_PM_RUNTIME=y
CONFIG_SCHED_AUTOGROUP=y
CONFIG_UEVENT_HELPER_PATH=""
CONFIG_FHANDLE=y
CONFIG_EFI_STUB=y
CONFIG_EFIVAR_FS=m
CONFIG_HYPERVISOR_GUEST=y
CONFIG_DRM_CIRRUS_QEMU=y
CONFIG_CFG80211=m
CONFIG_MAC80211=m
CONFIG_IWLWIFI=m
CONFIG_CFG80211_DEFAULT_PS=n
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
scripts/kconfig/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index d9b1fef..0d55ad1 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -97,9 +97,15 @@ defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),)
$< $(silent) --defconfig $(Kconfig)
else
+ifneq ($(KBUILD_USERCONFIG),)
+ @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)' and '$(KBUILD_USERCONFIG)'"
+ $(Q)cat arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(KBUILD_USERCONFIG) > defconfig
+ $(Q)$< $(silent) --defconfig=defconfig $(Kconfig)
+else
@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
+endif
%_defconfig: $(obj)/conf
$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig
2015-08-27 13:08 [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs Felipe Contreras
2015-08-27 13:08 ` [RFC/PATCH 1/2] kconfig: add KBUILD_USERCONFIG option Felipe Contreras
@ 2015-08-27 13:08 ` Felipe Contreras
2015-08-28 12:55 ` [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs John Stoffel
2 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2015-08-27 13:08 UTC (permalink / raw)
To: linux-kernel
Cc: linux-kbuild, Yann E. MORIN, Linus Torvalds, Felipe Contreras
This option parses a defconfig file, and sets all the values as default
ones. The result is a much simplified defconfig.
This defconfig can be used as a KBUILD_USERCONFIG, which added to the
default defconfig generates exactly the same config file.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
scripts/kconfig/conf.c | 3 ++
scripts/kconfig/confdata.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
scripts/kconfig/lkc_proto.h | 1 +
3 files changed, 93 insertions(+)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 6c20431..382151c 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -698,6 +698,9 @@ int main(int ac, char **av)
return 1;
}
} else if (input_mode == savedefconfig) {
+ name = getenv("KCONFIG_BASECONFIG");
+ if (name)
+ conf_read_def(name);
if (conf_write_defconfig(defconfig_file)) {
fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
defconfig_file);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c814f57..af96042 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -476,6 +476,95 @@ int conf_read(const char *name)
return 0;
}
+static void conf_set_sym_default(struct symbol *sym, char *p)
+{
+ struct property *prop, **propp;
+
+ prop = xmalloc(sizeof(*prop));
+ memset(prop, 0, sizeof(*prop));
+ prop->type = P_DEFAULT;
+ prop->sym = sym;
+ prop->file = current_file;
+ prop->lineno = zconf_lineno();
+
+ for (propp = &sym->prop; *propp; propp = &(*propp)->next) {
+ if ((*propp)->type == P_DEFAULT) {
+ prop->next = *propp;
+ break;
+ }
+ }
+ *propp = prop;
+
+ prop->expr = expr_alloc_symbol(sym_lookup(p, SYMBOL_CONST));
+}
+
+int conf_read_def(const char *name)
+{
+ FILE *in = NULL;
+ char *line = NULL;
+ size_t line_asize = 0;
+ char *p, *p2;
+ struct symbol *sym;
+
+ in = zconf_fopen(name);
+ if (!in)
+ return 1;
+
+ conf_filename = name;
+ conf_lineno = 0;
+ conf_warnings = 0;
+
+ while (compat_getline(&line, &line_asize, in) != -1) {
+ conf_lineno++;
+ sym = NULL;
+ if (line[0] == '#') {
+ if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
+ continue;
+ p = strchr(line + 2 + strlen(CONFIG_), ' ');
+ if (!p)
+ continue;
+ *p++ = 0;
+ if (strncmp(p, "is not set", 10))
+ continue;
+ sym = sym_find(line + 2 + strlen(CONFIG_));
+ if (!sym)
+ continue;
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ conf_set_sym_default(sym, "n");
+ break;
+ default:
+ ;
+ }
+ } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
+ p = strchr(line + strlen(CONFIG_), '=');
+ if (!p)
+ continue;
+ *p++ = 0;
+ p2 = strchr(p, '\n');
+ if (p2) {
+ *p2-- = 0;
+ if (*p2 == '\r')
+ *p2 = 0;
+ }
+
+ sym = sym_find(line + strlen(CONFIG_));
+ if (!sym)
+ continue;
+ conf_set_sym_default(sym, p);
+ } else {
+ if (line[0] != '\r' && line[0] != '\n')
+ conf_warning("unexpected data");
+ continue;
+ }
+ }
+ free(line);
+ fclose(in);
+
+ return 0;
+}
+
/*
* Kconfig configuration printer
*
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index d539871..69c3785 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -3,6 +3,7 @@
/* confdata.c */
void conf_parse(const char *name);
int conf_read(const char *name);
+int conf_read_def(const char *name);
int conf_read_simple(const char *name, int);
int conf_write_defconfig(const char *name);
int conf_write(const char *name);
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs
2015-08-27 13:08 [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs Felipe Contreras
2015-08-27 13:08 ` [RFC/PATCH 1/2] kconfig: add KBUILD_USERCONFIG option Felipe Contreras
2015-08-27 13:08 ` [RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig Felipe Contreras
@ 2015-08-28 12:55 ` John Stoffel
2 siblings, 0 replies; 4+ messages in thread
From: John Stoffel @ 2015-08-28 12:55 UTC (permalink / raw)
To: Felipe Contreras
Cc: linux-kernel, linux-kbuild, Yann E. MORIN, Linus Torvalds
Felipe> For several years I've used a trick to be able to maintain a simple defconfig
Felipe> that works across many versions, and requires little maintenance from my
Felipe> part:
Felipe> % cat arch/x86/configs/x86_64_defconfig ~/my-config > .config && make olddefconfig
Felipe> I'm sending a proposal to integrate it on the build system so that many people
Felipe> can do the same in a simple manner.
Felipe> The interesting part is how to generate this simplified defconfig. In a
Felipe> nutshell; you want to take your .config, remove everything that is the default
Felipe> in the Kconfig files (what savedefconfig does), but also removes anything that
Felipe> is in the default defconfig (e.g. x86_64_defconfig)
Felipe> I've been doing this by hand, but today I gave it a shot to automate this. The
Felipe> result is a bit crude, but it works.
Felipe> Thoughts?
I like this idea, it makes alot of sense to me, and looks like it will
simplify things for people.
^ permalink raw reply [flat|nested] 4+ messages in thread