* [Buildroot] [PATCH v2 1/3] package/cross-ldd: new package
@ 2021-12-19 7:31 Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 2/3] package/dracut: new host package Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
0 siblings, 2 replies; 5+ messages in thread
From: Thierry Bultel @ 2021-12-19 7:31 UTC (permalink / raw)
To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni
cross-ldd works just as ldd, but supports
other architectures. It is needed by dracut, for instance.
Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
Changes v1 -> v2:
- simplified the download (suggested by Arnoult)
---
package/Config.in | 1 +
package/cross-ldd/Config.in | 7 +++++++
package/cross-ldd/cross-ldd.mk | 15 +++++++++++++++
3 files changed, 23 insertions(+)
create mode 100644 package/cross-ldd/Config.in
create mode 100644 package/cross-ldd/cross-ldd.mk
diff --git a/package/Config.in b/package/Config.in
index bcb23132c9..5d0f858c03 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -162,6 +162,7 @@ menu "Development tools"
source "package/check/Config.in"
source "package/cmake/Config.in"
source "package/cppunit/Config.in"
+ source "package/cross-ldd/Config.in"
source "package/cukinia/Config.in"
source "package/cunit/Config.in"
source "package/cvs/Config.in"
diff --git a/package/cross-ldd/Config.in b/package/cross-ldd/Config.in
new file mode 100644
index 0000000000..3858fbc5fe
--- /dev/null
+++ b/package/cross-ldd/Config.in
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_HOST_CROSS_LDD
+ bool "cross-ldd"
+ help
+ ldd drop-in replacement for cross-compilation
+ toolchains.
+ This is the officially supported version mentioned
+ in the dracut documentation
diff --git a/package/cross-ldd/cross-ldd.mk b/package/cross-ldd/cross-ldd.mk
new file mode 100644
index 0000000000..6b507a651a
--- /dev/null
+++ b/package/cross-ldd/cross-ldd.mk
@@ -0,0 +1,15 @@
+################################################################################
+#
+# cross-ldd
+#
+################################################################################
+
+CROSS_LDD_VERSION = 6c9c724ebd6a29c279c6e5734e44c07f067808ec
+CROSS_LDD_SOURCE = $(CROSS_LDD_VERSION).tar.gz
+CROSS_LDD_SITE = https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f/archive
+
+define HOST_CROSS_LDD_INSTALL_CMDS
+ install -m 755 $(@D)/cross-compile-ldd $(TARGET_CROSS)ldd
+endef
+
+$(eval $(host-generic-package))
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH v2 2/3] package/dracut: new host package
2021-12-19 7:31 [Buildroot] [PATCH v2 1/3] package/cross-ldd: new package Thierry Bultel
@ 2021-12-19 7:31 ` Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
1 sibling, 0 replies; 5+ messages in thread
From: Thierry Bultel @ 2021-12-19 7:31 UTC (permalink / raw)
To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni
dracut is the tool used by desktop distributions to
build initrds. In the embedded world, it can be
very usefull, too, for instance when wanting to
create an initramfs for a system recovery mode.
Whereas it is definitively possible to achieve
this with buildroot, the process is to have a
dedicated buildroot configuration for that,
and perform a full build. Instead of doing that,
the idea is to use dracut to pick the needed
binaries/shared libraries, configuration files,
or kernel modules from the 'target' directory.
The advantage is to save build time, and also
to have a consistency between the packages versions
taken for the recovery and the production filesystem.
Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
Changes v1 -> v2 (all suggested by Arnoult)
- added a wrapper script
---
package/Config.in.host | 1 +
package/dracut/Config.in.host | 10 ++++++++++
package/dracut/dracut.mk | 28 ++++++++++++++++++++++++++++
package/dracut/dracut_wrapper.sh | 14 ++++++++++++++
4 files changed, 53 insertions(+)
create mode 100644 package/dracut/Config.in.host
create mode 100644 package/dracut/dracut.mk
create mode 100644 package/dracut/dracut_wrapper.sh
diff --git a/package/Config.in.host b/package/Config.in.host
index 6e5a5c5fc5..72531374f4 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -14,6 +14,7 @@ menu "Host utilities"
source "package/cramfs/Config.in.host"
source "package/cryptsetup/Config.in.host"
source "package/dbus-python/Config.in.host"
+ source "package/dracut/Config.in.host"
source "package/dfu-util/Config.in.host"
source "package/dos2unix/Config.in.host"
source "package/dosfstools/Config.in.host"
diff --git a/package/dracut/Config.in.host b/package/dracut/Config.in.host
new file mode 100644
index 0000000000..074d46f623
--- /dev/null
+++ b/package/dracut/Config.in.host
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_HOST_DRACUT
+ bool
+ select BR2_PACKAGE_HOST_KMOD
+ select BR2_PACKAGE_HOST_CROSS_LDD
+ help
+ dracut is used to create an initramfs image by
+ copying tools and files from an installed system
+ and combining it with the dracut framework.
+
+ https://dracut.wiki.kernel.org
diff --git a/package/dracut/dracut.mk b/package/dracut/dracut.mk
new file mode 100644
index 0000000000..ada9e1d691
--- /dev/null
+++ b/package/dracut/dracut.mk
@@ -0,0 +1,28 @@
+################################################################################
+#
+# dracut
+#
+################################################################################
+
+DRACUT_VERSION = 055
+DRACUT_SOURCE = dracut-$(DRACUT_VERSION).tar.xz
+DRACUT_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/boot/dracut
+DRACUT_LICENSE = GPL-2.0
+DRACUT_LICENSE_FILES = COPYING
+
+HOST_DRACUT_DEPENDENCIES += host-pkgconf host-kmod host-cross-ldd
+
+define HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
+ $(SED) '/unset LD_LIBRARY_PATH/d' $(HOST_DIR)/bin/dracut
+ $(SED) '/unset LD_PRELOAD/d' $(HOST_DIR)/bin/dracut
+endef
+
+define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
+ $(INSTALL) -D -m 0755 package/dracut/dracut_wrapper.sh \
+ $(HOST_DIR)/usr/bin/dracut_wrapper.sh
+endef
+
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_ENABLE_FAKEROOT
+HOST_DRACUT_POST_INSTALL_HOOKS+=HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
+
+$(eval $(host-autotools-package))
diff --git a/package/dracut/dracut_wrapper.sh b/package/dracut/dracut_wrapper.sh
new file mode 100644
index 0000000000..388086762c
--- /dev/null
+++ b/package/dracut/dracut_wrapper.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+if [ -z "$*" ]; then
+ echo "No argument supplied"
+ exit
+fi
+
+DRACUT_LDD=${TARGET_CROSS}ldd \
+DRACUT_INSTALL="${HOST_DIR}/lib/dracut/dracut-install" \
+dracutbasedir=${HOST_DIR}/usr/lib/dracut \
+dracutsysrootdir=${TARGET_DIR} \
+${HOST_DIR}/bin/dracut "$@"
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool
2021-12-19 7:31 [Buildroot] [PATCH v2 1/3] package/cross-ldd: new package Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 2/3] package/dracut: new host package Thierry Bultel
@ 2021-12-19 7:31 ` Thierry Bultel
2021-12-19 10:13 ` Thomas Petazzoni
1 sibling, 1 reply; 5+ messages in thread
From: Thierry Bultel @ 2021-12-19 7:31 UTC (permalink / raw)
To: buildroot; +Cc: Thierry Bultel, Thomas Petazzoni
Adds an option to invoke the dracut host tool, providing
a configuration file, instead of having a full cpio archive
of the whole target directory.
Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
Changes v1 -> v2 (suggested by Arnoult and Yann)
- was a new fs type, now an option of cpio
- deals with the case of a build with no kernel
- gets the kernel name in a smarter way
- checks for the name of dracut configuration file
Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
---
fs/cpio/Config.in | 28 ++++++++++++++++++++++++++++
fs/cpio/cpio.mk | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
index c1151a2881..09c5bf46d3 100644
--- a/fs/cpio/Config.in
+++ b/fs/cpio/Config.in
@@ -7,6 +7,34 @@ config BR2_TARGET_ROOTFS_CPIO
if BR2_TARGET_ROOTFS_CPIO
+choice
+ prompt "cpio type"
+config BR2_TARGET_ROOTFS_CPIO_FULL
+ bool "cpio the whole root filesystem (ie the content of 'target')"
+ help
+ Build a cpio archive containing the whole the root filesystem.
+
+config BR2_TARGET_ROOTFS_CPIO_DRACUT
+ bool "Invoke dracut to make an initramfs"
+ depends on BR2_LINUX_KERNEL
+ select BR2_PACKAGE_HOST_DRACUT
+ select BR2_PACKAGE_HOST_UBOOT_TOOLS
+ help
+ Builds an additional initramfs using dracut.
+ This can be useful to create a recovery system,
+ for instance.
+
+if BR2_TARGET_ROOTFS_CPIO_DRACUT
+config BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE
+ string "configuration file"
+endif
+
+endchoice
+
+endif # BR2_TARGET_ROOTFS_CPIO
+
+if BR2_TARGET_ROOTFS_CPIO_FULL
+
choice
prompt "Compression method"
default BR2_TARGET_ROOTFS_CPIO_NONE
diff --git a/fs/cpio/cpio.mk b/fs/cpio/cpio.mk
index 81f8c393d1..c5fbb05a57 100644
--- a/fs/cpio/cpio.mk
+++ b/fs/cpio/cpio.mk
@@ -29,6 +29,41 @@ endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
+ifeq ($(BR2_TARGET_ROOTFS_CPIO_DRACUT),y)
+
+export TARGET_CROSS
+ROOTFS_CPIO_DEPENDENCIES += host-dracut
+
+ifeq ($(BR2_LINUX_KERNEL),y)
+ROOTFS_CPIO_DEPENDENCIES += linux
+endif
+
+ifeq ($(BR_BUILDING).$(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE),y.)
+$(error No dracut config file name specified, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE setting)
+endif
+
+ifeq ($(BR2_LINUX_KERNEL),y)
+ROOTFS_CPIO_DRACUT_CMD_OPTS += --kver $(LINUX_VERSION_PROBED)
+else
+ROOTFS_CPIO_DRACUT_CMD_OPTS += --no_kernel
+endif
+
+define ROOTFS_CPIO_CMD
+ mkdir -p $(@D)/tmp
+ rm -rf $(@D)/tmp/*
+
+ $(HOST_DIR)/usr/bin/dracut_wrapper.sh \
+ $(ROOTFS_CPIO_DRACUT_CMD_OPTS) \
+ -c $(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILE) \
+ --tmpdir $(@D)/tmp \
+ -M \
+ --force \
+ --keep \
+ $@
+endef
+
+else ifeq ($(BR2_TARGET_ROOTFS_CPIO_FULL),y)
+
# --reproducible option was introduced in cpio v2.12, which may not be
# available in some old distributions, so we build host-cpio
ifeq ($(BR2_REPRODUCIBLE),y)
@@ -53,4 +88,6 @@ endef
ROOTFS_CPIO_POST_GEN_HOOKS += ROOTFS_CPIO_UBOOT_MKIMAGE
endif
+endif #BR2_TARGET_ROOTFS_CPIO_DRACUT
+
$(eval $(rootfs))
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool
2021-12-19 7:31 ` [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
@ 2021-12-19 10:13 ` Thomas Petazzoni
2021-12-23 11:20 ` Thierry Bultel
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2021-12-19 10:13 UTC (permalink / raw)
To: Thierry Bultel; +Cc: buildroot
Hello Thierry,
On Sun, 19 Dec 2021 08:31:19 +0100
Thierry Bultel <thierry.bultel@linatsea.fr> wrote:
> Adds an option to invoke the dracut host tool, providing
> a configuration file, instead of having a full cpio archive
> of the whole target directory.
>
> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
> Changes v1 -> v2 (suggested by Arnoult and Yann)
> - was a new fs type, now an option of cpio
> - deals with the case of a build with no kernel
> - gets the kernel name in a smarter way
> - checks for the name of dracut configuration file
>
> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
Thanks for working on this! What would be nice is to add a test case in
support/testing/ for this. We already have lots of tests for various
filesystem types in support/testing/tests/fs.
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool
2021-12-19 10:13 ` Thomas Petazzoni
@ 2021-12-23 11:20 ` Thierry Bultel
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Bultel @ 2021-12-23 11:20 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot
Le 19/12/2021 à 11:13, Thomas Petazzoni a écrit :
> Hello Thierry,
>
> On Sun, 19 Dec 2021 08:31:19 +0100
> Thierry Bultel <thierry.bultel@linatsea.fr> wrote:
>
>> Adds an option to invoke the dracut host tool, providing
>> a configuration file, instead of having a full cpio archive
>> of the whole target directory.
>>
>> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
>> Changes v1 -> v2 (suggested by Arnoult and Yann)
>> - was a new fs type, now an option of cpio
>> - deals with the case of a build with no kernel
>> - gets the kernel name in a smarter way
>> - checks for the name of dracut configuration file
>>
>> Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
> Thanks for working on this! What would be nice is to add a test case in
> support/testing/ for this. We already have lots of tests for various
> filesystem types in support/testing/tests/fs.
Thanks Thomas,
done and just submitted in my v3 patches.
The tests also cover the full cpio mode, and revealed some
unhandled cases in dracut mode, where the uClibc required
to pay more attention.
Cheers
Thierry
>
> Thanks!
>
> Thomas
--
Re: test
--
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-23 11:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-19 7:31 [Buildroot] [PATCH v2 1/3] package/cross-ldd: new package Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 2/3] package/dracut: new host package Thierry Bultel
2021-12-19 7:31 ` [Buildroot] [PATCH v2 3/3] fs/cpio: new option to use dracut tool Thierry Bultel
2021-12-19 10:13 ` Thomas Petazzoni
2021-12-23 11:20 ` Thierry Bultel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox