Skip to content

Commit cc0e4ba

Browse files
pothoschewi
andcommitted
test: initrd in /usr
Pulls in flatcar/bootengine#110 Co-authored-by: James Le Cuirot <[email protected]> Signed-off-by: Kai Lueke <[email protected]>
1 parent 88cb9c9 commit cc0e4ba

File tree

5 files changed

+126
-2
lines changed

5 files changed

+126
-2
lines changed

sdk_container/src/third_party/coreos-overlay/sys-apps/seismograph/seismograph-9999.ebuild

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ EGIT_REPO_URI="https://github.com/flatcar/seismograph.git"
77
if [[ "${PV}" == 9999 ]]; then
88
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
99
else
10-
EGIT_COMMIT="e32ac4d13ca44333dc77e5872dbf23f964b6f1e2" # main
10+
#EGIT_COMMIT="e32ac4d13ca44333dc77e5872dbf23f964b6f1e2" # main
11+
EGIT_BRANCH="kai/fix-lookup"
1112
KEYWORDS="amd64 arm arm64 x86"
1213
fi
1314

sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ EGIT_REPO_URI="https://github.com/flatcar/bootengine.git"
77
if [[ "${PV}" == 9999 ]]; then
88
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
99
else
10-
EGIT_COMMIT="31ba2964ce5e77ae5553eb0a3624afcc7078bb09" # flatcar-master
10+
#EGIT_COMMIT="31ba2964ce5e77ae5553eb0a3624afcc7078bb09" # flatcar-master
11+
EGIT_BRANCH="kai/initrd-in-usr"
1112
KEYWORDS="amd64 arm arm64 x86"
1213
fi
1314

