From c91ce7a0338418888837e54c81f5f005720ab50e Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Thu, 7 Nov 2024 00:10:27 +0530 Subject: [PATCH 1/6] feat: add outdated ISO version check Signed-off-by: SoulHarsh007 --- Cargo.toml | 4 ++-- i18n/en/cachyos_hello.ftl | 1 + src/main.rs | 49 +++++++++++++++++++++++++++++++++------ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1479cd4..5c97109 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,9 @@ gtk = { version = "0.18", default-features = false } gio = { version = "0.20", default-features = false } gdk-pixbuf = "0.20" glib = { default-features = false, version = "0.20" } -serde = { version = "1", default-features = false } +serde = { version = "1", features = ["derive"] } serde_json = "1" -reqwest = { version = "0.12", features = ["blocking"] } +reqwest = { version = "0.12", features = ["blocking", "json"] } unic-langid = "0.9" phf = { version = "0.11", features = ["macros"], default-features = false } chwd = { git = "https://github.com/CachyOS/chwd", rev = "d7e7e65c5c2c0ffe0434adad9a0016617d1f8bb7", version = "1.10.0" } diff --git a/i18n/en/cachyos_hello.ftl b/i18n/en/cachyos_hello.ftl index ed6c1e6..10f9bd7 100644 --- a/i18n/en/cachyos_hello.ftl +++ b/i18n/en/cachyos_hello.ftl @@ -79,6 +79,7 @@ calamares-install-type = Calamares install type # Main Page (body) offline-error = Unable to start online installation! No internet connection unsupported-hw-warning = You are attempting to install on hardware not supported by the current ISO, your installation will not be eligible for support +outdated-version-warning = You are using an older version of CachyOS ISO, please consider using latest version for installations tweaksbrowser-label = Apps/Tweaks appbrowser-label = Install Apps launch-start-label = Launch at start diff --git a/src/main.rs b/src/main.rs index dbc1e23..a461832 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,10 +41,44 @@ static G_SAVE_JSON: Lazy> = Lazy::new(|| { }); static mut G_HELLO_WINDOW: Option> = None; -fn version_compat_check(message: String) { - let version_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()); +#[derive(serde::Deserialize)] +struct Versions { + #[serde(rename = "desktopISOVersion")] + desktop_iso_version: String, + #[serde(rename = "handheldISOVersion")] + handheld_iso_version: String, +} + +fn outdated_version_check(message: String) { + let edition_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()); + let version_tag = fs::read_to_string("/etc/version-tag").unwrap_or_default(); + + let versions = reqwest::blocking::get("https://cachyos.org/versions.json") + .unwrap() + .json::() + .unwrap(); + + let latest_version = if edition_tag == "desktop" { + versions.desktop_iso_version + } else { + versions.handheld_iso_version + }; + + if version_tag != latest_version { + let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; + show_simple_dialog( + window_ref, + gtk::MessageType::Warning, + &fl!("outdated-version-warning"), + message.clone(), + ); + } +} + +fn edition_compat_check(message: String) { + let edition_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()); - if version_tag == "handheld" { + if edition_tag == "handheld" { let profiles_path = format!("{}/handhelds/profiles.toml", chwd::consts::CHWD_PCI_CONFIG_DIR); @@ -511,19 +545,20 @@ fn on_action_clicked(param: &[glib::Value]) -> Option { let widget = param[0].get::().unwrap(); match widget.widget_name().as_str() { "install" => { - version_compat_check(fl!("calamares-install-type")); + edition_compat_check(fl!("calamares-install-type")); + outdated_version_check(fl!("calamares-install-type")); quick_message(fl!("calamares-install-type")); None - } + }, "autostart" => { let action = widget.downcast::().unwrap(); set_autostart(action.is_active()); None - } + }, _ => { show_about_dialog(); None - } + }, } } From bad1a77e63964cd49435bcc79e0e9bec189230db Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Thu, 7 Nov 2024 01:32:08 +0530 Subject: [PATCH 2/6] feat: testing ISO warning Signed-off-by: SoulHarsh007 --- i18n/en/cachyos_hello.ftl | 1 + src/main.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/i18n/en/cachyos_hello.ftl b/i18n/en/cachyos_hello.ftl index 10f9bd7..182bc44 100644 --- a/i18n/en/cachyos_hello.ftl +++ b/i18n/en/cachyos_hello.ftl @@ -80,6 +80,7 @@ calamares-install-type = Calamares install type offline-error = Unable to start online installation! No internet connection unsupported-hw-warning = You are attempting to install on hardware not supported by the current ISO, your installation will not be eligible for support outdated-version-warning = You are using an older version of CachyOS ISO, please consider using latest version for installations +testing-iso-warning = You are using a testing ISO, testing ISOs are not considered stable and ready for use tweaksbrowser-label = Apps/Tweaks appbrowser-label = Install Apps launch-start-label = Launch at start diff --git a/src/main.rs b/src/main.rs index a461832..2e384c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,17 @@ fn outdated_version_check(message: String) { let edition_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()); let version_tag = fs::read_to_string("/etc/version-tag").unwrap_or_default(); + let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; + + if version_tag.contains("testing") { + return show_simple_dialog( + window_ref, + gtk::MessageType::Warning, + &fl!("testing-iso-warning"), + message.clone(), + ); + } + let versions = reqwest::blocking::get("https://cachyos.org/versions.json") .unwrap() .json::() @@ -65,7 +76,6 @@ fn outdated_version_check(message: String) { }; if version_tag != latest_version { - let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; show_simple_dialog( window_ref, gtk::MessageType::Warning, @@ -556,6 +566,7 @@ fn on_action_clicked(param: &[glib::Value]) -> Option { None }, _ => { + outdated_version_check(fl!("calamares-install-type")); show_about_dialog(); None }, From c4aab94fb98ca79f8f8bfd395865bd53e15b762e Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Thu, 7 Nov 2024 02:18:57 +0530 Subject: [PATCH 3/6] chore: add translations for new strings Signed-off-by: SoulHarsh007 --- i18n/by/cachyos_hello.ftl | 2 ++ i18n/cs/cachyos_hello.ftl | 2 ++ i18n/de/cachyos_hello.ftl | 2 ++ i18n/it/cachyos_hello.ftl | 2 ++ i18n/nl/cachyos_hello.ftl | 2 ++ i18n/pl/cachyos_hello.ftl | 2 ++ i18n/ru/cachyos_hello.ftl | 2 ++ i18n/sk/cachyos_hello.ftl | 4 +++- i18n/tr/cachyos_hello.ftl | 2 ++ i18n/zh-CN/cachyos_hello.ftl | 2 ++ 10 files changed, 21 insertions(+), 1 deletion(-) diff --git a/i18n/by/cachyos_hello.ftl b/i18n/by/cachyos_hello.ftl index 20b8321..4a595f4 100644 --- a/i18n/by/cachyos_hello.ftl +++ b/i18n/by/cachyos_hello.ftl @@ -77,6 +77,8 @@ calamares-install-type = тып усталёўкі Calamares # Main Page (body) offline-error = Не ўдаецца запусціць анлайн-усталёўку! Няма падлучэння да Інтэрнэту unsupported-hw-warning = Вы спрабуеце ўсталяваць на абсталяванне, якое не падтрымліваецца бягучым ISO, ваша ўстаноўка не будзе мець права на падтрымку +outdated-version-warning = Вы выкарыстоўваеце старую версію CachyOS ISO, калі ласка, разгледзьце магчымасць выкарыстання апошняй версіі для ўстаноўкі +testing-iso-warning = Вы выкарыстоўваеце тэставую версію ISO, тэставыя версіі ISO не лічацца стабільнымі і гатовымі да выкарыстання tweaksbrowser-label = Праграммы/Налады appbrowser-label = Устанавіць Праграммы launch-start-label = Запуск пры старту diff --git a/i18n/cs/cachyos_hello.ftl b/i18n/cs/cachyos_hello.ftl index 2bf4758..9f750c7 100644 --- a/i18n/cs/cachyos_hello.ftl +++ b/i18n/cs/cachyos_hello.ftl @@ -77,6 +77,8 @@ calamares-install-type = Typ Instalace Calamares # Hlavní stránka (tělo) offline-error = Nedá se spustit online instalace! Žádné internetové připojení unsupported-hw-warning = Pokoušíte se instalovat na hardware, který není podporován aktuální verzí ISO, vaše instalace nebude mít nárok na podporu +outdated-version-warning = Používáte starší verzi CachyOS ISO, zvažte prosím použití nejnovější verze pro instalace +testing-iso-warning = Používáte testovací ISO, testovací ISO nejsou považovány za stabilní a připravené k použití tweaksbrowser-label = Aplikacie/Vylepšení appbrowser-label = Instalovat Aplikace launch-start-label = Spustit při startu diff --git a/i18n/de/cachyos_hello.ftl b/i18n/de/cachyos_hello.ftl index 69fbdb3..8e41207 100644 --- a/i18n/de/cachyos_hello.ftl +++ b/i18n/de/cachyos_hello.ftl @@ -57,6 +57,8 @@ section-project = PROJEKT # Main Page (body) offline-error = Die Online-Installation kann nicht gestartet werden! Keine Internetverbindung unsupported-hw-warning = Sie versuchen, die Installation auf einer Hardware durchzuführen, die von der aktuellen ISO nicht unterstützt wird, und können daher keinen Support in Anspruch nehmen +outdated-version-warning = Sie verwenden eine ältere Version des CachyOS ISO, bitte verwenden Sie die neueste Version für Installationen +testing-iso-warning = Sie verwenden ein Test-ISO, Test-ISOs gelten nicht als stabil und einsatzbereit tweaksbrowser-label = Apps/Tweaks appbrowser-label = Apps installieren launch-start-label = Beim Systemstart ausführen diff --git a/i18n/it/cachyos_hello.ftl b/i18n/it/cachyos_hello.ftl index 93346a1..de8dd9a 100644 --- a/i18n/it/cachyos_hello.ftl +++ b/i18n/it/cachyos_hello.ftl @@ -57,6 +57,8 @@ section-project = PROGETTO # Main Page (body) offline-error = Impossibile avviare l'installazione online! Connessione a internet assente unsupported-hw-warning = Si sta tentando di effettuare l'installazione su un hardware non supportato dall'ISO corrente; l'installazione non potrà beneficiare dell'assistenza +outdated-version-warning = Stai usando una versione obsoleta dell'ISO di CachyOS, considera di utilizzare l'ultima versione per le installazioni +testing-iso-warning = Stai usando una ISO di test, le ISO di test non sono considerate stabili e pronte per l'uso tweaksbrowser-label = Applicazioni/Personalizzazioni appbrowser-label = Installa Applicazioni launch-start-label = Lancia all'avvio diff --git a/i18n/nl/cachyos_hello.ftl b/i18n/nl/cachyos_hello.ftl index 428fbe3..262ead7 100644 --- a/i18n/nl/cachyos_hello.ftl +++ b/i18n/nl/cachyos_hello.ftl @@ -77,6 +77,8 @@ calamares-install-type = Calamares-installatietype # Main Page (body) offline-error = De installatie kan niet worden gestart: er is geen internetverbinding unsupported-hw-warning = U probeert te installeren op hardware die niet wordt ondersteund door de huidige ISO, uw installatie komt niet in aanmerking voor ondersteuning +outdated-version-warning = U gebruikt een oudere versie van CachyOS ISO, overweeg alstublieft de nieuwste versie te gebruiken voor installaties +testing-iso-warning = U gebruikt een test-ISO, test-ISO's worden niet als stabiel en gebruiksklaar beschouwd tweaksbrowser-label = Programma's/Aanpassingen appbrowser-label = Programma's installeren launch-start-label = Tonen na opstarten diff --git a/i18n/pl/cachyos_hello.ftl b/i18n/pl/cachyos_hello.ftl index 13534a7..e2d91b6 100644 --- a/i18n/pl/cachyos_hello.ftl +++ b/i18n/pl/cachyos_hello.ftl @@ -57,6 +57,8 @@ section-project = PROJEKT # Main Page (body) offline-error = Instalacja online niemożliwa! Brak połączenia internetowego unsupported-hw-warning = Próba instalacji na sprzęcie nieobsługiwanym przez aktualne ISO spowoduje, że instalacja nie będzie objęta pomocą techniczną +outdated-version-warning = Używasz starszej wersji CachyOS ISO, rozważ użycie najnowszej wersji do instalacji +testing-iso-warning = Używasz testowej wersji ISO, testowe wersje ISO nie są uważane za stabilne i gotowe do użycia tweaksbrowser-label = Programy/Usprawnienia appbrowser-label = Instalator Programów launch-start-label = Uruchamiaj przy starcie diff --git a/i18n/ru/cachyos_hello.ftl b/i18n/ru/cachyos_hello.ftl index dfa54ab..b23eee6 100644 --- a/i18n/ru/cachyos_hello.ftl +++ b/i18n/ru/cachyos_hello.ftl @@ -76,6 +76,8 @@ calamares-install-type = Calamares тип установки # Main Page (body) offline-error = Не удается запустить онлайн-установку! Нет подключения к Интернету unsupported-hw-warning = Вы пытаетесь установить систему на оборудовании, не поддерживаемом текущим ISO. Ваша установка не будет иметь поддержки +outdated-version-warning = Вы используете устаревшую версию ISO CachyOS, пожалуйста, рассмотрите возможность использования последней версии для установки +testing-iso-warning = Вы используете тестовую версию ISO, тестовые версии ISO не считаются стабильными и готовыми к использованию tweaksbrowser-label = Приложения/Настройки appbrowser-label = Установить ПO launch-start-label = Автозапуск diff --git a/i18n/sk/cachyos_hello.ftl b/i18n/sk/cachyos_hello.ftl index b4446c7..84fca45 100644 --- a/i18n/sk/cachyos_hello.ftl +++ b/i18n/sk/cachyos_hello.ftl @@ -77,6 +77,8 @@ calamares-install-type = Typ inštalácie Calamares # Hlavná stránka (telo) offline-error = Nedá sa spustiť online inštalácia! Žiadne internetové pripojenie unsupported-hw-warning = Pokúšate sa nainštalovať na hardvér, ktorý nie je podporovaný aktuálnou verziou ISO, vaša inštalácia nebude mať nárok na podporu +outdated-version-warning = Používate staršiu verziu CachyOS ISO, zvážte použitie najnovšej verzie pre inštalácie +testing-iso-warning = Používate testovacie ISO, testovacie ISO nie sú považované za stabilné a pripravené na použitie tweaksbrowser-label = Aplikácie/Vylepšenia appbrowser-label = Inštalovať aplikácie launch-start-label = Spustiť pri štarte @@ -84,4 +86,4 @@ welcome-title = Vitajte v CachyOS! welcome-body = Ďakujeme, že ste sa pridali k našej komunite! - My, vývojári CachyOS, dúfame, že budete používať CachyOS s rovnakým nadšením, s akým ho my vytvárame. Odkazy nižšie vám pomôžu začať s vaším novým operačným systémom. Užite si zážitok a neváhajte nám poslať vašu spätnú väzbu. \ No newline at end of file + My, vývojári CachyOS, dúfame, že budete používať CachyOS s rovnakým nadšením, s akým ho my vytvárame. Odkazy nižšie vám pomôžu začať s vaším novým operačným systémom. Užite si zážitok a neváhajte nám poslať vašu spätnú väzbu. diff --git a/i18n/tr/cachyos_hello.ftl b/i18n/tr/cachyos_hello.ftl index c9f4c2d..c19b80e 100644 --- a/i18n/tr/cachyos_hello.ftl +++ b/i18n/tr/cachyos_hello.ftl @@ -73,6 +73,8 @@ calamares-install-type = Calamares kurulum tipi # Main Page (body) offline-error = Çevrimiçi kurulum başlatılamadı! Bir internet bağlantısı bulunmuyor. unsupported-hw-warning = Mevcut ISO tarafından desteklenmeyen bir donanıma kurulum yapmaya çalışıyorsunuz, kurulumunuz destek için uygun olmayacaktır +outdated-version-warning = Daha eski bir CachyOS ISO sürümü kullanıyorsunuz, lütfen kurulumlar için en son sürümü kullanmayı düşünün +testing-iso-warning = Test amaçlı bir ISO kullanıyorsunuz, test ISO'ları kararlı ve kullanıma hazır olarak kabul edilmez tweaksbrowser-label = Uygulamalar/İyileştirmeler appbrowser-label = Uygulama kur launch-start-label = Başlangıçta aç diff --git a/i18n/zh-CN/cachyos_hello.ftl b/i18n/zh-CN/cachyos_hello.ftl index 99ce1bc..dddc21d 100644 --- a/i18n/zh-CN/cachyos_hello.ftl +++ b/i18n/zh-CN/cachyos_hello.ftl @@ -68,6 +68,8 @@ section-project = 项目 # Main Page (body) offline-error = 无法启动在线安装!无网络连接 unsupported-hw-warning = 如果您试图在当前 ISO 不支持的硬件上进行安装,您的安装将无法获得支持 +outdated-version-warning = 您正在使用旧版本的 CachyOS ISO,请考虑使用最新版本进行安装 +testing-iso-warning = 您正在使用测试版 ISO,测试版 ISO 不被认为是稳定且可供使用的 tweaksbrowser-label = 应用/调整 appbrowser-label = 安装应用 launch-start-label = 启动时运行 From 09c39e876799ae70d9c1431ee992ad3be86c1b0e Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Thu, 7 Nov 2024 02:19:18 +0530 Subject: [PATCH 4/6] chore: move connectivity check to a separate function Signed-off-by: SoulHarsh007 --- src/main.rs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2e384c7..dfabbfe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,25 +112,26 @@ fn edition_compat_check(message: String) { } } +fn connectivity_check(message: String) { + let status = match reqwest::blocking::get("https://cachyos.org") { + Ok(resp) => resp.status().is_success() || resp.status().is_server_error(), + _ => false, + }; + + if !status { + let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; + utils::show_simple_dialog( + window_ref, + gtk::MessageType::Error, + &fl!("offline-error"), + message, + ); + } +} + fn quick_message(message: String) { // Spawn child process in separate thread. std::thread::spawn(move || { - let status = match reqwest::blocking::get("https://cachyos.org") { - Ok(resp) => resp.status().is_success() || resp.status().is_server_error(), - _ => false, - }; - - if !status { - let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; - utils::show_simple_dialog( - window_ref, - gtk::MessageType::Error, - &fl!("offline-error"), - message, - ); - return; - } - let cmd = "/usr/local/bin/calamares-online.sh".to_owned(); Exec::cmd(cmd).join().unwrap(); }); @@ -555,6 +556,7 @@ fn on_action_clicked(param: &[glib::Value]) -> Option { let widget = param[0].get::().unwrap(); match widget.widget_name().as_str() { "install" => { + connectivity_check(fl!("calamares-install-type")); edition_compat_check(fl!("calamares-install-type")); outdated_version_check(fl!("calamares-install-type")); quick_message(fl!("calamares-install-type")); From d1a868868be42fe9f4c1b2449f9ba312a9a467c6 Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Thu, 7 Nov 2024 19:44:45 +0530 Subject: [PATCH 5/6] chore: update translations as per recommendations Signed-off-by: SoulHarsh007 --- i18n/de/cachyos_hello.ftl | 4 ++-- i18n/ru/cachyos_hello.ftl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/de/cachyos_hello.ftl b/i18n/de/cachyos_hello.ftl index 8e41207..c482b1d 100644 --- a/i18n/de/cachyos_hello.ftl +++ b/i18n/de/cachyos_hello.ftl @@ -57,8 +57,8 @@ section-project = PROJEKT # Main Page (body) offline-error = Die Online-Installation kann nicht gestartet werden! Keine Internetverbindung unsupported-hw-warning = Sie versuchen, die Installation auf einer Hardware durchzuführen, die von der aktuellen ISO nicht unterstützt wird, und können daher keinen Support in Anspruch nehmen -outdated-version-warning = Sie verwenden eine ältere Version des CachyOS ISO, bitte verwenden Sie die neueste Version für Installationen -testing-iso-warning = Sie verwenden ein Test-ISO, Test-ISOs gelten nicht als stabil und einsatzbereit +outdated-version-warning = Du nutzt eine alte Version von CachyOS, bitte downloade die letzte Version runter +testing-iso-warning = Du verwendest eine alte Testing ISO, Testing-ISOs sind nicht stabil und getestet tweaksbrowser-label = Apps/Tweaks appbrowser-label = Apps installieren launch-start-label = Beim Systemstart ausführen diff --git a/i18n/ru/cachyos_hello.ftl b/i18n/ru/cachyos_hello.ftl index b23eee6..8783eab 100644 --- a/i18n/ru/cachyos_hello.ftl +++ b/i18n/ru/cachyos_hello.ftl @@ -76,7 +76,7 @@ calamares-install-type = Calamares тип установки # Main Page (body) offline-error = Не удается запустить онлайн-установку! Нет подключения к Интернету unsupported-hw-warning = Вы пытаетесь установить систему на оборудовании, не поддерживаемом текущим ISO. Ваша установка не будет иметь поддержки -outdated-version-warning = Вы используете устаревшую версию ISO CachyOS, пожалуйста, рассмотрите возможность использования последней версии для установки +outdated-version-warning = Вы используете устаревшую версию CachyOS ISO, пожалуйста, рассмотрите возможность использования последней версии для установкиDD testing-iso-warning = Вы используете тестовую версию ISO, тестовые версии ISO не считаются стабильными и готовыми к использованию tweaksbrowser-label = Приложения/Настройки appbrowser-label = Установить ПO From 8be5da096b999868bdb7f9d6ade4a23a99e269cd Mon Sep 17 00:00:00 2001 From: SoulHarsh007 Date: Fri, 8 Nov 2024 23:08:54 +0530 Subject: [PATCH 6/6] chore: fix typo in RU translations Signed-off-by: SoulHarsh007 --- i18n/ru/cachyos_hello.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/ru/cachyos_hello.ftl b/i18n/ru/cachyos_hello.ftl index 8783eab..4f136f1 100644 --- a/i18n/ru/cachyos_hello.ftl +++ b/i18n/ru/cachyos_hello.ftl @@ -76,7 +76,7 @@ calamares-install-type = Calamares тип установки # Main Page (body) offline-error = Не удается запустить онлайн-установку! Нет подключения к Интернету unsupported-hw-warning = Вы пытаетесь установить систему на оборудовании, не поддерживаемом текущим ISO. Ваша установка не будет иметь поддержки -outdated-version-warning = Вы используете устаревшую версию CachyOS ISO, пожалуйста, рассмотрите возможность использования последней версии для установкиDD +outdated-version-warning = Вы используете устаревшую версию CachyOS ISO, пожалуйста, рассмотрите возможность использования последней версии для установки testing-iso-warning = Вы используете тестовую версию ISO, тестовые версии ISO не считаются стабильными и готовыми к использованию tweaksbrowser-label = Приложения/Настройки appbrowser-label = Установить ПO