diff mbox

[U-Boot,19/21] tools: moveconfig: report when defconfig is updated

Message ID 1463640729-25666-20-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit c8e1b10d07b1dbbf3cbf882ac270476b964d05ff
Delegated to: Masahiro Yamada
Headers show

Commit Message

Masahiro Yamada May 19, 2016, 6:52 a.m. UTC
There are various factors that determine if the given defconfig is
updated, and it is probably what users are more interested in.

Show the log when the defconfig is updated.  Also, copy the file
only when the file content was really updated to avoid changing
the time stamp needlessly.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 tools/moveconfig.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Joe Hershberger May 24, 2016, 2:55 p.m. UTC | #1
On Thu, May 19, 2016 at 1:52 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> There are various factors that determine if the given defconfig is
> updated, and it is probably what users are more interested in.
>
> Show the log when the defconfig is updated.  Also, copy the file
> only when the file content was really updated to avoid changing
> the time stamp needlessly.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 9c73b30..65cc5b3 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -172,6 +172,7 @@  To see the complete list of supported options, run
 
 """
 
+import filecmp
 import fnmatch
 import multiprocessing
 import optparse
@@ -717,9 +718,16 @@  class Slot:
 
         if self.state == STATE_SAVEDEFCONFIG:
             self.log += self.parser.check_defconfig()
-            if not self.options.dry_run:
-                shutil.move(os.path.join(self.build_dir, 'defconfig'),
-                            os.path.join('configs', self.defconfig))
+            orig_defconfig = os.path.join('configs', self.defconfig)
+            new_defconfig = os.path.join(self.build_dir, 'defconfig')
+            updated = not filecmp.cmp(orig_defconfig, new_defconfig)
+
+            if updated:
+                self.log += color_text(self.options.color, COLOR_LIGHT_GREEN,
+                                       "defconfig was updated.\n")
+
+            if not self.options.dry_run and updated:
+                shutil.move(new_defconfig, orig_defconfig)
             self.finish(True)
             return True