@@ -23,6 +24,7 @@ src_install() {
2324
insinto /usr/lib/dracut/modules.d/
2425
doins -r dracut/.
2526
dosbin update-bootengine
27+
dosbin minimal-init
2628

2729
# must be executable since dracut's install scripts just
2830
# re-use existing filesystem permissions during initrd creation.

sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-6.12.47.ebuild

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DEPEND="
2626
coreos-base/coreos-init:=
2727
sys-apps/azure-vm-utils[dracut]
2828
sys-apps/baselayout
29+
sys-apps/busybox
2930
sys-apps/coreutils
3031
sys-apps/findutils
3132
sys-apps/grep
@@ -72,6 +73,16 @@ src_prepare() {
7273
use amd64 && config_update "CONFIG_EXTRA_FIRMWARE_DIR=\"${fw_dir}\""
7374
}
7475

76+
copy_in() {
77+
# Simple setup, assume we only have /lib64 to care about
78+
cp "${ESYSROOT}"/usr/"$1" ./"$1"
79+
for LIBFILE in $(patchelf --print-needed ./"$1"); do
80+
if [ ! -e ./lib64/"${LIBFILE}" ]; then
81+
copy_in /lib64/"${LIBFILE}"
82+
fi
83+
done
84+
}
85+
7586
src_compile() {
7687
local BE_ARGS=()
7788

@@ -89,6 +100,76 @@ src_compile() {
89100

90101
tc-export PKG_CONFIG
91102
"${ESYSROOT}"/usr/bin/update-bootengine -k "${KV_FULL}" -o "${S}"/build/bootengine.cpio "${BE_ARGS[@]}" || die
103+
# Copy full initrd over to /usr as filesystem image
104+
mkdir "${S}"/build/bootengine || die
105+
pushd "${S}"/build/bootengine || die
106+
sudo lsinitrd --unpack "${S}"/build/bootengine.cpio || die
107+
sudo mksquashfs . "${S}"/build/bootengine.img -noappend -xattrs-exclude ^btrfs. || die
108+
popd || die
109+
# Create minimal initrd
110+
if use amd64; then
111+
microcode=$(cpio -t < "${S}"/build/bootengine.cpio 2>&1 > /dev/null | cut -d " " -f 1)
112+
# Only keep early cpio for microcode
113+
truncate -s $((microcode*512)) "${S}"/build/bootengine.cpio || die
114+
# Debug: List contents after truncation
115+
cpio -t < "${S}"/build/bootengine.cpio
116+
else
117+
# No early cpio, drop full initrd
118+
> "${S}"/build/bootengine.cpio
119+
fi
120+
mkdir "${S}"/build/minimal || die
121+
pushd "${S}"/build/minimal || die
122+
mkdir -p {etc,bin,sbin,dev,proc,sys,dev,lib,lib64,usr/bin,usr/sbin,usr/lib,usr/lib64,realinit,sysusr/usr}
123+
mkdir -p lib/modules/"${KV_FULL}"/
124+
# Instead from ESYSROOT we can also copy kernel modules from the dracut pre-selection
125+
cp "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/modules.* lib/modules/"${KV_FULL}"/
126+
mkdir -p lib/modprobe.d/
127+
cp "${S}"/build/bootengine/lib/modprobe.d/* lib/modprobe.d/
128+
MODULES=("fs/overlayfs" "fs/squashfs" "drivers/md/dm-verity.ko.xz" "drivers/md/dm-mod.ko.xz" "drivers/block/loop.ko.xz" "fs/btrfs" "drivers/nvme" "drivers/scsi" "drivers/ata" "drivers/block" "drivers/pci" "drivers/char/virtio_console.ko.xz" "drivers/hv" "drivers/input/serio" "drivers/mmc" "drivers/usb" "drivers/hid" "security/keys")
129+
for MODULE in "${MODULES[@]}"; do
130+
if [ -f "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/kernel/"${MODULE}" ]; then
131+
MODULE_DIR=$(dirname "${MODULE}")
132+
mkdir -p lib/modules/"${KV_FULL}"/kernel/"${MODULE_DIR}"
133+
cp "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/kernel/"${MODULE}" lib/modules/"${KV_FULL}"/kernel/"${MODULE}"
134+
elif [ -d "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/kernel/"${MODULE}" ]; then
135+
mkdir -p lib/modules/"${KV_FULL}"/kernel/"${MODULE}"
136+
cp -r "${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/kernel/"${MODULE}"/* lib/modules/"${KV_FULL}"/kernel/"${MODULE}"/
137+
else
138+
die "wrong module type/not found: ${S}"/build/bootengine/usr/lib/modules/"${KV_FULL}"/kernel/"${MODULE}"
139+
fi
140+
done
141+
# Copy module dependencies
142+
for MODULE in $(find ./lib/modules/"${KV_FULL}"/ -type f); do
143+
MODULE=$(basename "${MODULE}" | sed "s/\.ko\.xz$//")
144+
for DEP in $(modprobe -S "${KV_FULL}" -d "${S}"/build/bootengine -D "${MODULE}" | grep "^insmod " | sed "s/^insmod //"); do
145+
DEP=$(echo "${DEP}" | sed "s,${S}/build/bootengine,/,")
146+
DEP_DIR=$(dirname "${DEP}")
147+
mkdir -p ./"${DEP_DIR}"
148+
cp "${S}"/build/bootengine/"${DEP}" ./"${DEP}"
149+
done
150+
done
151+
echo '$MODALIAS=.* 0:0 660 @/sbin/modprobe "$MODALIAS"' > ./etc/mdev.conf
152+
copy_in /bin/veritysetup
153+
copy_in /bin/dmsetup
154+
copy_in /bin/busybox
155+
# We can't use busybox's modprobe because it doesn't support the globs in module.alias, breaking module loading
156+
copy_in /sbin/kmod
157+
ln -s /sbin/kmod ./sbin/modprobe
158+
if use arm64; then
159+
ln -s ../lib64/ld-linux-aarch64.so.1 ./lib/ld-linux-aarch64.so.1
160+
fi
161+
cp -a "${ESYSROOT}"/usr/bin/minimal-init ./init
162+
# Make it easier to debug by not relying too much on the first commands
163+
ln -s /bin/busybox ./bin/sh
164+
mknod ./dev/console c 5 1
165+
mknod ./dev/null c 1 3
166+
mknod ./dev/tty c 5 0
167+
mknod ./dev/urandom c 1 9
168+
mknod ./dev/random c 1 8
169+
mknod ./dev/zero c 1 5
170+
# No compression because CONFIG_INITRAMFS_COMPRESSION_XZ should take care of it
171+
find . -print0 | cpio --null --create --verbose --format=newc >> "${S}"/build/bootengine.cpio
172+
popd || die
92173
kmake "$(kernel_target)"
93174

94175
# sanity check :)
@@ -111,4 +192,7 @@ src_install() {
111192
# For easy access to vdso debug symbols in gdb:
112193
# set debug-file-directory /usr/lib/debug/usr/lib/modules/${KV_FULL}/vdso/
113194
kmake INSTALL_MOD_PATH="${ED}/usr/lib/debug/usr" vdso_install
195+
196+
insinto "/usr/lib/flatcar"
197+
doins build/bootengine.img
114198
}

sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-6.12.47.ebuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ UNIPATCH_LIST="
4343
${PATCH_DIR}/z0006-mtd-disable-slram-and-phram-when-locked-down.patch \
4444
${PATCH_DIR}/z0007-arm64-add-kernel-config-option-to-lock-down-when.patch \
4545
${PATCH_DIR}/z0008-tools-hv-fix-cross-compilation-for-ARM64.patch \
46+
${PATCH_DIR}/z0009-block-add-partition-uuid-into-uevent.patch \
4647
"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 758737d86f8a2d74c0fa9f8b2523fa7fd1e0d0aa Mon Sep 17 00:00:00 2001
2+
From: Konstantin Khlebnikov <[email protected]>
3+
Date: Fri, 4 Oct 2024 17:13:43 -0700
4+
Subject: [PATCH] block: add partition uuid into uevent as "PARTUUID"
5+
6+
Both most common formats have uuid in addition to partition name:
7+
GPT: standard uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
8+
DOS: 4 byte disk signature and 1 byte partition xxxxxxxx-xx
9+
10+
Tools from util-linux use the same notation for them.
11+
12+
Signed-off-by: Konstantin Khlebnikov <[email protected]>
13+
Reviewed-by: Kyle Fortin <[email protected]>
14+
[dianders: rebased to modern kernels]
15+
Signed-off-by: Douglas Anderson <[email protected]>
16+
Signed-off-by: Douglas Anderson <[email protected]>
17+
Reviewed-by: Christoph Hellwig <[email protected]>
18+
Link: https://lore.kernel.org/r/20241004171340.v2.1.I938c91d10e454e841fdf5d64499a8ae8514dc004@changeid
19+
Signed-off-by: Jens Axboe <[email protected]>
20+
---
21+
block/partitions/core.c | 2 ++
22+
1 file changed, 2 insertions(+)
23+
24+
diff --git a/block/partitions/core.c b/block/partitions/core.c
25+
index cdad05f9764768..815ed33caa1b86 100644
26+
--- a/block/partitions/core.c
27+
+++ b/block/partitions/core.c
28+
@@ -256,6 +256,8 @@ static int part_uevent(const struct device *dev, struct kobj_uevent_env *env)
29+
add_uevent_var(env, "PARTN=%u", bdev_partno(part));
30+
if (part->bd_meta_info && part->bd_meta_info->volname[0])
31+
add_uevent_var(env, "PARTNAME=%s", part->bd_meta_info->volname);
32+
+ if (part->bd_meta_info && part->bd_meta_info->uuid[0])
33+
+ add_uevent_var(env, "PARTUUID=%s", part->bd_meta_info->uuid);
34+
return 0;
35+
}
36+

0 commit comments

Comments
 (0)