Skip to content

Commit

Permalink
treefile: Add an edition
Browse files Browse the repository at this point in the history
This will allow us to clean up some defaults and change some semantics.
In particular, I'd like to add an opinionated mechanism to copy files
from git into the build.

For now, `edition: "2024"` just flips on `tmp-is-dir: true` and fixes
`boot-location`.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Oct 4, 2024
1 parent daed6dc commit 4a12c44
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/treefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Jenkins to operate on them as it changes.

It supports the following parameters:

* `edition`: string, optional: If not set, the default value is
treated as `2014`. The only other supported value is `2024`, which
changes some defaults.

* `ref`: string, mandatory: Holds a string which will be the name of
the branch for the content. This field supports variable substitution.

Expand Down Expand Up @@ -47,7 +51,8 @@ It supports the following parameters:
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.
from very old libostree versions. This is the default for editions 2024
and above.

* `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 Expand Up @@ -441,8 +446,8 @@ It supports the following parameters:
supported. For more details, see the OSTree manual:
https://ostreedev.github.io/ostree/deployment/

* `tmp-is-dir`: boolean, optional: Defaults to `false`. By default,
rpm-ostree creates symlink `/tmp` → `sysroot/tmp`. When set to `true`,
* `tmp-is-dir`: boolean, optional: Defaults to `false` in editions &lt; 2024, otherwise `true`.
By default, rpm-ostree creates symlink `/tmp` → `sysroot/tmp`. When set to `true`,
`/tmp` will be a regular directory, which allows the `systemd` unit
`tmp.mount` to mount it as `tmpfs`. It's more flexible to leave it
as a directory, and further, we don't want to encourage `/sysroot`
Expand Down
30 changes: 30 additions & 0 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ fn treefile_parse_stream<R: io::Read>(
treefile.check_groups = Some(CheckGroups::None);
}

// Change these defaults for 2024 edition
if treefile.edition.unwrap_or_default() >= Edition::Twenty24 {
treefile.boot_location = Some(BootLocation::Modules);
treefile.tmp_is_dir = Some(true);
}

// Special handling for packages, since we allow whitespace within items.
// We also canonicalize bootstrap_packages to packages here so it's
// easier to append the basearch packages after.
Expand Down Expand Up @@ -389,6 +395,7 @@ fn treefile_merge(dest: &mut TreeComposeConfig, src: &mut TreeComposeConfig) {
}

merge_basics!(
edition,
treeref,
basearch,
rojig,
Expand Down Expand Up @@ -2391,10 +2398,22 @@ impl std::ops::DerefMut for TreeComposeConfig {
}
}

#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq, Copy, Clone, PartialOrd, Ord)]
#[serde(rename_all = "kebab-case")]
pub(crate) enum Edition {
#[serde(rename = "2014")]
#[default]
Twenty14,
#[serde(rename = "2024")]
Twenty24,
}

/// These fields are only useful when composing a new ostree commit.
#[derive(Clone, Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct BaseComposeConfigFields {
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) edition: Option<Edition>,
// Compose controls
#[serde(rename = "ref")]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -3792,6 +3811,17 @@ conditional-include:
assert!(tf.parsed.base.tmp_is_dir.unwrap());
}

#[test]
fn test_edition() {
let workdir = tempfile::tempdir().unwrap();
let workdir: &Utf8Path = workdir.path().try_into().unwrap();
let tf = indoc! { r#"
edition: "2024"
"#};
let tf = new_test_treefile(workdir, tf, None).unwrap();
assert!(tf.parsed.base.tmp_is_dir.unwrap());
}

#[test]
fn test_check_passwd() {
{
Expand Down

0 comments on commit 4a12c44

Please sign in to comment.