Main turn point, no pacman wrapping, no update functionality, making things simplier

This commit is contained in:
2026-09-13 22:23:43 +02:00
parent 20bdd217c4
commit 6811002ca6
6 changed files with 1 additions and 85 deletions
-18
View File
@@ -106,24 +106,6 @@ fn process_remoute(
println!("Error while ansvering cli request: {}", ex);
}
}
// we should apply updates if any on reboot
BzzReq::ScheduleUpdate => {
// but only if we have actually any updates
if bzz_db.updates_available > 0 {
bzz_db.update_on_reboot = true;
// keep it simple Kira
// lets just return err from the loop if something wrong with db
hive_db::write_db(&bzz_db)?;
// signal remoute that evertyhing go OK
if let Err(ex) = hive_intercom::socket_send(
&listening_socket,
&client_addr,
BzzResp::Finish,
) {
println!("Error while ansvering cli request: {}", ex);
}
}
}
BzzReq::CheckForUpdates => {
let resp = BzzResp::Working(1);
if let Err(ex) =
-10
View File
@@ -62,22 +62,12 @@ pub struct HiveDb {
pub update_check_timestamp: u64,
/// non zero if there is updates that can bee applied, showing numbers of packages that can be updated
pub updates_available: u32,
/// true if last update was successful
/// if it is false - nyanit need to roll back snapshots
pub update_status: bool,
/// datetime of last snapshot in format "%Y-%m-%dT%H:%M:%S"
pub last_snapshot_time: String,
/// set to true if we want to apply available updates on reboot
pub update_on_reboot: bool,
}
fn init_db() -> Result<HiveDb, DBError> {
let bzz_db = HiveDb{
update_check_timestamp: 0,
updates_available: 0,
update_status: false,
last_snapshot_time: "".into(),
update_on_reboot: false,
};
write_db(&bzz_db)?;
Ok(bzz_db)
-10
View File
@@ -96,7 +96,6 @@ pub enum BzzResp {
pub enum BzzReq {
UpdatesAvailable,
CheckForUpdates,
ScheduleUpdate,
}
pub fn socket_bind(read_timeout_sec: u64) -> Result<UnixDatagram, std::io::Error> {
@@ -194,12 +193,3 @@ pub fn client_check_for_updates() -> Result<u32, IntercomError> {
_ => Err(IntercomError::UnexpectedResponse),
}
}
pub fn client_schedule_update() -> Result<(), IntercomError> {
let resp = send_and_recv(BzzReq::ScheduleUpdate)?;
match resp {
BzzResp::Finish => Ok(()),
BzzResp::Error(ex) => Err(IntercomError::ServerError(ex)),
_ => Err(IntercomError::UnexpectedResponse),
}
}
+1 -44
View File
@@ -24,9 +24,6 @@ mod hive_system;
mod hive_config;
use crate::hive_config::HiveConfig;
use crate::hive_system::SysUpgradeError;
mod daemon;
mod hive_db;
mod hive_intercom;
@@ -118,18 +115,11 @@ struct RemoteArgs {
/// Ask daemon if there is any updates available
#[arg(long)]
updates_avail: bool,
/// Ask daemon to perform system update on next reboot
#[arg(long)]
schedule_update: bool,
}
#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
struct CliArgs {
/// Perform system upgrade
#[arg(long)]
upgrade: bool,
/// Install new kernel into boot partition
#[arg(long)]
update_boot: bool,
@@ -161,33 +151,6 @@ struct Cli {
mode: HiveUpMode,
}
fn cli_upgrade(bzz_config: HiveConfig) -> Result<(), HiveUpError> {
let mut bzz_db = hive_db::read_db()?;
if (bzz_db.updates_available !=0) && (bzz_db.update_on_reboot || bzz_config.update.auto_update) {
println!("Starting full system upgrade");
bzz_db.update_status = false;
hive_db::write_db(&bzz_db)?;
match hive_system::sys_upgrade() {
Ok(snap_time) => {
bzz_db.update_status = true;
bzz_db.update_on_reboot = false;
bzz_db.last_snapshot_time = snap_time;
hive_db::write_db(&bzz_db)?;
}
Err(SysUpgradeError::PkgUpgradeErr((snap_time, ex))) => {
bzz_db.update_status = false;
bzz_db.update_on_reboot = false;
bzz_db.last_snapshot_time = snap_time;
hive_db::write_db(&bzz_db)?;
return Err(ex.into());
}
Err(ex) => return Err(ex.to_string().into()),
}
}
Ok(())
}
fn main() -> Result<(), HiveUpError> {
// registering signals handling
let term_flag: Arc<AtomicBool> = Arc::new(AtomicBool::new(false));
@@ -208,9 +171,7 @@ fn main() -> Result<(), HiveUpError> {
match args.mode {
HiveUpMode::Daemon => daemon::run(bzz_config, term_flag.clone(), reload_flag.clone())?,
HiveUpMode::Cli(cli_args) => {
if cli_args.upgrade {
cli_upgrade(bzz_config)?;
} else if cli_args.update_boot {
if cli_args.update_boot {
println!("Updating boot...");
hive_system::boot_update()?;
} else if cli_args.init_boot_menu {
@@ -233,10 +194,6 @@ fn main() -> Result<(), HiveUpError> {
} else if remote_args.updates_avail {
let up_num = hive_intercom::client_updates_available()?;
println!("Updates awailable: {}", up_num);
} else if remote_args.schedule_update {
println!("Scheduling system update...");
hive_intercom::client_schedule_update()?;
print!("Done!")
}
}
}