First, the tree must include a kernel (and optionally an initramfs). The
current standard locations for these are `/usr/lib/modules/$kver/vmlinuz` and
-`/usr/lib/modules/$kver/initramfs`. The "boot checksum" will be computed
+`/usr/lib/modules/$kver/initramfs.img`. The "boot checksum" will be computed
automatically. This follows the current Fedora kernel layout, and is
the current recommended path. However, older versions of libostree don't
support this; you may need to also put kernels in the previous (legacy)
g_clear_object (&in);
(void) close (fd); fd = -1;
- /* Look for an initramfs, but it's optional */
- if (!ot_openat_ignore_enoent (ret_layout->boot_dfd, "initramfs", &fd, error))
- return FALSE;
+ /* Look for an initramfs, but it's optional; since there wasn't any precedent
+ * for this, let's be a bit conservative and support both `initramfs.img` and
+ * `initramfs`.
+ */
+ const char *initramfs_paths[] = {"initramfs.img", "initramfs"};
+ const char *initramfs_path = NULL;
+ for (guint i = 0; i < G_N_ELEMENTS(initramfs_paths); i++)
+ {
+ initramfs_path = initramfs_paths[i];
+ if (!ot_openat_ignore_enoent (ret_layout->boot_dfd, initramfs_path, &fd, error))
+ return FALSE;
+ if (fd != -1)
+ break;
+ else
+ initramfs_path = NULL;
+ }
if (fd != -1)
{
- ret_layout->initramfs_srcpath = g_strdup ("initramfs");
- ret_layout->initramfs_namever = g_strdup_printf ("initramfs-%s", kver);
+ g_assert (initramfs_path);
+ ret_layout->initramfs_srcpath = g_strdup (initramfs_path);
+ ret_layout->initramfs_namever = g_strdup_printf ("initramfs-%s.img", kver);
in = g_unix_input_stream_new (fd, FALSE);
if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error))
return FALSE;
g_assert (initramfs_checksum != NULL);
if (strcmp (kernel_checksum, initramfs_checksum) != 0)
return glnx_throw (error, "Mismatched kernel checksum vs initrd");
- ret_layout->bootcsum = g_steal_pointer (&kernel_checksum);
}
+ ret_layout->bootcsum = g_steal_pointer (&kernel_checksum);
+
*out_layout = g_steal_pointer (&ret_layout);
return TRUE;
}
cd ${test_tmpdir}
mkdir osdata
cd osdata
- mkdir -p usr/bin ${bootdir} usr/lib/modules/3.6.0 usr/share usr/etc
+ kver=3.6.0
+ mkdir -p usr/bin ${bootdir} usr/lib/modules/${kver} usr/share usr/etc
kernel_path=${bootdir}/vmlinuz
- initramfs_path=${bootdir}/initramfs
+ initramfs_path=${bootdir}/initramfs.img
# /usr/lib/modules just uses "vmlinuz", since the version is in the module
# directory name.
if [[ $bootdir != usr/lib/modules/* ]]; then
- kernel_path=${kernel_path}-3.6.0
- initramfs_path=${initramfs_path}-3.6.0
+ kernel_path=${kernel_path}-${kver}
+ initramfs_path=${bootdir}/initramfs-${kver}.img
fi
echo "a kernel" > ${kernel_path}
echo "an initramfs" > ${initramfs_path}
branch=${3:-testos/buildmaster/x86_64-runtime}
echo "BOOT ITERATION: $boot_checksum_iteration"
cd ${test_tmpdir}/osdata
- if test -f usr/lib/modules/3.6.0/vmlinuz; then
- bootdir=usr/lib/modules/3.6.0
+ kver=3.6.0
+ if test -f usr/lib/modules/${kver}/vmlinuz; then
+ bootdir=usr/lib/modules/${kver}
else
if test -d usr/lib/ostree-boot; then
bootdir=usr/lib/ostree-boot
fi
rm ${bootdir}/*
kernel_path=${bootdir}/vmlinuz
- initramfs_path=${bootdir}/initramfs
+ initramfs_path=${bootdir}/initramfs.img
if [[ $bootdir != usr/lib/modules/* ]]; then
- kernel_path=${kernel_path}-3.6.0
- initramfs_path=${initramfs_path}-3.6.0
+ kernel_path=${kernel_path}-${kver}
+ initramfs_path=${bootdir}/initramfs-${kver}.img
fi
echo "new: a kernel ${boot_checksum_iteration}" > ${kernel_path}
echo "new: an initramfs ${boot_checksum_iteration}" > ${initramfs_path}
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* quiet'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
- assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0 'an initramfs'
+ assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0.img 'an initramfs'
# kernel/initrams should also be in the tree's /boot with the checksum
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/$test_bootdir/vmlinuz-3.6.0-${bootcsum} 'a kernel'
- assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/$test_bootdir/initramfs-3.6.0-${bootcsum} 'an initramfs'
+ assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/$test_bootdir/initramfs-3.6.0.img-${bootcsum} 'an initramfs'
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
${CMD_PREFIX} ostree admin status
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
-assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0 'an initramfs'
+assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/initramfs-3.6.0.img 'an initramfs'
# Note this bootcsum shouldn't be the modules one
assert_not_streq "${bootcsum}" "${usrlib_modules_bootcsum}"
echo "ok kernel in /usr/lib/modules and /usr/lib/ostree-boot"