Ripristinato akode update verso il Gitea dell'utente (come in 0.9.2, senza il sync del daemon)

Da 9494b768, e1ce139a e 1c278642: crate akode-update (ultima release da
git.difonzo.net/andrea/imeai-aKode, confronto semver, download solo dallo stesso host, verifica
SHA-256, sostituzione atomica), `akode update [--check]`, riga di avviso nella TUI, controllo in
background all'avvio al massimo ogni 24 h (disattivabile con [update] check_on_startup = false;
non installa mai nulla da solo). Nessun contatto con OpenAI o altri domini; il sistema upstream
(curl chatgpt.com/codex/install.sh, npm, brew) resta rimosso. Lasciato fuori l'allineamento del
daemon (95f4ddcd).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 14:35:07 +01:00
parent 925917c58c
commit 07ba31d492
22 changed files with 1538 additions and 75 deletions

View File

@@ -0,0 +1,90 @@
//! `akode update`: installs the latest aKode release from the configured Gitea repository.
//! The release archive is verified against its published SHA-256 before anything changes.
use std::path::PathBuf;
use akode_core::config::Config;
use akode_install_context::InstallContext;
use akode_update::CheckResult;
use akode_update::InstallOutcome;
use akode_update::InstallTarget;
use anyhow::Context;
#[derive(Debug, Default, clap::Parser)]
pub struct UpdateCommand {
/// Only report whether a newer release exists, without installing it.
#[arg(long)]
pub check: bool,
}
pub async fn run(cmd: UpdateCommand, config: &Config) -> anyhow::Result<()> {
let current = env!("CARGO_PKG_VERSION");
let repo_url = config.update_repo_url.as_str();
let client = akode_update::http_client(akode_update::COMMAND_TIMEOUT)?;
println!("Controllo degli aggiornamenti su {repo_url}…");
let release = match akode_update::check(&client, repo_url, current).await? {
CheckResult::UpToDate { latest: None } => {
println!("Nessuna release pubblicata: aKode {current} è la versione più recente.");
return Ok(());
}
CheckResult::UpToDate {
latest: Some(latest),
} => {
println!("aKode {current} è aggiornato (ultima release: {latest}).");
return Ok(());
}
CheckResult::Available(release) => release,
};
if cmd.check {
println!(
"È disponibile aKode {} (installata: {current}). Esegui \"akode update\" per installarla.",
release.version
);
return Ok(());
}
let target = akode_update::current_target()
.context("aKode non pubblica release per questa piattaforma")?;
let install = install_target()?;
println!("Download di aKode {} ({target})…", release.version);
let outcome = akode_update::install_release(&client, repo_url, &release, target, &install)
.await
.context("aggiornamento non riuscito; la versione installata non è stata modificata")?;
match outcome {
InstallOutcome::Binary { backup } => println!(
"aKode aggiornato da {current} a {}. Copia della versione precedente: {}",
release.version,
backup.display()
),
InstallOutcome::Package { backup } => println!(
"Pacchetto aKode aggiornato da {current} a {}. Copia del pacchetto precedente: {}",
release.version,
backup.display()
),
}
if config
.codex_home
.join("packages/app-server-daemon/current")
.symlink_metadata()
.is_ok()
{
println!(
"Il server in background usa ancora il pacchetto precedente: esegui \"akode app-server daemon update --from-cli\" per allinearlo."
);
}
println!("Riavvia aKode per usare la nuova versione.");
Ok(())
}
/// The real file behind the running binary, and its package directory if it is packaged.
fn install_target() -> anyhow::Result<InstallTarget> {
let exe = std::env::current_exe()
.and_then(|exe| exe.canonicalize())
.context("impossibile individuare il binario di aKode in esecuzione")?;
let package_dir = InstallContext::current()
.package_layout
.as_ref()
.filter(|layout| exe.starts_with(layout.bin_dir.as_path()))
.map(|layout| PathBuf::from(layout.package_dir.as_path()));
Ok(InstallTarget { exe, package_dir })
}