From patchwork Wed Aug 23 20:45:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 805170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xczwW6Twzz9t34 for ; Thu, 24 Aug 2017 06:46:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6B76530B28; Wed, 23 Aug 2017 20:46:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q5ZkYKBlhWqj; Wed, 23 Aug 2017 20:46:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 5630830B2C; Wed, 23 Aug 2017 20:46:00 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 655701C1FCF for ; Wed, 23 Aug 2017 20:45:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 594E78905E for ; Wed, 23 Aug 2017 20:45:59 +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 Wh+MawHMARgH for ; Wed, 23 Aug 2017 20:45:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by whitealder.osuosl.org (Postfix) with ESMTP id EE23889056 for ; Wed, 23 Aug 2017 20:45:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 766DD209BA; Wed, 23 Aug 2017 22:45:56 +0200 (CEST) Received: from localhost (132.230.147.77.rev.sfr.net [77.147.230.132]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0DB5E20993; Wed, 23 Aug 2017 22:45:56 +0200 (CEST) From: Thomas Petazzoni To: Buildroot List , "Yann E. MORIN" , "Arnout Vandecappelle (Essensium/Mind)" , Peter Korsgaard Date: Wed, 23 Aug 2017 22:45:46 +0200 Message-Id: <20170823204547.16672-2-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170823204547.16672-1-thomas.petazzoni@free-electrons.com> References: <20170823204547.16672-1-thomas.petazzoni@free-electrons.com> Cc: Thomas Petazzoni Subject: [Buildroot] [RFC-next 1/2] fs/genimage: add logic to generate an image using genimage X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 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" We have more and more boards that need to repeat in their post-image script the logic to use genimage. Even though the logic has been factorized in support/scripts/genimage.sh, users still have to remember that they need to enable BR2_PACKAGE_HOST_MTOOLS and BR2_PACKAGE_HOST_DOSFSTOOLS when they have a VFAT partition in their genimage configuration. Therefore, this commit adds some minimal logic in Buildroot to use genimage directly. This logic is added into fs/genimage/, even if stricly speaking genimage isn't a filesystem format. It does not use the filesystem infrastructure (fs/common.mk), and is referenced explicitly from the target-post-image target in the main Makefile. Signed-off-by: Thomas Petazzoni --- Makefile | 1 + fs/Config.in | 1 + fs/genimage/Config.in | 26 ++++++++++++++++++++++++++ fs/genimage/genimage.mk | 31 +++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 fs/genimage/Config.in create mode 100644 fs/genimage/genimage.mk diff --git a/Makefile b/Makefile index 1b0e36f..3baad7b 100644 --- a/Makefile +++ b/Makefile @@ -733,6 +733,7 @@ endif .PHONY: target-post-image target-post-image: $(TARGETS_ROOTFS) target-finalize + $(GENIMAGE_GENERATE_CMDS) @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \ $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) diff --git a/fs/Config.in b/fs/Config.in index 51ccf28..04b4ebe 100644 --- a/fs/Config.in +++ b/fs/Config.in @@ -13,5 +13,6 @@ source "fs/squashfs/Config.in" source "fs/tar/Config.in" source "fs/ubifs/Config.in" source "fs/yaffs2/Config.in" +source "fs/genimage/Config.in" endmenu diff --git a/fs/genimage/Config.in b/fs/genimage/Config.in new file mode 100644 index 0000000..bd747bc --- /dev/null +++ b/fs/genimage/Config.in @@ -0,0 +1,26 @@ +config BR2_TARGET_ROOTFS_GENIMAGE + bool "generate a final image with genimage" + select BR2_PACKAGE_HOST_GENIMAGE + help + This option allows to generate a final image to flash on + your device using a tool called genimage. + +if BR2_TARGET_ROOTFS_GENIMAGE + +config BR2_TARGET_ROOTFS_GENIMAGE_CFG_FILE + string "genimage config file" + help + This option allows to specify the path to the genimage + configuration file. See + https://git.pengutronix.de/cgit/genimage/plain/README for + the specification of the genimage configuration file format. + +config BR2_TARGET_ROOTFS_GENIMAGE_USES_VFAT + bool "genimage config uses vfat" + select BR2_PACKAGE_HOST_DOSFSTOOLS + select BR2_PACKAGE_HOST_MTOOLS + help + Enable this option if your genimage configuration file uses + a "vfat" section to generate a VFAT filesystem. + +endif diff --git a/fs/genimage/genimage.mk b/fs/genimage/genimage.mk new file mode 100644 index 0000000..b44b29b --- /dev/null +++ b/fs/genimage/genimage.mk @@ -0,0 +1,31 @@ +################################################################################ +# +# genimage support +# +################################################################################ + +ifeq ($(BR2_TARGET_ROOTFS_GENIMAGE),y) +PACKAGES += host-genimage + +ifeq ($(BR2_TARGET_ROOTFS_GENIMAGE_USES_VFAT),y) +PACKAGES += host-dosfstools host-mtools +endif + +GENIMAGE_CFG_FILE = $(call qstrip,$(BR2_TARGET_ROOTFS_GENIMAGE_CFG_FILE)) +GENIMAGE_TMP = $(BUILD_DIR)/genimage.tmp + +define GENIMAGE_GENERATE_CMDS + if grep -q "vfat.*{" $(GENIMAGE_CFG_FILE) && \ + test "$(BR2_TARGET_ROOTFS_GENIMAGE_USES_VFAT)" != "y" ; then \ + echo "ERROR: genimage configuration generates a VFAT filesystem" ; \ + echo " please enable BR2_TARGET_ROOTFS_GENIMAGE_USES_VFAT" ; \ + fi + $(RM) -rf $(GENIMAGE_TMP) + $(HOST_DIR)/usr/bin/genimage --rootpath $(TARGET_DIR) \ + --tmppath $(GENIMAGE_TMP) \ + --inputpath $(BINARIES_DIR) \ + --outputpath $(BINARIES_DIR) \ + --config $(GENIMAGE_CFG_FILE) +endef + +endif # BR2_TARGET_ROOTFS_GENIMAGE