Skip to contentSkip to conversation

post-build: pass an empty rootpath to genimage

PATCH New unixmania at gmail.com 3 participants 15 messages Oct 13, 2019 – Oct 27, 2019 Broadcom BCM2711/BCM2835 Arm architecture

lore
Share & tools
lore
#0 lore raw

cover post-build: pass an empty rootpath to genimage

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR is a waste of time and disk space. We don't rely on genimage to build rootfs images, just to insert pre-built images in the disk images.

The waste may be negligible for sporadic builds but becomes relevant if we think about autobuilders that perform several builds everyday.

Patch 1 changes support/scripts/genimage.sh to pass an empty rootpath to genimage.

Patches 2-6, 8 and 9 drop per-board scripts and use genimage.sh, passing the corresponding configuration file via BR2_ROOTFS_POST_SCRIPT_ARGS.

Patch 7 makes the same change in board/raspberrypi/post-image.sh. This script cannot be directly replaced by genimage.sh
because it does other things.

The board/beaglebone/post-image.sh script was not removed because it is used by beaglebone_qt5_defconfig, which is currently broken and cannot be tested.

Again, these changes may appear to be overkill but since Buildroot is an open source project each piece of code becomes a potential learning tool for other developers. We must strive to provide good examples.

Carlos Santos (9):
support/scripts/genimage.sh: pass an empty rootpath to genimage configs/beagleboardx15: drop custom post-image script configs/beaglebone: don't use custom post-image script configs/minnowboard_max-graphical: don't use custom post-image script configs/minnowboard_max: drop custom post-image script configs/pandaboard: drop custom post-image script board/raspberrypi/post-image.sh: pass an empty rootpath to genimage configs/roseapplepi: drop custom post-image script configs/wandboard: drop custom post-image script

 board/beagleboardx15/post-image.sh          | 15 ---------------
 board/beaglebone/post-build.sh              |  4 ++++
 board/minnowboard/post-image.sh             | 13 -------------
 board/pandaboard/post-image.sh              | 16 ----------------
 board/raspberrypi/post-image.sh             | 12 ++++++++++--
 board/roseapplepi/post-build.sh             |  4 ++++
 board/roseapplepi/post-image.sh             | 18 ------------------
 board/wandboard/post-image.sh               | 15 ---------------
 configs/beagleboardx15_defconfig            |  3 ++-
 configs/beaglebone_defconfig                |  4 +++-
 configs/minnowboard_max-graphical_defconfig |  3 ++-
 configs/minnowboard_max_defconfig           |  3 ++-
 configs/pandaboard_defconfig                |  3 ++-
 configs/roseapplepi_defconfig               |  4 +++-
 configs/wandboard_defconfig                 |  3 ++-
 support/scripts/genimage.sh                 | 10 +++++++++-
 16 files changed, 43 insertions(+), 87 deletions(-)
 delete mode 100755 board/beagleboardx15/post-image.sh
 create mode 100755 board/beaglebone/post-build.sh
 delete mode 100755 board/minnowboard/post-image.sh
 delete mode 100755 board/pandaboard/post-image.sh
 create mode 100755 board/roseapplepi/post-build.sh
 delete mode 100755 board/roseapplepi/post-image.sh
 delete mode 100755 board/wandboard/post-image.sh
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/9 support/scripts/genimage.sh: pass an empty rootpath to genimage

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 support/scripts/genimage.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
support/scripts/genimage.sh +9 -1
index 039b3fef1d..2796e19eb7 100755
@@ -30,10 +30,18 @@ done
 
 [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
 
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"
+
 rm -rf "${GENIMAGE_TMP}"
 
 genimage \
-	--rootpath "${TARGET_DIR}"     \
+	--rootpath "${ROOTPATH_TMP}"     \
 	--tmppath "${GENIMAGE_TMP}"    \
 	--inputpath "${BINARIES_DIR}"  \
 	--outputpath "${BINARIES_DIR}" \
Signature · 1 line
2.18.1
#2 lore raw

PATCH 1/9 support/scripts/genimage.sh: pass an empty rootpath to genimage

Quoted 17 lines · unixmania at gmail.com

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 support/scripts/genimage.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
support/scripts/genimage.sh +0 -0
index 039b3fef1d..2796e19eb7 100755

support/scripts/genimage.sh done · line 39

Quoted 10 lines
support/scripts/genimage.sh +7 -0
@@ -30,10 +30,18 @@ done
 
 [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
 
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"

Instead of a temporary directory, I think it would make sense to use a fixed
directory, e.g. $(BINARIES_DIR)/rootpath. This would allow the path to be used for some other things, i.e. packages could install stuff in there that could be used to generate a filesystem. Cfr. [1].

Regards,
Arnout

[1] http://patchwork.ozlabs.org/patch/1156956/

Quoted 10 lines
support/scripts/genimage.sh +2 -1
+
 rm -rf "${GENIMAGE_TMP}"
 
 genimage \
-	--rootpath "${TARGET_DIR}"     \
+	--rootpath "${ROOTPATH_TMP}"     \
 	--tmppath "${GENIMAGE_TMP}"    \
 	--inputpath "${BINARIES_DIR}"  \
 	--outputpath "${BINARIES_DIR}" \
#3 lore raw

PATCH 1/9 support/scripts/genimage.sh: pass an empty rootpath to genimage

Quoted 24 lines · Arnout Vandecappelle
Quoted 20 lines · unixmania at gmail.com

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 support/scripts/genimage.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
support/scripts/genimage.sh +0 -0
index 039b3fef1d..2796e19eb7 100755
@@ -30,10 +30,18 @@ done
 
 [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
 
Quoted 12 lines

support/scripts/genimage.sh done · line 39

Quoted 7 lines
support/scripts/genimage.sh +7 -0
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"

Instead of a temporary directory, I think it would make sense to use a fixed
directory, e.g. $(BINARIES_DIR)/rootpath. This would allow the path to be used for some other things, i.e. packages could install stuff in there that could be used to generate a filesystem. Cfr. [1].

That's exactly what I'm attempting to avoid.

Quoted 5 lines

Regards,
Arnout

[1] http://patchwork.ozlabs.org/patch/1156956/

I had to deal with that situation in the recent past. It requires a post-fakeroot script. You can't set ownership and permissions o the mount points in a post-image script.

Quoted 10 lines
Quoted 10 lines
support/scripts/genimage.sh +2 -1
+
 rm -rf "${GENIMAGE_TMP}"
 
 genimage \
-     --rootpath "${TARGET_DIR}"     \
+     --rootpath "${ROOTPATH_TMP}"     \
      --tmppath "${GENIMAGE_TMP}"    \
      --inputpath "${BINARIES_DIR}"  \
      --outputpath "${BINARIES_DIR}" \
Signature · 1 line
Carlos Santos <[email protected]>
#4 lore raw

PATCH 1/9 support/scripts/genimage.sh: pass an empty rootpath to genimage

Quoted 64 lines · Carlos Santos
Quoted 24 lines · Arnout Vandecappelle
Quoted 20 lines · unixmania at gmail.com

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 support/scripts/genimage.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
support/scripts/genimage.sh +0 -0
index 039b3fef1d..2796e19eb7 100755
@@ -30,10 +30,18 @@ done
 
 [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
 
Quoted 12 lines

support/scripts/genimage.sh done · line 39

Quoted 7 lines
support/scripts/genimage.sh +7 -0
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"

Instead of a temporary directory, I think it would make sense to use a fixed
directory, e.g. $(BINARIES_DIR)/rootpath. This would allow the path to be used for some other things, i.e. packages could install stuff in there that could be used to generate a filesystem. Cfr. [1].

That's exactly what I'm attempting to avoid.

Quoted 5 lines

Regards,
Arnout

[1] http://patchwork.ozlabs.org/patch/1156956/

I had to deal with that situation in the recent past. It requires a post-fakeroot script. You can't set ownership and permissions o the mount points in a post-image script.

Quoted 10 lines

support/scripts/genimage.sh done · line 47

Quoted 10 lines
support/scripts/genimage.sh +2 -1
+
 rm -rf "${GENIMAGE_TMP}"
 
 genimage \
-     --rootpath "${TARGET_DIR}"     \
+     --rootpath "${ROOTPATH_TMP}"     \
      --tmppath "${GENIMAGE_TMP}"    \
      --inputpath "${BINARIES_DIR}"  \
      --outputpath "${BINARIES_DIR}" \

--
Carlos Santos <[email protected]>

Signature · 1 line
Carlos Santos <[email protected]>
#5 lore raw

PATCH 1/9 support/scripts/genimage.sh: pass an empty rootpath to genimage

In reply to Carlos Santos
Quoted 41 lines · Carlos Santos
Quoted 24 lines · Arnout Vandecappelle
Quoted 20 lines · unixmania at gmail.com

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 support/scripts/genimage.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
support/scripts/genimage.sh +0 -0
index 039b3fef1d..2796e19eb7 100755
@@ -30,10 +30,18 @@ done
 
 [ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
 
Quoted 12 lines

support/scripts/genimage.sh done · line 39

Quoted 7 lines
support/scripts/genimage.sh +7 -0
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"

Instead of a temporary directory, I think it would make sense to use a fixed
directory, e.g. $(BINARIES_DIR)/rootpath. This would allow the path to be used for some other things, i.e. packages could install stuff in there that could be used to generate a filesystem. Cfr. [1].

That's exactly what I'm attempting to avoid.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Regards,
Arnout

[1] http://patchwork.ozlabs.org/patch/1156956/

I had to deal with that situation in the recent past. It requires a post-fakeroot script. You can't set ownership and permissions o the mount points in a post-image script.

It only needs to be in a post-fakeroot script if you actually want to set
ownership and permissions.

And even so, there's no reason why you couldn't run it as a post-fakeroot
script instead of a post-image script.

That said, it remains kludgy to use genimage.sh in this way, so the patch is
definitely OK as is. I just didn't have time to do the merge yesterday.

Regards,
Arnout

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
support/scripts/genimage.sh +2 -1
+
 rm -rf "${GENIMAGE_TMP}"
 
 genimage \
-     --rootpath "${TARGET_DIR}"     \
+     --rootpath "${ROOTPATH_TMP}"     \
      --tmppath "${GENIMAGE_TMP}"    \
      --inputpath "${BINARIES_DIR}"  \
      --outputpath "${BINARIES_DIR}" \
#6 lore raw

PATCH 2/9 configs/beagleboardx15: drop custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
 board/beagleboardx15/post-image.sh | 15 ---------------
 configs/beagleboardx15_defconfig   |  3 ++-
 2 files changed, 2 insertions(+), 16 deletions(-)
 delete mode 100755 board/beagleboardx15/post-image.sh
board/beagleboardx15/post-image.sh deleted +0 -15
deleted file mode 100755
index f52682f5d5..0000000000
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-BOARD_DIR="$(dirname $0)"
-
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-    --rootpath "${TARGET_DIR}" \
-    --tmppath "${GENIMAGE_TMP}" \
-    --inputpath "${BINARIES_DIR}" \
-    --outputpath "${BINARIES_DIR}" \
-    --config "${GENIMAGE_CFG}"
configs/beagleboardx15_defconfig +2 -1
index 393b29eef0..039a07b11e 100644
@@ -1,7 +1,8 @@
 BR2_arm=y
 BR2_cortex_a15=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_9=y
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/beagleboardx15/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/beagleboardx15/genimage.cfg"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.9"
Signature · 1 line
2.18.1
#7 lore raw

PATCH 3/9 configs/beaglebone: don't use custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

Use a post-build script to copy uEnv.txt to BINARIES_DIR, as made for beagleboneai.

Keep the post-image script because it is still used by beaglebone_qt5.

---
This should be made for beaglebone_qt5 too, but it's not possible to test because it' broken since commit a7914499b80r:

    https://gitlab.com/buildroot.org/buildroot/-/jobs/289126249
---
 board/beaglebone/post-build.sh | 4 ++++
 configs/beaglebone_defconfig   | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)
 create mode 100755 board/beaglebone/post-build.sh
board/beaglebone/post-build.sh new file +4 -0
new file mode 100755
index 0000000000..ffdd19138c
@@ -0,0 +1,4 @@
+#!/bin/sh
+BOARD_DIR="$(dirname $0)"
+
+cp $BOARD_DIR/uEnv.txt $BINARIES_DIR/uEnv.txt
configs/beaglebone_defconfig +3 -1
index d88b4253ef..ee97f80322 100644
@@ -2,7 +2,9 @@ BR2_arm=y
 BR2_cortex_a8=y
 BR2_GLOBAL_PATCH_DIR="board/beaglebone/patches"
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/beaglebone/post-image.sh"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/beaglebone/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/beaglebone/genimage.cfg"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.ti.com/processor-sdk/processor-sdk-linux.git"
Signature · 1 line
2.18.1
#8 lore raw

PATCH 4/9 configs/minnowboard_max-graphical: don't use custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
The defconfig was edited by hand to reduce the turmoild that would result from using "make savedefconfig"

---
 configs/minnowboard_max-graphical_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
configs/minnowboard_max-graphical_defconfig +2 -1
index 1d043240ad..910c324e25 100644
@@ -13,7 +13,8 @@ BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_ROOTFS_OVERLAY="board/minnowboard/fs-overlay-graphical"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/minnowboard/post-build.sh"
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/minnowboard/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/minnowboard/genimage.cfg"
 
 # Host packages
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
Signature · 1 line
2.18.1
#9 lore raw

PATCH 5/9 configs/minnowboard_max: drop custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
The defconfig was edited by hand to reduce the turmoild that would result from using "make savedefconfig"

---
 board/minnowboard/post-image.sh   | 13 -------------
 configs/minnowboard_max_defconfig |  3 ++-
 2 files changed, 2 insertions(+), 14 deletions(-)
 delete mode 100755 board/minnowboard/post-image.sh
board/minnowboard/post-image.sh deleted +0 -13
deleted file mode 100755
index 428baa5e55..0000000000
@@ -1,13 +0,0 @@
-#!/bin/sh -e
-
-GENIMAGE_CFG="board/minnowboard/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-    --rootpath "${TARGET_DIR}" \
-    --tmppath "${GENIMAGE_TMP}" \
-    --inputpath "${BINARIES_DIR}" \
-    --outputpath "${BINARIES_DIR}" \
-    --config "${GENIMAGE_CFG}"
configs/minnowboard_max_defconfig +2 -1
index 523ddffd51..fef597c350 100644
@@ -5,7 +5,8 @@ BR2_x86_silvermont=y
 # Misc
 BR2_SYSTEM_DHCP="eth0"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/minnowboard/post-build.sh"
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/minnowboard/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/minnowboard/genimage.cfg"
 
 # Linux headers same as kernel, a 4.19 series
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
Signature · 1 line
2.18.1
#10 lore raw

PATCH 6/9 configs/pandaboard: drop custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
 board/pandaboard/post-image.sh | 16 ----------------
 configs/pandaboard_defconfig   |  3 ++-
 2 files changed, 2 insertions(+), 17 deletions(-)
 delete mode 100755 board/pandaboard/post-image.sh
board/pandaboard/post-image.sh deleted +0 -16
deleted file mode 100755
index 9cca1b1789..0000000000
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage                           \
-	--rootpath "${TARGET_DIR}"     \
-	--tmppath "${GENIMAGE_TMP}"    \
-	--inputpath "${BINARIES_DIR}"  \
-	--outputpath "${BINARIES_DIR}" \
-	--config "${GENIMAGE_CFG}"
-
-exit $?
configs/pandaboard_defconfig +2 -1
index bb4dd28783..408bced9c0 100644
@@ -6,7 +6,8 @@ BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyS2"
 BR2_SYSTEM_DHCP="eth0"
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pandaboard/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pandaboard/genimage.cfg"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.62"
Signature · 1 line
2.18.1
#11 lore raw

PATCH 7/9 board/raspberrypi/post-image.sh: pass an empty rootpath to genimage

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

genimage makes a full copy of the given rootpath to ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk space. We don't rely on genimage to build the rootfs image, just to insert a pre-built one in the disk image.

---
 board/raspberrypi/post-image.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
board/raspberrypi/post-image.sh +10 -2
index 70447cd48b..bf9af5dc60 100755
@@ -49,10 +49,18 @@ __EOF__
 
 done
 
+# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
+# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
+# space. We don't rely on genimage to build the rootfs image, just to insert a
+# pre-built one in the disk image.
+
+trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
+ROOTPATH_TMP="$(mktemp -d)"
+
 rm -rf "${GENIMAGE_TMP}"
 
-genimage                           \
-	--rootpath "${TARGET_DIR}"     \
+genimage \
+	--rootpath "${ROOTPATH_TMP}"   \
 	--tmppath "${GENIMAGE_TMP}"    \
 	--inputpath "${BINARIES_DIR}"  \
 	--outputpath "${BINARIES_DIR}" \
Signature · 1 line
2.18.1
#12 lore raw

PATCH 8/9 configs/roseapplepi: drop custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
The defconfig was edited by hand to reduce the turmoild that would result from using "make savedefconfig"

---
 board/roseapplepi/post-build.sh |  4 ++++
 board/roseapplepi/post-image.sh | 18 ------------------
 configs/roseapplepi_defconfig   |  4 +++-
 3 files changed, 7 insertions(+), 19 deletions(-)
 create mode 100755 board/roseapplepi/post-build.sh
 delete mode 100755 board/roseapplepi/post-image.sh
board/roseapplepi/post-build.sh new file +4 -0
new file mode 100755
index 0000000000..ffdd19138c
@@ -0,0 +1,4 @@
+#!/bin/sh
+BOARD_DIR="$(dirname $0)"
+
+cp $BOARD_DIR/uEnv.txt $BINARIES_DIR/uEnv.txt
board/roseapplepi/post-image.sh deleted +0 -18
deleted file mode 100755
index e8f2df23f3..0000000000
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-cp "${BOARD_DIR}/uEnv.txt" "${BINARIES_DIR}"
-
-genimage                           \
-	--rootpath "${TARGET_DIR}"     \
-	--tmppath "${GENIMAGE_TMP}"    \
-	--inputpath "${BINARIES_DIR}"  \
-	--outputpath "${BINARIES_DIR}" \
-	--config "${GENIMAGE_CFG}"
-
-exit $?
configs/roseapplepi_defconfig +3 -1
index 966d444a45..d315a02e16 100644
@@ -8,7 +8,9 @@ BR2_GLOBAL_PATCH_DIR="board/roseapplepi/patches"
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_10=y
 # kernel does not build with gcc 8.x
 BR2_GCC_VERSION_7_X=y
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/roseapplepi/post-image.sh"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/roseapplepi/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/roseapplepi/genimage.cfg"
 
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
Signature · 1 line
2.18.1
#13 lore raw

PATCH 9/9 configs/wandboard: drop custom post-image script

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

Use support/scripts/genimage.sh, instead, which prevents duplicating TARGET_DIR under ${BUILD_DIR}/genimage.tmp/root.

---
The defconfig was edited by hand to reduce the turmoild that would result from using "make savedefconfig"

---
 board/wandboard/post-image.sh | 15 ---------------
 configs/wandboard_defconfig   |  3 ++-
 2 files changed, 2 insertions(+), 16 deletions(-)
 delete mode 100755 board/wandboard/post-image.sh
board/wandboard/post-image.sh deleted +0 -15
deleted file mode 100755
index 18e76aa40d..0000000000
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-
-BOARD_DIR="$(dirname $0)"
-GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
-GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
-
-rm -rf "${GENIMAGE_TMP}"
-
-genimage \
-  --rootpath "${TARGET_DIR}" \
-  --tmppath "${GENIMAGE_TMP}" \
-  --inputpath "${BINARIES_DIR}" \
-  --outputpath "${BINARIES_DIR}" \
-  --config "${GENIMAGE_CFG}"
-
configs/wandboard_defconfig +2 -1
index d2f72f734f..c3e04af53e 100644
@@ -7,7 +7,8 @@ BR2_ARM_FPU_VFPV3=y
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_18=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttymxc0"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/wandboard/post-build.sh"
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/wandboard/post-image.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/wandboard/genimage.cfg"
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 BR2_TARGET_UBOOT=y
Signature · 1 line
2.18.1
#14 lore raw

cover post-build: pass an empty rootpath to genimage

In reply to unixmania at gmail.com
Quoted 10 lines · On Sat, 12 Oct 2019 21:22:23 -0300 unixmania at gmail.com wrote:

Carlos Santos (9):
support/scripts/genimage.sh: pass an empty rootpath to genimage configs/beagleboardx15: drop custom post-image script configs/beaglebone: don't use custom post-image script configs/minnowboard_max-graphical: don't use custom post-image script configs/minnowboard_max: drop custom post-image script configs/pandaboard: drop custom post-image script board/raspberrypi/post-image.sh: pass an empty rootpath to genimage configs/roseapplepi: drop custom post-image script configs/wandboard: drop custom post-image script

All applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com