Revert "Merge pull request #139 from adtya/built_on_date"
This reverts commitd751d13b0a
, reversing changes made to7c55847aaf
.
This commit is contained in:
parent
efff933460
commit
979d25ee13
|
@ -1,5 +1,6 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
@ -95,7 +96,7 @@ impl fmt::Display for Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_build_time(path: &Path) -> Result<Date> {
|
fn read_build_time(path: &Path) -> Result<Date> {
|
||||||
let build_time = time::OffsetDateTime::from(fs::metadata(path)?.created()?).date();
|
let build_time = time::OffsetDateTime::from_unix_timestamp(fs::metadata(path)?.mtime())?.date();
|
||||||
Ok(build_time)
|
Ok(build_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,9 @@ pub fn setup_generation_link_from_toplevel(
|
||||||
let mut file = fs::File::create(bootspec_path)?;
|
let mut file = fs::File::create(bootspec_path)?;
|
||||||
file.write_all(&serde_json::to_vec(&bootspec)?)?;
|
file.write_all(&serde_json::to_vec(&bootspec)?)?;
|
||||||
|
|
||||||
|
// Explicitly set modification time so that snapshot test of os-release reliably works.
|
||||||
|
// This has to happen after any modifications to the directory.
|
||||||
|
filetime::set_file_mtime(&generation_link_path, filetime::FileTime::zero())?;
|
||||||
Ok(generation_link_path)
|
Ok(generation_link_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
use expect_test::expect;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
@ -14,9 +15,6 @@ fn generate_expected_os_release() -> Result<()> {
|
||||||
let generation_link = common::setup_generation_link(tmpdir.path(), profiles.path(), 1)
|
let generation_link = common::setup_generation_link(tmpdir.path(), profiles.path(), 1)
|
||||||
.expect("Failed to setup generation link");
|
.expect("Failed to setup generation link");
|
||||||
|
|
||||||
// Expect the 'Built on' date in VERSION_ID to be from the birth time of generation_link
|
|
||||||
let expected_built_on = time::OffsetDateTime::from(fs::metadata(generation_link.as_path())?.created()?).date();
|
|
||||||
|
|
||||||
let output0 = common::lanzaboote_install(0, esp_mountpoint.path(), vec![generation_link])?;
|
let output0 = common::lanzaboote_install(0, esp_mountpoint.path(), vec![generation_link])?;
|
||||||
assert!(output0.status.success());
|
assert!(output0.status.success());
|
||||||
|
|
||||||
|
@ -29,12 +27,13 @@ fn generate_expected_os_release() -> Result<()> {
|
||||||
.context("Failed to read .osrelease PE section.")?
|
.context("Failed to read .osrelease PE section.")?
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
let expected_os_release_section = format!(r#"ID=lanza
|
let expected = expect![[r#"
|
||||||
PRETTY_NAME=LanzaOS
|
ID=lanza
|
||||||
VERSION_ID=Generation 1, Built on {}
|
PRETTY_NAME=LanzaOS
|
||||||
"#, expected_built_on.to_string());
|
VERSION_ID=Generation 1, Built on 1970-01-01
|
||||||
|
"#]];
|
||||||
|
|
||||||
assert_eq!(&expected_os_release_section, &String::from_utf8(os_release_section)?);
|
expected.assert_eq(&String::from_utf8(os_release_section)?);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue