Skip to content

Commit

Permalink
compose: Add boot-location: modules
Browse files Browse the repository at this point in the history
And this (for now at least) completes the epic journey of the
"where's the kernel"?  With this it's found solely in
`/usr/lib/modules/$kver`.

There are a few reasons to do this; most prominent is that
it avoids duplicating the content as the locations may have
different SELinux labels.

Closes: #1773
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Mar 8, 2019
1 parent f37426f commit adff1e9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
12 changes: 9 additions & 3 deletions docs/manual/treefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ It supports the following parameters:
* `selinux`: boolean, optional: Defaults to `true`. If `false`, then
no SELinux labeling will be performed on the server side.

* `boot-location` (or `boot_location`): string, optional: If specified, this value
must be "new". Historically rpm-ostree supported multiple kernel locations;
this is no longer the case.
* `boot-location` (or `boot_location`): string, optional:
There are 2 possible values:
* "new": A misnomer, this value is no longer "new". Kernel data
goes in `/usr/lib/ostree-boot` in addition to `/usr/lib/modules`.
This is the default; use it if you have a need to care about
upgrading from very old versions of libostree.
* "modules": Kernel data goes just in `/usr/lib/modules`. Use
this for new systems, and systems that don't need to be upgraded
from very old libostree versions.

* `etc-group-members`: Array of strings, optional: Unix groups in this
list will be stored in `/etc/group` instead of `/usr/lib/group`. Use
Expand Down
2 changes: 2 additions & 0 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ fn whitespace_split_packages(pkgs: &[String]) -> Vec<String> {
enum BootLocation {
#[serde(rename = "new")]
New,
#[serde(rename = "modules")]
Modules,
}

impl Default for BootLocation {
Expand Down
16 changes: 12 additions & 4 deletions src/libpriv/rpmostree-postprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
#include "rpmostree-rust.h"

typedef enum {
RPMOSTREE_POSTPROCESS_BOOT_LOCATION_NEW
RPMOSTREE_POSTPROCESS_BOOT_LOCATION_NEW,
RPMOSTREE_POSTPROCESS_BOOT_LOCATION_MODULES,
} RpmOstreePostprocessBootLocation;

/* The "unified_core_mode" flag controls whether or not we use rofiles-fuse,
Expand Down Expand Up @@ -363,7 +364,11 @@ process_kernel_and_initramfs (int rootfs_dfd,
return FALSE;
if (boot_location_str != NULL)
{
if (!g_str_equal (boot_location_str, "new"))
if (g_str_equal (boot_location_str, "new"))
boot_location = RPMOSTREE_POSTPROCESS_BOOT_LOCATION_NEW;
else if (g_str_equal (boot_location_str, "modules"))
boot_location = RPMOSTREE_POSTPROCESS_BOOT_LOCATION_MODULES;
else
return glnx_throw (error, "Invalid boot location '%s'", boot_location_str);
}

Expand Down Expand Up @@ -439,9 +444,12 @@ process_kernel_and_initramfs (int rootfs_dfd,
/* We always tell rpmostree_finalize_kernel() to skip /boot, since we'll do a
* full hardlink pass if needed after that for the kernel + bootloader data.
*/
RpmOstreeFinalizeKernelDestination fin_dest =
(boot_location == RPMOSTREE_POSTPROCESS_BOOT_LOCATION_MODULES) ?
RPMOSTREE_FINALIZE_KERNEL_USRLIB_MODULES :
RPMOSTREE_FINALIZE_KERNEL_USRLIB_OSTREEBOOT;
if (!rpmostree_finalize_kernel (rootfs_dfd, bootdir, kver, kernel_path,
&initramfs_tmpf,
RPMOSTREE_FINALIZE_KERNEL_USRLIB_OSTREEBOOT,
&initramfs_tmpf, fin_dest,
cancellable, error))
return FALSE;

Expand Down
26 changes: 26 additions & 0 deletions tests/compose-tests/test-boot-location-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -xeuo pipefail

dn=$(cd $(dirname $0) && pwd)
. ${dn}/libcomposetest.sh

prepare_compose_test "bootlocation-modules"
pysetjsonmember "boot_location" '"modules"'
runcompose
echo "ok compose"

# Nothing in /boot (but it should exist)
ostree --repo=${repobuild} ls -R ${treeref} /boot > bootls.txt
cat >bootls-expected.txt <<EOF
d00755 0 0 0 /boot
EOF
diff -u bootls{-expected,}.txt
# Verify /usr/lib/ostree-boot
ostree --repo=${repobuild} ls -R ${treeref} /usr/lib/ostree-boot > bootls.txt
assert_not_file_has_content bootls.txt vmlinuz-
assert_not_file_has_content bootls.txt initramfs-
# And use the kver to find the kernel in /usr/lib/modules
ostree --repo=${repobuild} ls -R ${treeref} /usr/lib/modules > modules-lsr.txt
assert_file_has_content modules-lsr.txt '/vmlinuz$'
assert_file_has_content modules-lsr.txt '/initramfs.img$'
echo "ok boot location modules"

0 comments on commit adff1e9

Please sign in to comment.