From patchwork Sat Nov 17 13:52:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 199855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id D89142C0040 for ; Sun, 18 Nov 2012 00:52:43 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5B36F8D0AC; Sat, 17 Nov 2012 13:52:40 +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 sM7PlvRF4NJx; Sat, 17 Nov 2012 13:52:37 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 008118D043; Sat, 17 Nov 2012 13:52:36 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 5F1A78F74A for ; Sat, 17 Nov 2012 13:52:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EB71D30DE2 for ; Sat, 17 Nov 2012 13:52:35 +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 ROH0GiWC6xzO for ; Sat, 17 Nov 2012 13:52:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [88.190.12.23]) by silver.osuosl.org (Postfix) with ESMTP id E9D3430E21 for ; Sat, 17 Nov 2012 13:52:31 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 106) id 3E45517D; Sat, 17 Nov 2012 14:52:24 +0100 (CET) Received: from localhost (46.130.200.77.rev.sfr.net [77.200.130.46]) by mail.free-electrons.com (Postfix) with ESMTPSA id F36B1DB; Sat, 17 Nov 2012 14:52:13 +0100 (CET) From: Thomas Petazzoni To: buildroot@uclibc.org Date: Sat, 17 Nov 2012 14:52:14 +0100 Message-Id: <1353160334-30174-1-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 1.7.9.5 Cc: Juha Lumme Subject: [Buildroot] [PATCH] Warn the user about the usage of output/target as the root filesystem 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 A very common mistake done by our users is that they use output/target/ directory as their root filesystem. Even though this is loudly documented in our Buildroot manual, people don't read documentation, so it is not sufficient. This patch adds a text file named output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM which explains why output/target isn't appropriate to use as the root filesystem. The process is: * At the beginning of the build, right after the skeleton has been copied, support/misc/target-dir-warning.txt is copied to output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM * In the filesystem images creation code, this file is removed before launching fakeroot, and restored right after that, so that this file is not present in the generated root filesystem images. Note that the file has not been added to the default skeleton for two reasons: * It would have annoying to have in our source tree a file named in capital letters inside system/skeleton/ * The proposed way works even if the user uses a custom skeleton. Signed-off-by: Thomas Petazzoni Cc: Juha Lumme Acked-by: Gustavo Zacarias --- Makefile | 5 +++++ fs/common.mk | 2 ++ support/misc/target-dir-warning.txt | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 support/misc/target-dir-warning.txt diff --git a/Makefile b/Makefile index c526fe1..3e7d520 100644 --- a/Makefile +++ b/Makefile @@ -269,6 +269,10 @@ LEGAL_LICENSES_TXT=$(LEGAL_INFO_DIR)/licenses.txt LEGAL_WARNINGS=$(LEGAL_INFO_DIR)/.warnings LEGAL_REPORT=$(LEGAL_INFO_DIR)/README +# Location of a file giving a big fat warning that output/target +# should not be used as the root filesystem. +TARGET_DIR_WARNING_FILE=$(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM + ifeq ($(BR2_CCACHE),y) CCACHE:=$(HOST_DIR)/usr/bin/ccache BUILDROOT_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR)) @@ -403,6 +407,7 @@ $(BUILD_DIR)/.root: cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \ fi; \ fi + cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE) -find $(TARGET_DIR) -type d -name CVS -print0 -o -name .svn -print0 | xargs -0 rm -rf -find $(TARGET_DIR) -type f \( -name .empty -o -name '*~' \) -print0 | xargs -0 rm -rf touch $@ diff --git a/fs/common.mk b/fs/common.mk index 0f0eae9..b1512dd 100644 --- a/fs/common.mk +++ b/fs/common.mk @@ -45,6 +45,7 @@ $(BINARIES_DIR)/rootfs.$(1): $(ROOTFS_$(2)_DEPENDENCIES) @$(call MESSAGE,"Generating root filesystem image rootfs.$(1)") $(foreach hook,$(ROOTFS_$(2)_PRE_GEN_HOOKS),$(call $(hook))$(sep)) rm -f $(FAKEROOT_SCRIPT) + rm -f $(TARGET_DIR_WARNING_FILE) echo "chown -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT) ifneq ($(ROOTFS_DEVICE_TABLES),) cat $(ROOTFS_DEVICE_TABLES) > $(FULL_DEVICE_TABLE) @@ -57,6 +58,7 @@ endif echo "$(ROOTFS_$(2)_CMD)" >> $(FAKEROOT_SCRIPT) chmod a+x $(FAKEROOT_SCRIPT) $(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT) + cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE) -@rm -f $(FAKEROOT_SCRIPT) $(FULL_DEVICE_TABLE) $(foreach hook,$(ROOTFS_$(2)_POST_GEN_HOOKS),$(call $(hook))$(sep)) ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y) diff --git a/support/misc/target-dir-warning.txt b/support/misc/target-dir-warning.txt new file mode 100644 index 0000000..b39b759 --- /dev/null +++ b/support/misc/target-dir-warning.txt @@ -0,0 +1,29 @@ +Warning! +======== + +This directory does *not* contain the root filesystem that you can use +on your embedded system. Since Buildroot does not run as root, it +cannot create device files and set the permissions and ownership of +files correectly in this directory to make it usable as a root +filesystem. + +For that reason, do *not* use the contents of this directory to mount +your root filesystem over NFS or copy the contents of this directory +to a SD card or USB key, thinking it will work as the root filesystem +for your embedded system. It will simply *not* work. + +Instead, if you need a usable root filesystem, please select one of +the filesystem image formats available in the Buildroot configuration +interface (make menuconfig or others) in the "Filesystem images" +sub-menu. If you want to get a filesystem image that you can easily +extract to your SD card or to some directory exposed through NFS, +please use the "tar the root filesystem" option. It will generate a +images/rootfs.tar image in your Buildroot output directory, which you +can extract as root: + + sudo tar -C /destination/of/extraction -xf images/rootfs.tar + +Those image files are created using the contents of the target/ +directory, but there is a post-processing step to create device files +and set owernship/permissions properly even if Buildroot does not run +as root.