From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 3/6] common: setup: read locale info as shipped by the installer directly
Date: Mon, 9 Dec 2024 13:45:56 +0100 [thread overview]
Message-ID: <20241209124601.1272122-4-c.heiss@proxmox.com> (raw)
In-Reply-To: <20241209124601.1272122-1-c.heiss@proxmox.com>
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>
---
proxmox-installer-common/src/setup.rs | 20 +++++++++++++++-----
proxmox-low-level-installer | 3 ---
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs
index 4b4920e..c3004bc 100644
--- a/proxmox-installer-common/src/setup.rs
+++ b/proxmox-installer-common/src/setup.rs
@@ -87,13 +87,23 @@ impl IsoInfo {
#[derive(Clone, Deserialize)]
pub struct IsoLocations {
pub iso: PathBuf,
+ pub lib: PathBuf,
}
impl IsoLocations {
/// A mocked location, uses the current working directory by default
pub fn mocked() -> Self {
+ let lib = match std::env::current_dir() {
+ Ok(mut dir) => {
+ dir.push("run");
+ dir
+ }
+ Err(_) => "/dev/null".into(),
+ };
+
Self {
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(
- base_path: impl AsRef<Path>,
+ runtime_dir: impl AsRef<Path>,
) -> Result<(SetupInfo, LocaleInfo, RuntimeInfo), String> {
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");
read_json(&path).map_err(|err| format!("Failed to retrieve setup info: {err}"))?
};
let locale_info = {
- let mut path = base_path.as_ref().to_path_buf();
- path.push("locales.json");
+ let mut path = installer_info.locations.lib.clone();
+ path.push("locale-info.json");
read_json(&path).map_err(|err| format!("Failed to retrieve locale info: {err}"))?
};
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");
read_json(&path)
diff --git a/proxmox-low-level-installer b/proxmox-low-level-installer
index e5c2908..bcfe60e 100755
--- a/proxmox-low-level-installer
+++ b/proxmox-low-level-installer
@@ -100,9 +100,6 @@ if ($cmd eq 'dump-env') {
make_path($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 = {
'iso-info' => $env->{iso},
'product' => $env->{product},
--
2.47.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-12-09 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 12:45 [pve-devel] [PATCH installer 0/6] assistant: properly validate answer file settings Christoph Heiss
2024-12-09 12:45 ` [pve-devel] [PATCH installer 1/6] tui: options: simplify unit-test setup Christoph Heiss
2024-12-09 12:45 ` [pve-devel] [PATCH installer 2/6] country.pl: generate final structure as json at build time directly Christoph Heiss
2024-12-09 12:45 ` Christoph Heiss [this message]
2024-12-09 12:45 ` [pve-devel] [PATCH installer 4/6] common: setup: include path in error message if file could not be read Christoph Heiss
2024-12-09 12:45 ` [pve-devel] [PATCH installer 5/6] fix #5889: assistant: validate answer email & root password settings Christoph Heiss
2024-12-09 12:45 ` [pve-devel] [PATCH installer 6/6] assistant: validate answer first-boot hook and locale settings Christoph Heiss
2024-12-10 17:37 ` [pve-devel] applied-series: [PATCH installer 0/6] assistant: properly validate answer file settings Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241209124601.1272122-4-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.