Skip to content

Commit 2aac5c2

Browse files
authored
feat: add outdated ISO version check (#86)
* feat: add outdated ISO version check Signed-off-by: SoulHarsh007 <[email protected]> * feat: testing ISO warning Signed-off-by: SoulHarsh007 <[email protected]> * chore: add translations for new strings Signed-off-by: SoulHarsh007 <[email protected]> * chore: move connectivity check to a separate function Signed-off-by: SoulHarsh007 <[email protected]> * chore: update translations as per recommendations Signed-off-by: SoulHarsh007 <[email protected]> * chore: fix typo in RU translations Signed-off-by: SoulHarsh007 <[email protected]> --------- Signed-off-by: SoulHarsh007 <[email protected]>
1 parent 59647a4 commit 2aac5c2

13 files changed

+96
-26
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ gtk = { version = "0.18", default-features = false }
1919
gio = { version = "0.20", default-features = false }
2020
gdk-pixbuf = "0.20"
2121
glib = { default-features = false, version = "0.20" }
22-
serde = { version = "1", default-features = false }
22+
serde = { version = "1", features = ["derive"] }
2323
serde_json = "1"
24-
reqwest = { version = "0.12", features = ["blocking"] }
24+
reqwest = { version = "0.12", features = ["blocking", "json"] }
2525
unic-langid = "0.9"
2626
phf = { version = "0.11", features = ["macros"], default-features = false }
2727
chwd = { git = "https://github.com/CachyOS/chwd", rev = "d7e7e65c5c2c0ffe0434adad9a0016617d1f8bb7", version = "1.10.0" }

i18n/by/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ calamares-install-type = тып усталёўкі Calamares
7777
# Main Page (body)
7878
offline-error = Не ўдаецца запусціць анлайн-усталёўку! Няма падлучэння да Інтэрнэту
7979
unsupported-hw-warning = Вы спрабуеце ўсталяваць на абсталяванне, якое не падтрымліваецца бягучым ISO, ваша ўстаноўка не будзе мець права на падтрымку
80+
outdated-version-warning = Вы выкарыстоўваеце старую версію CachyOS ISO, калі ласка, разгледзьце магчымасць выкарыстання апошняй версіі для ўстаноўкі
81+
testing-iso-warning = Вы выкарыстоўваеце тэставую версію ISO, тэставыя версіі ISO не лічацца стабільнымі і гатовымі да выкарыстання
8082
tweaksbrowser-label = Праграммы/Налады
8183
appbrowser-label = Устанавіць Праграммы
8284
launch-start-label = Запуск пры старту

i18n/cs/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ calamares-install-type = Typ Instalace Calamares
7777
# Hlavní stránka (tělo)
7878
offline-error = Nedá se spustit online instalace! Žádné internetové připojení
7979
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
80+
outdated-version-warning = Používáte starší verzi CachyOS ISO, zvažte prosím použití nejnovější verze pro instalace
81+
testing-iso-warning = Používáte testovací ISO, testovací ISO nejsou považovány za stabilní a připravené k použití
8082
tweaksbrowser-label = Aplikacie/Vylepšení
8183
appbrowser-label = Instalovat Aplikace
8284
launch-start-label = Spustit při startu

i18n/de/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ section-project = PROJEKT
5757
# Main Page (body)
5858
offline-error = Die Online-Installation kann nicht gestartet werden! Keine Internetverbindung
5959
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
60+
outdated-version-warning = Du nutzt eine alte Version von CachyOS, bitte downloade die letzte Version runter
61+
testing-iso-warning = Du verwendest eine alte Testing ISO, Testing-ISOs sind nicht stabil und getestet
6062
tweaksbrowser-label = Apps/Tweaks
6163
appbrowser-label = Apps installieren
6264
launch-start-label = Beim Systemstart ausführen

i18n/en/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ calamares-install-type = Calamares install type
7979
# Main Page (body)
8080
offline-error = Unable to start online installation! No internet connection
8181
unsupported-hw-warning = You are attempting to install on hardware not supported by the current ISO, your installation will not be eligible for support
82+
outdated-version-warning = You are using an older version of CachyOS ISO, please consider using latest version for installations
83+
testing-iso-warning = You are using a testing ISO, testing ISOs are not considered stable and ready for use
8284
tweaksbrowser-label = Apps/Tweaks
8385
appbrowser-label = Install Apps
8486
launch-start-label = Launch at start

i18n/it/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ section-project = PROGETTO
5757
# Main Page (body)
5858
offline-error = Impossibile avviare l'installazione online! Connessione a internet assente
5959
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
60+
outdated-version-warning = Stai usando una versione obsoleta dell'ISO di CachyOS, considera di utilizzare l'ultima versione per le installazioni
61+
testing-iso-warning = Stai usando una ISO di test, le ISO di test non sono considerate stabili e pronte per l'uso
6062
tweaksbrowser-label = Applicazioni/Personalizzazioni
6163
appbrowser-label = Installa Applicazioni
6264
launch-start-label = Lancia all'avvio

i18n/nl/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ calamares-install-type = Calamares-installatietype
7777
# Main Page (body)
7878
offline-error = De installatie kan niet worden gestart: er is geen internetverbinding
7979
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
80+
outdated-version-warning = U gebruikt een oudere versie van CachyOS ISO, overweeg alstublieft de nieuwste versie te gebruiken voor installaties
81+
testing-iso-warning = U gebruikt een test-ISO, test-ISO's worden niet als stabiel en gebruiksklaar beschouwd
8082
tweaksbrowser-label = Programma's/Aanpassingen
8183
appbrowser-label = Programma's installeren
8284
launch-start-label = Tonen na opstarten

i18n/pl/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ section-project = PROJEKT
5757
# Main Page (body)
5858
offline-error = Instalacja online niemożliwa! Brak połączenia internetowego
5959
unsupported-hw-warning = Próba instalacji na sprzęcie nieobsługiwanym przez aktualne ISO spowoduje, że instalacja nie będzie objęta pomocą techniczną
60+
outdated-version-warning = Używasz starszej wersji CachyOS ISO, rozważ użycie najnowszej wersji do instalacji
61+
testing-iso-warning = Używasz testowej wersji ISO, testowe wersje ISO nie są uważane za stabilne i gotowe do użycia
6062
tweaksbrowser-label = Programy/Usprawnienia
6163
appbrowser-label = Instalator Programów
6264
launch-start-label = Uruchamiaj przy starcie

i18n/ru/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ calamares-install-type = Calamares тип установки
7676
# Main Page (body)
7777
offline-error = Не удается запустить онлайн-установку! Нет подключения к Интернету
7878
unsupported-hw-warning = Вы пытаетесь установить систему на оборудовании, не поддерживаемом текущим ISO. Ваша установка не будет иметь поддержки
79+
outdated-version-warning = Вы используете устаревшую версию CachyOS ISO, пожалуйста, рассмотрите возможность использования последней версии для установки
80+
testing-iso-warning = Вы используете тестовую версию ISO, тестовые версии ISO не считаются стабильными и готовыми к использованию
7981
tweaksbrowser-label = Приложения/Настройки
8082
appbrowser-label = Установить ПO
8183
launch-start-label = Автозапуск

i18n/sk/cachyos_hello.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ calamares-install-type = Typ inštalácie Calamares
7777
# Hlavná stránka (telo)
7878
offline-error = Nedá sa spustiť online inštalácia! Žiadne internetové pripojenie
7979
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
80+
outdated-version-warning = Používate staršiu verziu CachyOS ISO, zvážte použitie najnovšej verzie pre inštalácie
81+
testing-iso-warning = Používate testovacie ISO, testovacie ISO nie sú považované za stabilné a pripravené na použitie
8082
tweaksbrowser-label = Aplikácie/Vylepšenia
8183
appbrowser-label = Inštalovať aplikácie
8284
launch-start-label = Spustiť pri štarte
8385
welcome-title = Vitajte v CachyOS!
8486
welcome-body =
8587
Ďakujeme, že ste sa pridali k našej komunite!
8688
87-
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.
89+
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.

i18n/tr/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ calamares-install-type = Calamares kurulum tipi
7373
# Main Page (body)
7474
offline-error = Çevrimiçi kurulum başlatılamadı! Bir internet bağlantısı bulunmuyor.
7575
unsupported-hw-warning = Mevcut ISO tarafından desteklenmeyen bir donanıma kurulum yapmaya çalışıyorsunuz, kurulumunuz destek için uygun olmayacaktır
76+
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
77+
testing-iso-warning = Test amaçlı bir ISO kullanıyorsunuz, test ISO'ları kararlı ve kullanıma hazır olarak kabul edilmez
7678
tweaksbrowser-label = Uygulamalar/İyileştirmeler
7779
appbrowser-label = Uygulama kur
7880
launch-start-label = Başlangıçta aç

i18n/zh-CN/cachyos_hello.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ section-project = 项目
6868
# Main Page (body)
6969
offline-error = 无法启动在线安装!无网络连接
7070
unsupported-hw-warning = 如果您试图在当前 ISO 不支持的硬件上进行安装,您的安装将无法获得支持
71+
outdated-version-warning = 您正在使用旧版本的 CachyOS ISO,请考虑使用最新版本进行安装
72+
testing-iso-warning = 您正在使用测试版 ISO,测试版 ISO 不被认为是稳定且可供使用的
7173
tweaksbrowser-label = 应用/调整
7274
appbrowser-label = 安装应用
7375
launch-start-label = 启动时运行

src/main.rs

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,54 @@ static G_SAVE_JSON: Lazy<Mutex<serde_json::Value>> = Lazy::new(|| {
4141
});
4242
static mut G_HELLO_WINDOW: Option<Arc<HelloWindow>> = None;
4343

44-
fn version_compat_check(message: String) {
45-
let version_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string());
44+
#[derive(serde::Deserialize)]
45+
struct Versions {
46+
#[serde(rename = "desktopISOVersion")]
47+
desktop_iso_version: String,
48+
#[serde(rename = "handheldISOVersion")]
49+
handheld_iso_version: String,
50+
}
51+
52+
fn outdated_version_check(message: String) {
53+
let edition_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string());
54+
let version_tag = fs::read_to_string("/etc/version-tag").unwrap_or_default();
55+
56+
let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window };
57+
58+
if version_tag.contains("testing") {
59+
return show_simple_dialog(
60+
window_ref,
61+
gtk::MessageType::Warning,
62+
&fl!("testing-iso-warning"),
63+
message.clone(),
64+
);
65+
}
66+
67+
let versions = reqwest::blocking::get("https://cachyos.org/versions.json")
68+
.unwrap()
69+
.json::<Versions>()
70+
.unwrap();
71+
72+
let latest_version = if edition_tag == "desktop" {
73+
versions.desktop_iso_version
74+
} else {
75+
versions.handheld_iso_version
76+
};
77+
78+
if version_tag != latest_version {
79+
show_simple_dialog(
80+
window_ref,
81+
gtk::MessageType::Warning,
82+
&fl!("outdated-version-warning"),
83+
message.clone(),
84+
);
85+
}
86+
}
87+
88+
fn edition_compat_check(message: String) {
89+
let edition_tag = fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string());
4690

