From patchwork Tue Sep 3 12:09:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= X-Patchwork-Id: 1156956 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=essensium.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=essensium-com.20150623.gappssmtp.com header.i=@essensium-com.20150623.gappssmtp.com header.b="arBE8y4y"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46N5Wd5J5Cz9s4Y for ; Tue, 3 Sep 2019 22:15:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0F49F87723; Tue, 3 Sep 2019 12:15:36 +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 Wj4CPWGZokRo; Tue, 3 Sep 2019 12:15:32 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 072778770C; Tue, 3 Sep 2019 12:15:32 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 0243C1BF2C6 for ; Tue, 3 Sep 2019 12:15:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id F36A48688F for ; Tue, 3 Sep 2019 12:15:30 +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 Ssg4e3zSu20N for ; Tue, 3 Sep 2019 12:15:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8E1378647F for ; Tue, 3 Sep 2019 12:15:29 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id c19so4444206edy.10 for ; Tue, 03 Sep 2019 05:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gItEbEY+7uym4WcxLY5hgCcQMF+uXtu7efeQONa5gj8=; b=arBE8y4ycKvOgCzJh8v8roYpgODAJs1lTZlNTf2gGM8cD0dLyelOMzQVZa6uuBLkRe As985zZSCsn1bIPANfBFzIoUp4bKp6JHj+a59YngPxe0KvBOxV7/06WEBKQJgyyinxVE SatZn8NQRVlUxIW1J2FjmC/KxSOI1HjyMZP1kIqcdM0uu5JqagjCxuRXxvB4GnN8YyPS Ze70CFiQUA5p0CPc5/y79tpSfM1eV45ejTVRIkrNdUb6wPViPmfGP2iQ2C/iXevctREe F+0+q5MSDiAGqlIK7460yqneswzHEwA2Z9JqV4lbHZfpe13K9h+VM6EnSSDjlwiXd7H8 uffw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gItEbEY+7uym4WcxLY5hgCcQMF+uXtu7efeQONa5gj8=; b=aQCzAo8onkxPjCZy/W57QvaGVee/jgnZmiY7XZOA3UkNcdWis4JKE1MHaM/g9K+lMZ 2aWUij6vy/jGu2zmjYA03b0Tzhd12J5eCv3pv5JuhJJlDIuGldTRGO6Ati3n6k0GBSt7 ulb/Tk4UJRr2OMRGwtp/GGxBN8DmumiVxrZMhlnsKaA/8f+Vu/vBaxWwvlcGkjajRvpb LHSSplivDAJhAxvoRZBIkLVBG1N5l5VbLB+R4Gl5/Ccz+l0QsXS09VVqx89q6Mim89Fp Cvzo4qBhcns/3Sa+mXfWSTDar2VWIMD9c5NGq2do0d5m3FEYVfDqbD3vbeZZ3+bYtVv7 BUqw== X-Gm-Message-State: APjAAAWRYGPiL6btDpD+1cR0imit2HiNKG4gvbJ9oOC0vzpzIjI7bqWK zwltE+s6sgxpUn0+EA+ZoY7u8w90vS0= X-Google-Smtp-Source: APXvYqxtXGZPCtrIj2KqvXhK8YLkuco++vEmm+jRvMn5DzTmvHvmldUavaOvYNTHm0sa30Ue31ha8w== X-Received: by 2002:a17:906:1493:: with SMTP id x19mr22942331ejc.39.1567512927473; Tue, 03 Sep 2019 05:15:27 -0700 (PDT) Received: from localhost.localdomain (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id i24sm2754622eds.27.2019.09.03.05.15.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 05:15:26 -0700 (PDT) From: raphael.melotte@essensium.com To: buildroot@buildroot.org Date: Tue, 3 Sep 2019 14:09:51 +0200 Message-Id: <20190903120951.3318-1-raphael.melotte@essensium.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] support/scripts/genimage.sh: allow setting rootpath from parameters. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: raphael.melotte@essensium.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Raphaël Mélotte Previously the rootpath was always set to $TARGET_DIR. This patch allows using other directories as rootpath. When you use genimage's mountpoints to generate an image with multiple (non-empty) partitions, it does two things: - copy $TARGET_DIR to $GENIMAGE_TMP/root - move any mountpoint from GENIMAGE_TMP/root to $GENIMAGE_TMP/ If you want to have an additional partition besides the rootfs, you will have to make sure it's content is in $TARGET_DIR so that genimage can find it. If you also use rootfs generated by buildroot, you will end up with two copies of the mountpoint: once in the rootfs itself, and once in the partition using the mountpoint. To better illustrate that behavior, here's an example configuration: image myhome.ext4 { name = "myhome" ext4{} size = 1G mountpoint = "/home/myhome" # Files will be copied from '/home/myhome' } image sdcard.img { hdimage { gpt = true } partition rootfs { partition-type = 0x83 image = "rootfs.ext4" # This the buildroot-generated rootfs, which already # contains the mountpoint } partition myhome { partition-type = 0x83 size = 1G image = "myhome.ext4" # genimage will generate and fill the partition itself } } As genimage correctly moves mountpoint from /root/ to /, a possible solution is to not use the rootfs generated by buildroot, but to use genimage to generate it from /root directly. The problem is that buildroot apply some additional fixups in the rootfs generation, that genimage doesn't have (see THIS_IS_NOT_YOUR_ROOT_FILESYSTEM). The remaining solutions are then to either: - Use the buildroot-generated rootfs, and patch genimage.sh to allow other rootpaths to be used. - Generate a filesystem for genimage, so that it's called under fakeroot and have all the fixups. This patch implements the first solution. Signed-off-by: Raphaël Mélotte --- support/scripts/genimage.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/support/scripts/genimage.sh b/support/scripts/genimage.sh index 039b3fef1d..071298a4b5 100755 --- a/support/scripts/genimage.sh +++ b/support/scripts/genimage.sh @@ -4,22 +4,26 @@ die() { cat <&2 Error: $@ -Usage: ${0} -c GENIMAGE_CONFIG_FILE +Usage: ${0} -c GENIMAGE_CONFIG_FILE [--rootpath ROOTPATH] EOF exit 1 } # Parse arguments and put into argument list of the script -opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $? +opts="$(getopt -n "${0##*/}" -o c: -l rootpath: -- "$@")" || exit $? eval set -- "$opts" GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" +GENIMAGE_ROOTPATH="${TARGET_DIR}" while true ; do case "$1" in -c) GENIMAGE_CFG="${2}"; shift 2 ;; + --rootpath) + GENIMAGE_ROOTPATH="${2}" + shift 2 ;; --) # Discard all non-option parameters shift 1; break ;; @@ -33,8 +37,8 @@ done rm -rf "${GENIMAGE_TMP}" genimage \ - --rootpath "${TARGET_DIR}" \ - --tmppath "${GENIMAGE_TMP}" \ - --inputpath "${BINARIES_DIR}" \ - --outputpath "${BINARIES_DIR}" \ + --rootpath "${GENIMAGE_ROOTPATH}" \ + --tmppath "${GENIMAGE_TMP}" \ + --inputpath "${BINARIES_DIR}" \ + --outputpath "${BINARIES_DIR}" \ --config "${GENIMAGE_CFG}"