[Buildroot] Execute Makefile before genrate rootfs

Daniel Mack daniel at caiaq.de
Fri Jul 24 08:42:41 UTC 2009


On Fri, Jul 24, 2009 at 10:11:00AM +0200, Lars Lockenvitz wrote:
> I'm looking for a way to execute a Makefile or script after all packages  
> are build and installed but befor buildroot is generating the rootfs 
> filr.
> The reason is that for different projects I maybe need the same  
> platform, packages and so on, but different settings for example in  
> inittab or other coniguration files.

We had the same demand, and I submitted a patch to do exactly that some
weeks ago. It was found to be useful by people, and we're actively using
it here in our tree, but it hasn't been commited to mainline yet.

I've attached it again, at least for you to pick it :)

Daniel


>From 51a4aec03908dae101e1a7fe7aede32c453053f1 Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel at caiaq.de>
Date: Wed, 8 Jul 2009 22:44:03 +0200
Subject: [PATCH] Add support for custom post-build script

The config help text says it all:

  Specify a script to be run after the build has finished and before
  the BR2 starts packing the files into selected packages.

  This gives users the oportunity to do board-specific cleanups,
  add-ons and the like, so the generated files can be used directly
  without further processing.

  The script is called with the target directory name as first and
  only argument. Make sure the exit code of that script is 0,
  otherwise make will stop after calling it.

Signed-off-by: Daniel Mack <daniel at caiaq.de>
Cc: Sven Neumann <s.neumann at raumfeld.com>
---
 Makefile         |    4 ++++
 target/Config.in |   15 +++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 76dd2cd..dbeede5 100644
--- a/Makefile
+++ b/Makefile
@@ -360,6 +360,10 @@ endif
 	find $(TARGET_DIR) -type f -perm +111 | xargs $(STRIPCMD) 2>/dev/null || true
 	$(TARGET_LDCONFIG) -r $(TARGET_DIR) 2>/dev/null
 
+ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
+	$(BR2_ROOTFS_POST_BUILD_SCRIPT) $(TARGET_DIR)
+endif
+
 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
 LOCALE_WHITELIST=$(PROJECT_BUILD_DIR)/locales.nopurge
 LOCALE_NOPURGE=$(strip $(subst ",,$(BR2_ENABLE_LOCALE_WHITELIST)))
diff --git a/target/Config.in b/target/Config.in
index 87abbe6..dbdc2d6 100644
--- a/target/Config.in
+++ b/target/Config.in
@@ -12,6 +12,21 @@ config BR2_ROOTFS_SUFFIX
 	help
 	  Add a custom string to the end of the root file system name.
 
+config BR2_ROOTFS_POST_BUILD_SCRIPT
+	string "Custom script to run before packing files"
+	default ""
+	help
+	  Specify a script to be run after the build has finished and before
+	  the BR2 starts packing the files into selected packages.
+
+	  This gives users the oportunity to do board-specific cleanups,
+	  add-ons and the like, so the generated files can be used directly
+	  without further processing.
+
+	  The script is called with the target directory name as first and
+	  only argument. Make sure the exit code of that script is 0,
+	  otherwise make will stop after calling it.
+
 comment "filesystem for target device"
 
 source "target/cramfs/Config.in"
-- 
1.6.3.1



More information about the buildroot mailing list