From patchwork Sun Jul 3 15:08:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 643751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rjD743GDYz9t0k for ; Mon, 4 Jul 2016 01:08:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=KIKyXeZA; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6B4FF8A907; Sun, 3 Jul 2016 15:08:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TkpA8566ZAaE; Sun, 3 Jul 2016 15:08:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 8481188C07; Sun, 3 Jul 2016 15:08:28 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 083601C11A9 for ; Sun, 3 Jul 2016 15:08:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 04E9425ACF for ; Sun, 3 Jul 2016 15:08:27 +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 fWPmudnlKjpE for ; Sun, 3 Jul 2016 15:08:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by silver.osuosl.org (Postfix) with ESMTPS id 551C131340 for ; Sun, 3 Jul 2016 15:08:25 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id c82so16190387wme.3 for ; Sun, 03 Jul 2016 08:08:25 -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; bh=eIWnn/hzRGy9n+8qhPvaK2963oIJf/p9Z8MtnqCEXJY=; b=KIKyXeZA0VwgTRMuM6y8QIHkShccUGVtqPAKxsMZp9f+BARtzgraDA4gOG58a1ythn Rts833TxFEWW7xEwmrJPOOzAChrX0dFmdPO8zLb3JnxI7t1oFzFFQyqSbJJe89I3CJSJ gxF6St0YBDq0zXA2bAAAFhbOi/zBUA30yPG+1c7PW4lv16uLoALE6psUJsmYO/OYZ3Av 0KweAq6YvyTzADs5hqKVb3vxPL8qqfyShMEyuwFU77ciia7L0zDQqJmPW7PGXiGx2kz7 otj8ROiNkRvZKsBDxHOFhju9WpUuj9Q95BQ2/nVc7VzRPsBQcIWDjg2FPiqdMj+BpNn8 clDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=eIWnn/hzRGy9n+8qhPvaK2963oIJf/p9Z8MtnqCEXJY=; b=Hos+kYsCSgQIZXmyA7T3ArzyvlbdHRkX/wjfymzBuoqh5aAQcBdrahmwTUJ4cLOLoH hXIh91EdWKaXeGWn9GR9Y5wVJGoljGxT3IFze6k5W21d7xQUuf2bX69AjDaAeGbhzcDD y3CAtkHNqEjZwC28uT0caHTI0cWa3yPK6s8ny8rJMOG6zhkIHquXcTTgmjmlePEmM2on HPyGehB1iLGimyU0w6PDdA91rMlVWeVMBZj41bsRnPbNbGU7dYfouHYYgfeB4+avQUlC xUqu6l2jcTozWxXAt4sWubHi6Ucf9EYcx4yN5qHbbOhaxyv0LueBfqNAja28x7rRsFKX 710A== X-Gm-Message-State: ALyK8tL30aBhzOjJ04T48OsnoLAyDV58ScPDTFkj3AQl+et5ZV121bFsGNOmMP69MO4uiQ== X-Received: by 10.28.168.7 with SMTP id r7mr6983542wme.9.1467558503921; Sun, 03 Jul 2016 08:08:23 -0700 (PDT) Received: from gourin.home ([2a01:cb19:84c0:6b00:3e97:eff:fe77:54d6]) by smtp.gmail.com with ESMTPSA id a4sm5154038wjq.40.2016.07.03.08.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jul 2016 08:08:23 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 3 Jul 2016 17:08:19 +0200 Message-Id: <1467558499-16415-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 2.7.4 Cc: Thomas Petazzoni , Cam Hutchison , "Yann E. MORIN" Subject: [Buildroot] [PATCH] fs/common: add option to execute custom scripts under fakeroot 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" Some users have the need to be able to tweak the content of the target rootfs with root-like rights, that is, from inside the fakeroot script. Add a new system option to allow those users to provide a list of scripts, like the post-build and post-image scripts, that will be run from our fakeroot script. Signed-off-by: "Yann E. MORIN" Cc: Thomas Petazzoni Cc: Peter Korsgaard Cc: Cam Hutchison --- fs/common.mk | 3 +++ system/Config.in | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/fs/common.mk b/fs/common.mk index b7202c3..d5adf40 100644 --- a/fs/common.mk +++ b/fs/common.mk @@ -92,6 +92,9 @@ endif $$(call PRINTF,$$(PACKAGES_PERMISSIONS_TABLE)) >> $$(FULL_DEVICE_TABLE) echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT) endif + $$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_FAKEROOT_SCRIPT)),\ + echo "echo '$$(TERM_BOLD)>>> Executing fakeroot script $$(s)$$(TERM_RESET)'" >>$$(FAKEROOT_SCRIPT); \ + echo $$(s) $$(BR2_ROOTFS_POST_SCRIPT_ARGS) >>$$(FAKEROOT_SCRIPT)) $$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT) chmod a+x $$(FAKEROOT_SCRIPT) PATH=$$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT) diff --git a/system/Config.in b/system/Config.in index 15d5b55..6219b83 100644 --- a/system/Config.in +++ b/system/Config.in @@ -454,6 +454,37 @@ config BR2_ROOTFS_POST_BUILD_SCRIPT argument. Make sure the exit code of those scripts are 0, otherwise make will stop after calling them. +config BR2_ROOTFS_POST_FAKEROOT_SCRIPT + string "Custom scripts to run at the end of the fakeroot environment" + default "" + help + Specify a space-separated list of scripts to be run at the end + of the fakeroot script right before the image is actually + generated. + + This gives users the opportunity to do customisations of the + content of the rootfs, which would otherwise require root + rigths. + + These scripts are called with the target directory name as + first argument. The build will fail on the first scripts that + exits with a non-zero exit code. + + Note that Buildroot already provides mechanisms to customise + the content of the rootfs: + - BR2_ROOTFS_STATIC_DEVICE_TABLE + to create arbitrary entries static in /dev + + - BR2_ROOTFS_DEVICE_TABLE + to set arbitrary permissions as well as extended attributes + (such as capabilities)on files and directories, + + - BR2_ROOTFS_USERS_TABLES: + to create arbitrary users and their home directories + + It is highly recommended to use those mechanisms if possible, + rather than using custom fakeroot scripts. + config BR2_ROOTFS_POST_IMAGE_SCRIPT string "Custom scripts to run after creating filesystem images" default "" @@ -473,8 +504,10 @@ config BR2_ROOTFS_POST_IMAGE_SCRIPT 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 != "" + string "Extra arguments passed to custom scripts" + depends on BR2_ROOTFS_POST_BUILD_SCRIPT != "" \ + || BR2_ROOTFS_POST_FAKEROOT_SCRIPT != "" \ + || BR2_ROOTFS_POST_IMAGE_SCRIPT != "" help Pass these additional arguments to each post-build or post-image scripts.