Skip to content

Commit 3c64d05

Browse files
authored
Merge pull request #3402 from cgwalters/treefile-container-cmd
treefile: Add `container-cmd`
2 parents af4528d + a919ec9 commit 3c64d05

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

docs/treefile.md

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ It supports the following parameters:
8787
files present in packages and prior layers will be silently overriden.
8888
This is useful for development builds to replace parts of the base tree.
8989

90+
* `container-cmd`: array of strings, optional: This maps to the `CMD` Dockerfile
91+
instruction, and is currently only meaningful when encapsulating/exporting
92+
an ostree commit as a Docker/OCI container.
93+
9094
* `bootstrap_packages`: Array of strings, optional: Deprecated; you should
9195
now just include this set in the main `packages` array.
9296

rust/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ pub mod ffi {
415415
fn get_lockfile_repos(&self) -> Vec<String>;
416416
fn get_ref(&self) -> &str;
417417
fn get_cliwrap(&self) -> bool;
418+
fn get_container_cmd(&self) -> Vec<String>;
418419
fn get_readonly_executables(&self) -> bool;
419420
fn get_documentation(&self) -> bool;
420421
fn get_recommends(&self) -> bool;

rust/src/treefile.rs

+8
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ fn treefile_merge(dest: &mut TreeComposeConfig, src: &mut TreeComposeConfig) {
380380
container,
381381
recommends,
382382
readonly_executables,
383+
container_cmd,
383384
documentation,
384385
boot_location,
385386
tmp_is_dir,
@@ -757,6 +758,10 @@ impl Treefile {
757758
self.parsed.base.releasever.as_deref().unwrap_or_default()
758759
}
759760

761+
pub(crate) fn get_container_cmd(&self) -> Vec<String> {
762+
self.parsed.base.container_cmd.clone().unwrap_or_default()
763+
}
764+
760765
/// Returns true if the database backend must be regenerated using the target system.
761766
pub(crate) fn rpmdb_backend_is_target(&self) -> bool {
762767
self.parsed
@@ -1382,6 +1387,9 @@ pub(crate) struct BaseComposeConfigFields {
13821387
#[serde(rename = "rpmdb-normalize")]
13831388
pub(crate) rpmdb_normalize: Option<bool>,
13841389

1390+
// Container related bits
1391+
pub(crate) container_cmd: Option<Vec<String>>,
1392+
13851393
#[serde(flatten)]
13861394
pub(crate) legacy_fields: LegacyTreeComposeConfigFields,
13871395

src/app/rpmostree-compose-builtin-tree.cxx

+12
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,18 @@ rpm_ostree_compose_context_new (const char *treefile_pathstr,
761761
return FALSE;
762762
}
763763

764+
auto cmd = (*self->treefile_rs)->get_container_cmd();
765+
if (cmd.size() > 0)
766+
{
767+
g_auto(GVariantBuilder) builder;
768+
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
769+
for (auto s: cmd)
770+
{
771+
g_variant_builder_add (&builder, "s", s.c_str());
772+
}
773+
g_hash_table_insert (self->metadata, g_strdup ("ostree.container-cmd"), g_variant_ref_sink (g_variant_builder_end (&builder)));
774+
}
775+
764776
auto layers = (*self->treefile_rs)->get_all_ostree_layers();
765777
if (layers.size() > 0 && !opt_unified_core)
766778
return glnx_throw (error, "ostree-layers requires unified-core mode");

tests/compose/test-misc-tweaks.sh

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ EOF
3535
cat > config/other.yaml <<'EOF'
3636
recommends: true
3737
readonly-executables: true
38+
container-cmd:
39+
- /usr/bin/bash
3840
EOF
3941
treefile_append "include" '["documentation.yaml", "other.yaml"]'
4042
for x in 'recommends' 'documentation' 'readonly-executables'; do

0 commit comments

Comments
 (0)