kconfig confdata: Add an option to keep all .config backups
Subsystems (3)
PATCH 1/1 kconfig confdata: Add an option to keep all .config backups
When KCONFIG_KEEPALLBACKUPS is set in the environment, instead of renaming the old .config to .config.old, kconfig puts it in a folder named .config.backupdir that stores all backups with the name .config.oldX where X is a number.
The latest backup is the one with the highest number.
This is useful to avoid doing a lot of manual backups to make sure to have a working build when you make a lot of changes that can break everything.
Signed-off-by Maxime Chretien <[email protected]>
--- Documentation/kbuild/kconfig.rst | 6 ++++++ Makefile | 2 +- scripts/kconfig/confdata.c | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-)
Documentation/kbuild/kconfig.rst +6 -0
@@ -46,6 +46,12 @@ KCONFIG_OVERWRITECONFIG If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not break symlinks when .config is a symlink to somewhere else. +KCONFIG_KEEPALLBACKUPS +----------------------- +If you set KCONFIG_KEEPALLBACKUPS in the environment, Kconfig will save +all .config.old as .config.oldX where X is a number (lower is older) +inside a folder named .config.backupdir . + `CONFIG_` --------- If you set `CONFIG_` in the environment, Kconfig will prefix all symbols
Makefile +1 -1
@@ -1437,7 +1437,7 @@ CLEAN_FILES += include/ksym vmlinux.symvers \ MRPROPER_FILES += include/config include/generated \ arch/$(SRCARCH)/include/generated .tmp_objdiff \ debian snap tar-install \ - .config .config.old .version \ + .config .config.old .config.backupdir .version \ Module.symvers \ signing_key.pem signing_key.priv signing_key.x509 \ x509.genkey extra_certificates signing_key.x509.keyid \
scripts/kconfig/confdata.c +14 -1
@@ -923,7 +923,20 @@ int conf_write(const char *name)return 0 ; } -snprintf (oldname,sizeof (oldname),"%s.old" , name); + env =getenv ("KCONFIG_KEEPALLBACKUPS" ); +if (env) { + i =0 ; +do { +snprintf (oldname,sizeof (oldname), +"%s.backupdir/%s.old%d" , name, name, i); + i++; + }while (is_present (oldname)); + +if (make_parent_dir (oldname)) +return -1 ; + }else { +snprintf (oldname,sizeof (oldname),"%s.old" , name); + }rename (name, oldname);if (rename (tmpname, name))return 1 ;
Signature · 1 line
2.27.0