Skip to contentSkip to conversation

Change behaviour of symlink .config

PATCH New Benoit Mauduit 2 participants 5 messages Jun 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Change behaviour of symlink .config

This patch change the bahaviour with .config management.

The default behaviour is modified only if .config is a symbolic link. In this case, the target pointed by the link will be overwritten, and the old .config is save to .config.old.

This can be useful when we want to save and use the config file outside the Buildroot directory.

#1 lore raw

PATCH v2 1/1 Change behaviour of symlink .config

Patch v2.
I forgot to add a patch to 'package/config/patches/'.

#2 lore raw

PATCH 1/1 Change behaviour of symlink .config

From: Benoit Mauduit <[email protected]>

If .config is a symlink, the target will be modified and the old .config is saved to .config.old.

---
 package/config/confdata.c                          |   15 +++++++-
 .../13-Change-behaviour-of-symlink-config.patch    |   40 ++++++++++++++++++++
 package/config/patches/series                      |    1 +
 3 files changed, 55 insertions(+), 1 deletions(-)
 create mode 100644 package/config/patches/13-Change-behaviour-of-symlink-config.patch
package/config/confdata.c +14 -1
index c9f13ee..c00639f 100644
@@ -588,7 +588,20 @@ int conf_write(const char *name)
 	} else
 		basename = conf_get_configname();
 
-	sprintf(newname, "%s%s", dirname, basename);
+	sprintf(tmpname, "%s%s", dirname, basename);
+
+	realpath(tmpname, newname);
+
+	if (strcmp(tmpname, newname)) {
+		printf(_("#\n"
+		         "# Warning: Symbolic link detected,"
+		         " the target will be overwritten\n"
+		         "#\n")
+		       );
+
+		tmpname[0] = '\0';
+	}
+
 	env = getenv("KCONFIG_OVERWRITECONFIG");
 	if (!env || !*env) {
 		sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
package/config/patches/13-Change-behaviour-of-symlink-config.patch new file +40 -0
new file mode 100644
index 0000000..e4e7be4
@@ -0,0 +1,40 @@
+From 3c8ff86dbe779f00eaa5692ef61cabef4466e5d6 Mon Sep 17 00:00:00 2001
+From: Benoit Mauduit <[email protected]>
+Date: Thu, 3 Mar 2011 16:20:27 +0100
+Subject: [PATCH] [package/config] Change behaviour of symlink .config
+
+If .config is a symlink, the target will be modified and the old
+.config is saved to .config.old.
+---
+ package/config/confdata.c |   15 ++++++++++++++-
+ 1 files changed, 14 insertions(+), 1 deletions(-)
+
+diff --git a/package/config/confdata.c b/package/config/confdata.c
+index c9f13ee..c00639f 100644
+--- a/confdata.c
++++ b/confdata.c
+@@ -588,7 +588,20 @@ int conf_write(const char *name)
+ 	} else
+ 		basename = conf_get_configname();
+ 
+-	sprintf(newname, "%s%s", dirname, basename);
++	sprintf(tmpname, "%s%s", dirname, basename);
++
++	realpath(tmpname, newname);
++
++	if (strcmp(tmpname, newname)) {
++		printf(_("#\n"
++		         "# Warning: Symbolic link detected,"
++		         " the target will be overwritten\n"
++		         "#\n")
++		       );
++
++		tmpname[0] = '\0';
++	}
++
+ 	env = getenv("KCONFIG_OVERWRITECONFIG");
+ 	if (!env || !*env) {
+ 		sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
+-- 
+1.7.5.2
+
package/config/patches/series +1 -0
index defdf58..b5455fd 100644
@@ -8,4 +8,5 @@
 10-br-build-system.patch
 11-use-mktemp-for-lxdialog.patch
 12-fix-glade-file-path.patch
+13-Change-behaviour-of-symlink-config.patch
 14-support-out-of-tree-config.patch
Signature · 1 line
1.7.5.2
#3 lore raw

PATCH 1/1 Change behaviour of symlink .config

In reply to Benoit Mauduit

Le Tue, 28 Jun 2011 14:07:29 +0200,
Benoit Mauduit <[email protected]> a ?crit :

Quoted 8 lines

This patch change the bahaviour with .config management.

The default behaviour is modified only if .config is a symbolic link. In this case, the target pointed by the link will be overwritten, and the old .config is save to .config.old.

This can be useful when we want to save and use the config file outside the Buildroot directory.

I am not sure to understand your use case. Isn't using out-of-tree builds with O= a better solution, if what you want is to have the config file outside of the Buildroot source directory ?

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/1 Change behaviour of symlink .config

Quoted 4 lines · Thomas Petazzoni

I am not sure to understand your use case. Isn't using out-of-tree builds with O= a better solution, if what you want is to have the config file outside of the Buildroot source directory ?

I will try to explain my use case :
We use buildroot as a tool inside another, but we want to have the choice of the tool for particular target.
For example, if I want to build the kernel and rootfs with Buildroot and the bootloader with another tool.
Actually, the "Buildroot tool" is a Buildroot wrapper. It can be configured with buildroot .config files and keep track of them in another directory with another config filename.

We can save config for specific board (using make savedefconfig), but we don't want to because is much for development purpose. Also, we don't need to export the output of buildroot in another directory. The trivial solution is to override the CONFIG_DIR variable but we must name the config file ".config".

I know this patch is not useful for buildroot itself, but if it can help some users.

Quoted 1 line

Regards,

Thanks for the review :)

Signature · 1 line
Beno?t Mauduit