mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-07-15 12:24:59 +00:00
common: setup: read locale info as shipped by the installer directly
Now that we have a pre-generated `locale-info.json` available, skip generating one on-the-fly and just read that one. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
dc401eb3f0
commit
dc46056376
@ -87,13 +87,23 @@ impl IsoInfo {
|
|||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
pub struct IsoLocations {
|
pub struct IsoLocations {
|
||||||
pub iso: PathBuf,
|
pub iso: PathBuf,
|
||||||
|
pub lib: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsoLocations {
|
impl IsoLocations {
|
||||||
/// A mocked location, uses the current working directory by default
|
/// A mocked location, uses the current working directory by default
|
||||||
pub fn mocked() -> Self {
|
pub fn mocked() -> Self {
|
||||||
|
let lib = match std::env::current_dir() {
|
||||||
|
Ok(mut dir) => {
|
||||||
|
dir.push("run");
|
||||||
|
dir
|
||||||
|
}
|
||||||
|
Err(_) => "/dev/null".into(),
|
||||||
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
iso: std::env::current_dir().unwrap_or("/dev/null".into()),
|
iso: std::env::current_dir().unwrap_or("/dev/null".into()),
|
||||||
|
lib,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,24 +181,24 @@ pub fn installer_setup(in_test_mode: bool) -> Result<(SetupInfo, LocaleInfo, Run
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_installer_setup_files(
|
pub fn load_installer_setup_files(
|
||||||
base_path: impl AsRef<Path>,
|
runtime_dir: impl AsRef<Path>,
|
||||||
) -> Result<(SetupInfo, LocaleInfo, RuntimeInfo), String> {
|
) -> Result<(SetupInfo, LocaleInfo, RuntimeInfo), String> {
|
||||||
let installer_info: SetupInfo = {
|
let installer_info: SetupInfo = {
|
||||||
let mut path = base_path.as_ref().to_path_buf();
|
let mut path = runtime_dir.as_ref().to_path_buf();
|
||||||
path.push("iso-info.json");
|
path.push("iso-info.json");
|
||||||
|
|
||||||
read_json(&path).map_err(|err| format!("Failed to retrieve setup info: {err}"))?
|
read_json(&path).map_err(|err| format!("Failed to retrieve setup info: {err}"))?
|
||||||
};
|
};
|
||||||
|
|
||||||
let locale_info = {
|
let locale_info = {
|
||||||
let mut path = base_path.as_ref().to_path_buf();
|
let mut path = installer_info.locations.lib.clone();
|
||||||
path.push("locales.json");
|
path.push("locale-info.json");
|
||||||
|
|
||||||
read_json(&path).map_err(|err| format!("Failed to retrieve locale info: {err}"))?
|
read_json(&path).map_err(|err| format!("Failed to retrieve locale info: {err}"))?
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut runtime_info: RuntimeInfo = {
|
let mut runtime_info: RuntimeInfo = {
|
||||||
let mut path = base_path.as_ref().to_path_buf();
|
let mut path = runtime_dir.as_ref().to_path_buf();
|
||||||
path.push("run-env-info.json");
|
path.push("run-env-info.json");
|
||||||
|
|
||||||
read_json(&path)
|
read_json(&path)
|
||||||
|
@ -100,9 +100,6 @@ if ($cmd eq 'dump-env') {
|
|||||||
make_path($out_dir);
|
make_path($out_dir);
|
||||||
die "failed to create output directory '$out_dir'\n" if !-d $out_dir;
|
die "failed to create output directory '$out_dir'\n" if !-d $out_dir;
|
||||||
|
|
||||||
my $locales_serialized = to_json($env->{locales}, {canonical => 1, utf8 => 1}) ."\n";
|
|
||||||
file_write_all("$out_dir/locales.json", $locales_serialized);
|
|
||||||
|
|
||||||
my $iso_info = {
|
my $iso_info = {
|
||||||
'iso-info' => $env->{iso},
|
'iso-info' => $env->{iso},
|
||||||
'product' => $env->{product},
|
'product' => $env->{product},
|
||||||
|
Loading…
Reference in New Issue
Block a user