47-
if version_tag == "handheld" {
91+
if edition_tag == "handheld" {
4892
let profiles_path =
4993
format!("{}/handhelds/profiles.toml", chwd::consts::CHWD_PCI_CONFIG_DIR);
5094

@@ -68,25 +112,26 @@ fn version_compat_check(message: String) {
68112
}
69113
}
70114

115+
fn connectivity_check(message: String) {
116+
let status = match reqwest::blocking::get("https://cachyos.org") {
117+
Ok(resp) => resp.status().is_success() || resp.status().is_server_error(),
118+
_ => false,
119+
};
120+
121+
if !status {
122+
let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window };
123+
utils::show_simple_dialog(
124+
window_ref,
125+
gtk::MessageType::Error,
126+
&fl!("offline-error"),
127+
message,
128+
);
129+
}
130+
}
131+
71132
fn quick_message(message: String) {
72133
// Spawn child process in separate thread.
73134
std::thread::spawn(move || {
74-
let status = match reqwest::blocking::get("https://cachyos.org") {
75-
Ok(resp) => resp.status().is_success() || resp.status().is_server_error(),
76-
_ => false,
77-
};
78-
79-
if !status {
80-
let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window };
81-
utils::show_simple_dialog(
82-
window_ref,
83-
gtk::MessageType::Error,
84-
&fl!("offline-error"),
85-
message,
86-
);
87-
return;
88-
}
89-
90135
let cmd = "/usr/local/bin/calamares-online.sh".to_owned();
91136
Exec::cmd(cmd).join().unwrap();
92137
});
@@ -511,19 +556,22 @@ fn on_action_clicked(param: &[glib::Value]) -> Option<glib::Value> {
511556
let widget = param[0].get::<gtk::Widget>().unwrap();
512557
match widget.widget_name().as_str() {
513558
"install" => {
514-
version_compat_check(fl!("calamares-install-type"));
559+
connectivity_check(fl!("calamares-install-type"));
560+
edition_compat_check(fl!("calamares-install-type"));
561+
outdated_version_check(fl!("calamares-install-type"));
515562
quick_message(fl!("calamares-install-type"));
516563
None
517-
}
564+
},
518565
"autostart" => {
519566
let action = widget.downcast::<gtk::Switch>().unwrap();
520567
set_autostart(action.is_active());
521568
None
522-
}
569+
},
523570
_ => {
571+
outdated_version_check(fl!("calamares-install-type"));
524572
show_about_dialog();
525573
None
526-
}
574+
},
527575
}
528576
}
529577

0 commit comments

Comments
 (0)