compose: Print a warning with boot-location: new

It's tempting to flip the default, but let's encourage
people to adapt to the `modules` version now.

Plus infrastructure to add deprecation warnings here
will come in handy in the future.
This commit is contained in:
Colin Walters 2020-10-22 22:10:04 +00:00 committed by OpenShift Merge Robot
parent 9cc0510ee8
commit 9a472f923b
2 changed files with 34 additions and 1 deletions

View File

@ -489,6 +489,31 @@ impl Treefile {
))
}
/// Given a treefile, print warnings about items which are deprecated.
fn print_deprecation_warnings(&self) {
let mut deprecated = false;
match self
.parsed
.boot_location
.as_ref()
.copied()
.unwrap_or_default()
{
BootLocation::Modules => {}
o => {
let s = serde_json::to_string(&o).expect("serialize");
deprecated = true;
eprintln!(
"warning: boot-location: {} is deprecated, use boot-location: modules",
s
)
}
}
if deprecated {
std::thread::sleep(std::time::Duration::from_secs(3));
}
}
fn update_checksum(&self, repo: &ostree::Repo, checksum: &mut glib::Checksum) -> Result<()> {
let it = self.parsed.ostree_layers.iter().flat_map(|x| x.iter());
let it = it.chain(
@ -631,7 +656,7 @@ fn split_whitespace_unless_quoted(element: &str) -> Result<impl Iterator<Item =
Ok(ret.into_iter())
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Copy, Clone)]
enum BootLocation {
#[serde(rename = "new")]
New,
@ -1541,6 +1566,12 @@ mod ffi {
s.to_string().to_glib_full()
}
#[no_mangle]
pub extern "C" fn ror_treefile_print_deprecation_warnings(tf: *mut Treefile) {
let tf = ref_from_raw_ptr(tf);
tf.print_deprecation_warnings()
}
#[no_mangle]
pub extern "C" fn ror_treefile_free(tf: *mut Treefile) {
if tf.is_null() {

View File

@ -726,6 +726,8 @@ rpm_ostree_compose_context_new (const char *treefile_pathstr,
error))
return FALSE;
ror_treefile_print_deprecation_warnings (self->treefile_rs);
self->treefile_rootval = json_parser_get_root (self->treefile_parser);
if (!JSON_NODE_HOLDS_OBJECT (self->treefile_rootval))
return glnx_throw (error, "Treefile root is not an object");