Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
@ 2011-06-28 12:07 Benoit Mauduit
  2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
  2011-06-28 14:18 ` Thomas Petazzoni
  0 siblings, 2 replies; 6+ messages in thread
From: Benoit Mauduit @ 2011-06-28 12:07 UTC (permalink / raw)
  To: buildroot

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
@ 2011-06-28 12:07 Benoit Mauduit
  0 siblings, 0 replies; 6+ messages in thread
From: Benoit Mauduit @ 2011-06-28 12:07 UTC (permalink / raw)
  To: buildroot

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/package/config/confdata.c
+++ b/package/config/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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCHv2] [package/config] Change behaviour of symlink .config
  2011-06-28 12:07 [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config Benoit Mauduit
@ 2011-06-28 13:51 ` Benoît Mauduit
  2011-06-28 13:51   ` [Buildroot] [PATCH] " Benoît Mauduit
  2011-06-28 14:18 ` Thomas Petazzoni
  1 sibling, 1 reply; 6+ messages in thread
From: Benoît Mauduit @ 2011-06-28 13:51 UTC (permalink / raw)
  To: buildroot


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
  2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
@ 2011-06-28 13:51   ` Benoît Mauduit
  0 siblings, 0 replies; 6+ messages in thread
From: Benoît Mauduit @ 2011-06-28 13:51 UTC (permalink / raw)
  To: buildroot

From: Benoit Mauduit <benoit.mauduit@openwide.fr>

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

diff --git a/package/config/confdata.c b/package/config/confdata.c
index c9f13ee..c00639f 100644
--- a/package/config/confdata.c
+++ b/package/config/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());
diff --git a/package/config/patches/13-Change-behaviour-of-symlink-config.patch b/package/config/patches/13-Change-behaviour-of-symlink-config.patch
new file mode 100644
index 0000000..e4e7be4
--- /dev/null
+++ b/package/config/patches/13-Change-behaviour-of-symlink-config.patch
@@ -0,0 +1,40 @@
+From 3c8ff86dbe779f00eaa5692ef61cabef4466e5d6 Mon Sep 17 00:00:00 2001
+From: Benoit Mauduit <benoit.mauduit@openwide.fr>
+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
+
diff --git a/package/config/patches/series b/package/config/patches/series
index defdf58..b5455fd 100644
--- a/package/config/patches/series
+++ b/package/config/patches/series
@@ -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
-- 
1.7.5.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
  2011-06-28 12:07 [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config Benoit Mauduit
  2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
@ 2011-06-28 14:18 ` Thomas Petazzoni
  2011-06-28 15:42   ` Benoît Mauduit
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2011-06-28 14:18 UTC (permalink / raw)
  To: buildroot

Le Tue, 28 Jun 2011 14:07:29 +0200,
Benoit Mauduit <benoit.mauduit@gmail.com> a ?crit :

> 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
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
  2011-06-28 14:18 ` Thomas Petazzoni
@ 2011-06-28 15:42   ` Benoît Mauduit
  0 siblings, 0 replies; 6+ messages in thread
From: Benoît Mauduit @ 2011-06-28 15:42 UTC (permalink / raw)
  To: buildroot

On Tue, Jun 28, 2011 at 4:18 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
>
> 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.

> Regards,
Thanks for the review :)


-- 
Beno?t Mauduit

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-28 15:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-28 12:07 [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config Benoit Mauduit
2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
2011-06-28 13:51   ` [Buildroot] [PATCH] " Benoît Mauduit
2011-06-28 14:18 ` Thomas Petazzoni
2011-06-28 15:42   ` Benoît Mauduit
  -- strict thread matches above, loose matches on Subject: below --
2011-06-28 12:07 Benoit Mauduit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox