From patchwork Tue Jul 9 22:00:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 257870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id F37F42C041F for ; Wed, 10 Jul 2013 08:01:08 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E5D3195DEE; Tue, 9 Jul 2013 22:01:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U5a7Jv_k94nW; Tue, 9 Jul 2013 22:01:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 998F995487; Tue, 9 Jul 2013 22:01:05 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 5F44A1BFA9B for ; Tue, 9 Jul 2013 22:01:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 910708C7CC for ; Tue, 9 Jul 2013 22:01:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9nDduVQDve6v for ; Tue, 9 Jul 2013 22:00:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by whitealder.osuosl.org (Postfix) with ESMTPS id 666978C900 for ; Tue, 9 Jul 2013 22:00:40 +0000 (UTC) Received: by mail-wi0-f182.google.com with SMTP id m6so5641745wiv.15 for ; Tue, 09 Jul 2013 15:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=Fspr1j7d998fMU7VEA4BqHHwG2zKwrA9NS3TL4Cco1w=; b=rjCEuLqOxvtda8za0jrPNdYMBhdN0sPTDn9uBXQzcyvEFBrRYtL0oJMW00+LfMgomZ I/IX1I/0iA/+YBQR4rZ4T5egvIiODp8oHn24V51CSneveM3srHVk9UWldYy4uYaDSIr/ AhN/cKZD+cZwazluWwRY1KbJDT6OfmVBbMpEWVdX3XpgsGFwnCvf/7FLg760DRXm9k2s 6SmMjmbz4mloMeHvPbS3oIxjRaICtVgYPHB9dPHFpGrUnQztV2Dm/DpYikzv03DGIQga 8gsKqb3alM4bFT6ZG2Z4HJkklYq1XGuSW++f6dTNXRFvVmH1WCf2dA9Fe8dx4kQL3sx6 IARA== X-Received: by 10.194.235.161 with SMTP id un1mr16386739wjc.6.1373407238475; Tue, 09 Jul 2013 15:00:38 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id x2sm19881525wif.3.2013.07.09.15.00.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jul 2013 15:00:37 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@busybox.net Date: Wed, 10 Jul 2013 00:00:31 +0200 Message-Id: <1373407231-20382-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 1.8.1.2 Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH] system: add option to pass extra args to post-build and post-image scripts X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: "Yann E. MORIN" It can be useful to have different configuration use the same post-build and/or post-image scripts as they share a common infrastructure, but yet have minor differentiation. This option allows passing zero or more additional arguments to each post-build or post-image script. The same set of extra arguments are passed to all scripts, it is not possible to pass different arguments to each script. Signed-off-by: "Yann E. MORIN" Cc: Baruch Siach --- Changes v1 -> v2: - $(TARGET_DIR) is no longer the only argument (Baruch) - mention BR2_ROOTFS_POST_IMAGE_SCRIPT in the manual --- Makefile | 4 ++-- docs/manual/customize-rootfs.txt | 19 ++++++++++++------- system/Config.in | 26 +++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 955e684..f6e9965 100644 --- a/Makefile +++ b/Makefile @@ -512,7 +512,7 @@ endif @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ $(call MESSAGE,"Executing post-build script $(s)"); \ - $(s) $(TARGET_DIR)$(sep)) + $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) ifeq ($(BR2_ENABLE_LOCALE_PURGE),y) LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge @@ -558,7 +558,7 @@ endif target-post-image: @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \ - $(s) $(BINARIES_DIR)$(sep)) + $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) toolchain-eclipse-register: ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH) diff --git a/docs/manual/customize-rootfs.txt b/docs/manual/customize-rootfs.txt index 7ff8d8b..49a6b4b 100644 --- a/docs/manual/customize-rootfs.txt +++ b/docs/manual/customize-rootfs.txt @@ -69,15 +69,20 @@ specify a space-separated list of scripts in the found in the +System configuration+ menu as well. Each of those scripts will be called with the path to the +images+ -output directory as first and unique argument, and will be executed -with the main Buildroot source directory as the current -directory. Those scripts will be executed as the user that executes -Buildroot, which should normally not be the root user. Therefore, any -action requiring root permissions in one of these _post-image scripts_ -will require special handling (usage of fakeroot or sudo), which is -left to the script developer. +output directory as first argument, and will be executed with the main +Buildroot source directory as the current directory. Those scripts will +be executed as the user that executes Buildroot, which should normally +not be the root user. Therefore, any action requiring root permissions +in one of these _post-image scripts_ will require special handling +(usage of fakeroot or sudo), which is left to the script developer. Just like for the _post-build scripts_ mentioned above, you also have access to the following environment variables from your _post-image scripts_: +BUILDROOT_CONFIG+, +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+, +BINARIES_DIR+ and +BASE_DIR+. + +Additionally, each of the +BR2_ROOTFS_POST_BUILD_SCRIPT+ and ++BR2_ROOTFS_POST_IMAGE_SCRIPT+ scripts will be passed the arguments +specified in +BR2_ROOTFS_POST_SCRIPT_ARGS+ (if that is not empty). +All the scripts will be passed the exact same set of arguments, it +is not possible to pass different sets of arguments to each script. diff --git a/system/Config.in b/system/Config.in index c0e4f4a..7379d15 100644 --- a/system/Config.in +++ b/system/Config.in @@ -272,9 +272,9 @@ config BR2_ROOTFS_POST_BUILD_SCRIPT add-ons and the like, so the generated files can be used directly without further processing. - These scripts are called with the target directory name as first and - only argument. Make sure the exit code of those scripts are 0, - otherwise make will stop after calling them. + These scripts are called with the target directory name as first + argument. Make sure the exit code of those scripts are 0, otherwise + make will stop after calling them. config BR2_ROOTFS_POST_IMAGE_SCRIPT string "Custom scripts to run after creating filesystem images" @@ -291,7 +291,23 @@ config BR2_ROOTFS_POST_IMAGE_SCRIPT action. These scripts are called with the images directory name as - first and only argument. The script is executed from the - main Buildroot source directory as the current directory. + first argument. The script is executed from the main Buildroot + source directory as the current directory. + +config BR2_ROOTFS_POST_SCRIPT_ARGS + string "Extra post-{build,image} arguments" + depends on BR2_ROOTFS_POST_BUILD_SCRIPT != "" || BR2_ROOTFS_POST_IMAGE_SCRIPT != "" + help + Pass these aditional arguments to each post-build or post-image + scripts. + + Note that all the post-build and post-image scripts will be passed + the same set of arguments, you can not pass different arguments to + each script. + + Note also, as stated in their respective help text, that the first + argument to each post-build or post-image script is the target/ + directory $(TARGET_DIR). The arguments in this option will be + passed *after*. endmenu