2013-06-06 23:54:13 +02:00
|
|
|
################################################################################
|
2006-11-22 20:10:59 +01:00
|
|
|
#
|
|
|
|
# cpio to archive target filesystem
|
|
|
|
#
|
2013-06-06 23:54:13 +02:00
|
|
|
################################################################################
|
2006-11-22 20:10:59 +01:00
|
|
|
|
2011-09-06 23:16:08 +02:00
|
|
|
ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
|
|
|
|
|
|
|
|
define ROOTFS_CPIO_ADD_INIT
|
2014-10-25 20:29:31 +02:00
|
|
|
if [ ! -e $(TARGET_DIR)/init ]; then \
|
|
|
|
ln -sf sbin/init $(TARGET_DIR)/init; \
|
|
|
|
fi
|
2011-09-06 23:16:08 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
else
|
|
|
|
# devtmpfs does not get automounted when initramfs is used.
|
|
|
|
# Add a pre-init script to mount it before running init
|
fs/cpio: don't extend packages' permissions table
Currently, when we build a cpio filesystem without static devices, we
shoehorn the /dev/console node as if it were specified by a package.
This means that this device is added for all filesystems as well, not
just the cpio. But if we disable cpio, that device is not created for
other filesystems.
This is not very clean, and may break expectations.
Instead, use an explicit mknod as part of the _CMD, as we know it's
going to run under fakeroot.
This is still visible to all filesystems built after cpio, and not to
those built before it, though.
[Peter: ensure /dev exists, simplify comment]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 11:05:48 +02:00
|
|
|
# We must have /dev/console very early, even before /init runs,
|
|
|
|
# for stdin/stdout/stderr
|
2011-09-06 23:16:08 +02:00
|
|
|
define ROOTFS_CPIO_ADD_INIT
|
2014-10-25 20:29:31 +02:00
|
|
|
if [ ! -e $(TARGET_DIR)/init ]; then \
|
|
|
|
$(INSTALL) -m 0755 fs/cpio/init $(TARGET_DIR)/init; \
|
|
|
|
fi
|
fs/cpio: don't extend packages' permissions table
Currently, when we build a cpio filesystem without static devices, we
shoehorn the /dev/console node as if it were specified by a package.
This means that this device is added for all filesystems as well, not
just the cpio. But if we disable cpio, that device is not created for
other filesystems.
This is not very clean, and may break expectations.
Instead, use an explicit mknod as part of the _CMD, as we know it's
going to run under fakeroot.
This is still visible to all filesystems built after cpio, and not to
those built before it, though.
[Peter: ensure /dev exists, simplify comment]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-03-31 11:05:48 +02:00
|
|
|
mkdir -p $(TARGET_DIR)/dev
|
|
|
|
mknod -m 0622 $(TARGET_DIR)/dev/console c 5 1
|
2010-03-10 00:13:24 +01:00
|
|
|
endef
|
2006-11-22 20:10:59 +01:00
|
|
|
|
2011-09-06 23:16:08 +02:00
|
|
|
endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
|
|
|
|
|
|
|
|
ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
|
2007-08-12 00:01:13 +02:00
|
|
|
|
2019-07-17 08:56:35 +02:00
|
|
|
# --reproducible option was introduced in cpio v2.12, which may not be
|
2019-07-16 19:35:18 +02:00
|
|
|
# available in some old distributions, so we build host-cpio
|
|
|
|
ifeq ($(BR2_REPRODUCIBLE),y)
|
|
|
|
ROOTFS_CPIO_DEPENDENCIES += host-cpio
|
|
|
|
ROOTFS_CPIO_OPTS += --reproducible
|
|
|
|
endif
|
|
|
|
|
2022-08-15 13:17:09 +02:00
|
|
|
ifeq ($(BR2_TARGET_ROOTFS_CPIO_FULL),y)
|
|
|
|
|
2010-03-10 00:13:24 +01:00
|
|
|
define ROOTFS_CPIO_CMD
|
2020-06-29 14:37:01 +02:00
|
|
|
cd $(TARGET_DIR) && \
|
|
|
|
find . \
|
|
|
|
| LC_ALL=C sort \
|
|
|
|
| cpio $(ROOTFS_CPIO_OPTS) --quiet -o -H newc \
|
|
|
|
> $@
|
2010-03-10 00:13:24 +01:00
|
|
|
endef
|
2007-08-12 00:01:13 +02:00
|
|
|
|
2022-08-15 13:17:09 +02:00
|
|
|
else ifeq ($(BR2_TARGET_ROOTFS_CPIO_DRACUT),y)
|
|
|
|
|
|
|
|
ROOTFS_CPIO_DEPENDENCIES += host-dracut
|
|
|
|
|
2022-08-19 19:51:00 +02:00
|
|
|
ROOTFS_CPIO_DRACUT_CONF_FILES = $(call qstrip,$(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES))
|
|
|
|
ifeq ($(BR_BUILDING),y)
|
|
|
|
ifeq ($(ROOTFS_CPIO_DRACUT_CONF_FILES),)
|
|
|
|
$(error No dracut config file name specified, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES setting)
|
|
|
|
endif
|
|
|
|
ifneq ($(words $(ROOTFS_CPIO_DRACUT_CONF_FILES)),$(words $(sort $(notdir $(ROOTFS_CPIO_DRACUT_CONF_FILES)))))
|
|
|
|
$(error No two dracut config files can have the same basename, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES setting)
|
|
|
|
endif
|
2022-08-15 13:17:09 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BR2_LINUX_KERNEL),y)
|
|
|
|
ROOTFS_CPIO_DEPENDENCIES += linux
|
|
|
|
ROOTFS_CPIO_OPTS += --kver $(LINUX_VERSION_PROBED)
|
|
|
|
else
|
|
|
|
ROOTFS_CPIO_OPTS += --no-kernel
|
|
|
|
endif
|
|
|
|
|
|
|
|
define ROOTFS_CPIO_CMD
|
2022-08-19 19:51:00 +02:00
|
|
|
mkdir -p $(ROOTFS_CPIO_DIR)/tmp $(ROOTFS_CPIO_DIR)/confdir
|
|
|
|
$(foreach cfg,$(ROOTFS_CPIO_DRACUT_CONF_FILES), \
|
|
|
|
cp $(cfg) $(ROOTFS_CPIO_DIR)/confdir/$(notdir $(cfg))
|
|
|
|
)
|
2022-08-15 13:17:09 +02:00
|
|
|
$(HOST_DIR)/bin/dracut \
|
|
|
|
$(ROOTFS_CPIO_OPTS) \
|
2022-08-19 19:51:00 +02:00
|
|
|
-c /dev/null \
|
|
|
|
--confdir $(ROOTFS_CPIO_DIR)/confdir \
|
2022-08-15 13:17:09 +02:00
|
|
|
--sysroot $(TARGET_DIR) \
|
|
|
|
--tmpdir $(ROOTFS_CPIO_DIR)/tmp \
|
|
|
|
-M \
|
|
|
|
--force \
|
|
|
|
--no-compress \
|
|
|
|
$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
endif #BR2_TARGET_ROOTFS_CPIO_DRACUT
|
|
|
|
|
2013-11-07 00:12:34 +01:00
|
|
|
ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y)
|
2017-11-12 18:45:44 +01:00
|
|
|
ROOTFS_CPIO_DEPENDENCIES += host-uboot-tools
|
|
|
|
define ROOTFS_CPIO_UBOOT_MKIMAGE
|
|
|
|
$(MKIMAGE) -A $(MKIMAGE_ARCH) -T ramdisk \
|
|
|
|
-C none -d $@$(ROOTFS_CPIO_COMPRESS_EXT) $@.uboot
|
|
|
|
endef
|
|
|
|
ROOTFS_CPIO_POST_GEN_HOOKS += ROOTFS_CPIO_UBOOT_MKIMAGE
|
2013-11-07 00:12:34 +01:00
|
|
|
endif
|
|
|
|
|
2017-12-28 11:40:32 +01:00
|
|
|
$(eval $(rootfs))
|