From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 0BD921FF16E
	for <inbox@lore.proxmox.com>; Mon,  9 Dec 2024 13:46:45 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 398C01CF5;
	Mon,  9 Dec 2024 13:46:41 +0100 (CET)
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Mon,  9 Dec 2024 13:45:56 +0100
Message-ID: <20241209124601.1272122-4-c.heiss@proxmox.com>
X-Mailer: git-send-email 2.47.0
In-Reply-To: <20241209124601.1272122-1-c.heiss@proxmox.com>
References: <20241209124601.1272122-1-c.heiss@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.027 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH installer 3/6] common: setup: read locale info
 as shipped by the installer directly
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.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