Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add outdated ISO version check #86

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions i18n/by/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Запуск пры старту
Expand Down
2 changes: 2 additions & 0 deletions i18n/cs/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions i18n/de/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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
Expand Down
2 changes: 2 additions & 0 deletions i18n/en/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ 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
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
Expand Down
2 changes: 2 additions & 0 deletions i18n/it/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions i18n/nl/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions i18n/pl/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions i18n/ru/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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 = Установить ПO
launch-start-label = Автозапуск
Expand Down
4 changes: 3 additions & 1 deletion i18n/sk/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ 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
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.
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.
2 changes: 2 additions & 0 deletions i18n/tr/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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ç
Expand Down
2 changes: 2 additions & 0 deletions i18n/zh-CN/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 启动时运行
Expand Down
94 changes: 71 additions & 23 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,54 @@ static G_SAVE_JSON: Lazy<Mutex<serde_json::Value>> = Lazy::new(|| {
});
static mut G_HELLO_WINDOW: Option<Arc<HelloWindow>> = 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 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::<Versions>()
.unwrap();

let latest_version = if edition_tag == "desktop" {
versions.desktop_iso_version
} else {
versions.handheld_iso_version
};

if version_tag != latest_version {
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);

Expand All @@ -68,25 +112,26 @@ fn version_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();
});
Expand Down Expand Up @@ -511,19 +556,22 @@ fn on_action_clicked(param: &[glib::Value]) -> Option<glib::Value> {
let widget = param[0].get::<gtk::Widget>().unwrap();
match widget.widget_name().as_str() {
"install" => {
version_compat_check(fl!("calamares-install-type"));
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"));
None
}
},
"autostart" => {
let action = widget.downcast::<gtk::Switch>().unwrap();
set_autostart(action.is_active());
None
}
},
_ => {
outdated_version_check(fl!("calamares-install-type"));
show_about_dialog();
None
}
},
}
}

Expand Down
Loading