Cleaning and wrapping things up. Bump of version.

This commit is contained in:
2026-09-14 00:32:09 +02:00
parent 39fb7c55b9
commit 4a4e6927bd
5 changed files with 86 additions and 244 deletions
Generated
+5 -181
View File
@@ -52,26 +52,11 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "atomic-polyfill"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
dependencies = [
"critical-section",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.13.1" version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@@ -125,39 +110,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "cobs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
dependencies = [
"thiserror",
]
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.5" version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "critical-section"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
[[package]]
name = "embedded-io"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
[[package]]
name = "embedded-io"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.2" version = "1.0.2"
@@ -174,35 +132,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.17.1" version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "heapless"
version = "0.7.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
dependencies = [
"atomic-polyfill",
"hash32",
"rustc_version",
"serde",
"spin",
"stable_deref_trait",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.5.0" version = "0.5.0"
@@ -211,14 +146,12 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]] [[package]]
name = "hive-up" name = "hive-up"
version = "0.1.2" version = "0.2.0"
dependencies = [ dependencies = [
"clap", "clap",
"nix", "nix",
"postcard",
"regex-lite", "regex-lite",
"serde", "serde",
"serde_json",
"signal-hook", "signal-hook",
"time-format", "time-format",
"toml", "toml",
@@ -240,33 +173,12 @@ version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.189" version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.31.3" version = "0.31.3"
@@ -285,19 +197,6 @@ version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "postcard"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
dependencies = [
"cobs",
"embedded-io 0.4.0",
"embedded-io 0.6.1",
"heapless",
"serde",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.107" version = "1.0.107"
@@ -322,27 +221,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.229" version = "1.0.229"
@@ -373,19 +251,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "serde_json"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "1.1.1" version = "1.1.1"
@@ -415,21 +280,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "spin"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.11.1" version = "0.11.1"
@@ -447,26 +297,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "thiserror"
version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "time-format" name = "time-format"
version = "1.2.3" version = "1.2.3"
@@ -475,9 +305,9 @@ checksum = "fb54c799611991d3d4a66fee3ff17b9f600c2a0f8c0d34e8209dbd153ff0a87b"
[[package]] [[package]]
name = "toml" name = "toml"
version = "1.1.5+spec-1.1.0" version = "1.1.6+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde_core", "serde_core",
@@ -544,9 +374,3 @@ name = "winnow"
version = "1.0.4" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+1 -3
View File
@@ -1,15 +1,13 @@
[package] [package]
name = "hive-up" name = "hive-up"
version = "0.1.2" version = "0.2.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
clap = { version = "4.6", features = ["derive"] } clap = { version = "4.6", features = ["derive"] }
nix = { version = "0", features = ["user"] } nix = { version = "0", features = ["user"] }
postcard = { version = "1.1", features = ["use-std"] }
regex-lite = "0.1" regex-lite = "0.1"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
signal-hook = "0.4" signal-hook = "0.4"
time-format = "1.2" time-format = "1.2"
toml = "1.1" toml = "1.1"
+2 -1
View File
@@ -9,4 +9,5 @@ Target = linux-kira-server-lts
[Action] [Action]
Description = Running custom command after kernel update Description = Running custom command after kernel update
When = PostTransaction When = PostTransaction
Exec = /usr/bin/hive-up cli --update-boot Exec = /usr/bin/hive-up boot update
+54 -54
View File
@@ -143,46 +143,46 @@ pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecComma
/// pacman -Sy /// pacman -Sy
/// pacman -Qu /// pacman -Qu
/// returns number of updatable packages, returns 0 if there is no updates awailable /// returns number of updatable packages, returns 0 if there is no updates awailable
pub fn check_updates() -> Result<u32, ExecCommandError> { // pub fn check_updates() -> Result<u32, ExecCommandError> {
// Synchronize pacman DB // // Synchronize pacman DB
exec_command("pacman", &vec!["-Sy"])?; // exec_command("pacman", &vec!["-Sy"])?;
// Check for updates // // Check for updates
let out = Command::new("pacman").arg("-Qu").output()?; // let out = Command::new("pacman").arg("-Qu").output()?;
if out.status.success() { // if out.status.success() {
Ok(String::from_utf8(out.stdout)? // Ok(String::from_utf8(out.stdout)?
.lines() // .lines()
.count() // .count()
.try_into() // .try_into()
.unwrap()) // .unwrap())
} else { // } else {
if let Some(code) = out.status.code() // if let Some(code) = out.status.code()
&& code == 1 // && code == 1
{ // {
Ok(0) // Ok(0)
} else { // } else {
Err(ExecCommandError::Other(format!( // Err(ExecCommandError::Other(format!(
"pacman -Qu failed: {}", // "pacman -Qu failed: {}",
String::from_utf8(out.stderr)? // String::from_utf8(out.stderr)?
))) // )))
} // }
} // }
} // }
/// ///
/// sudo pacman -Suw --noconfirm --noprogressbar /// sudo pacman -Suw --noconfirm --noprogressbar
/// Download updates (need to check for updates first) /// Download updates (need to check for updates first)
/// ///
pub fn download_updates() -> Result<(), ExecCommandError> { // pub fn download_updates() -> Result<(), ExecCommandError> {
exec_command("pacman", &vec!["-Suw", "--noconfirm", "--noprogressbar"]) // exec_command("pacman", &vec!["-Suw", "--noconfirm", "--noprogressbar"])
} // }
/// ///
/// sudo pacman -Su --noconfirm --noprogressbar /// sudo pacman -Su --noconfirm --noprogressbar
/// Perform updates /// Perform updates
/// ///
pub fn pkg_upgrade() -> Result<(), ExecCommandError> { // pub fn pkg_upgrade() -> Result<(), ExecCommandError> {
exec_command("pacman", &vec!["-Su", "--noconfirm", "--noprogressbar"]) // exec_command("pacman", &vec!["-Su", "--noconfirm", "--noprogressbar"])
} // }
/// ///
@@ -264,38 +264,38 @@ pub fn check_if_run_as_root() -> bool {
} }
} }
#[derive(Debug)] // #[derive(Debug)]
pub enum SysUpgradeError { // pub enum SysUpgradeError {
SnapshotError(ExecCommandError), // SnapshotError(ExecCommandError),
PkgUpgradeErr((String, ExecCommandError)), // PkgUpgradeErr((String, ExecCommandError)),
} // }
impl std::fmt::Display for SysUpgradeError { // impl std::fmt::Display for SysUpgradeError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { // fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self { // match self {
SysUpgradeError::SnapshotError(e) => write!(f, "Snapshot creation error: {}", e), // SysUpgradeError::SnapshotError(e) => write!(f, "Snapshot creation error: {}", e),
SysUpgradeError::PkgUpgradeErr((_, e)) => write!(f, "Packages upgrade error: {}", e), // SysUpgradeError::PkgUpgradeErr((_, e)) => write!(f, "Packages upgrade error: {}", e),
} // }
} // }
} // }
// Implement std::error::Error // // Implement std::error::Error
impl std::error::Error for SysUpgradeError {} // impl std::error::Error for SysUpgradeError {}
/// ///
/// Perform system upgrade /// Perform system upgrade
/// Reruns root snapshot name on success /// Reruns root snapshot name on success
/// In case of upgrade error SysUpgradeError::PkgUpgradeErr contains snapshot time is str format /// In case of upgrade error SysUpgradeError::PkgUpgradeErr contains snapshot time is str format
/// ///
pub fn sys_upgrade() -> Result<String, SysUpgradeError> { // pub fn sys_upgrade() -> Result<String, SysUpgradeError> {
// snapshooting root // // snapshooting root
let snap_time = snapshot_system().map_err(SysUpgradeError::SnapshotError)?; // let snap_time = snapshot_system().map_err(SysUpgradeError::SnapshotError)?;
// try to perform packages upgrade // // try to perform packages upgrade
match pkg_upgrade() { // match pkg_upgrade() {
Ok(_) => Ok(snap_time), // Ok(_) => Ok(snap_time),
Err(ex) => Err(SysUpgradeError::PkgUpgradeErr((snap_time, ex))), // Err(ex) => Err(SysUpgradeError::PkgUpgradeErr((snap_time, ex))),
} // }
} // }
/// Gets device node aka /dev/sda1 from gpr partition label /// Gets device node aka /dev/sda1 from gpr partition label
/// blkid -s PARTLABEL --match-token PARTLABEL="bzz-primary" /// blkid -s PARTLABEL --match-token PARTLABEL="bzz-primary"
+24 -5
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
use clap::{Args, Parser, Subcommand}; use clap::{Parser, Subcommand};
use signal_hook; use signal_hook;
use std; use std;
use std::sync::Arc; use std::sync::Arc;
@@ -82,17 +82,28 @@ enum BootCommand {
/// Install new kernel into boot partition /// Install new kernel into boot partition
Update, Update,
/// Cleans up and recreates UFI boot menu /// Cleans up and recreates UFI boot menu
InitEfiMenu, EfiMenuInit,
/// Cleans up and recreates UFI boot menu and /EFI dir content /// Cleans up and recreates UFI boot menu and /EFI dir content
Init, Init,
} }
#[derive(Subcommand, Debug)]
#[group(required = true)]
enum Pac {
/// Creates snapshoots of /usr and /var subvolumea
SnapshotSystem,
}
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
#[group(required = true)] // 'multiple = false' enforces exclusivity #[group(required = true)] // 'multiple = false' enforces exclusivity
enum HiveUpMode { enum HiveUpMode {
/// Manage system boot /// Manage system boot
#[command(subcommand)] #[command(subcommand)]
Boot(BootCommand), Boot(BootCommand),
/// Intended to be used by pacman hooks
#[command(subcommand)]
Pac(Pac),
} }
/// Update program fot Kira Linux :3 /// Update program fot Kira Linux :3
@@ -106,11 +117,12 @@ struct Cli {
fn main() -> Result<(), HiveUpError> { fn main() -> Result<(), HiveUpError> {
// registering signals handling // registering signals handling
// we really do not want for this program to get terminated in a middle of something,
// so doing nothing with signals.
// second sigtrm should kill it tho
let term_flag: Arc<AtomicBool> = Arc::new(AtomicBool::new(false)); let term_flag: Arc<AtomicBool> = Arc::new(AtomicBool::new(false));
let reload_flag = Arc::new(AtomicBool::new(false));
signal_hook::flag::register(signal_hook::consts::SIGTERM, Arc::clone(&term_flag)).unwrap(); signal_hook::flag::register(signal_hook::consts::SIGTERM, Arc::clone(&term_flag)).unwrap();
signal_hook::flag::register(signal_hook::consts::SIGINT, Arc::clone(&term_flag)).unwrap(); signal_hook::flag::register(signal_hook::consts::SIGINT, Arc::clone(&term_flag)).unwrap();
signal_hook::flag::register(signal_hook::consts::SIGHUP, Arc::clone(&reload_flag)).unwrap();
let args = Cli::parse(); let args = Cli::parse();
@@ -127,7 +139,7 @@ fn main() -> Result<(), HiveUpError> {
println!("Updating boot..."); println!("Updating boot...");
hive_system::boot_update()?; hive_system::boot_update()?;
} }
BootCommand::InitEfiMenu => { BootCommand::EfiMenuInit => {
println!("Init EFI boot menu..."); println!("Init EFI boot menu...");
let kernel_cmd = bzz_config.kernel.and_then(|kk| kk.cmd.clone()); let kernel_cmd = bzz_config.kernel.and_then(|kk| kk.cmd.clone());
hive_system::init_efi_boot_record(&kernel_cmd)?; hive_system::init_efi_boot_record(&kernel_cmd)?;
@@ -141,6 +153,13 @@ fn main() -> Result<(), HiveUpError> {
hive_system::init_efi_boot_partition_content()?; hive_system::init_efi_boot_partition_content()?;
} }
}, },
HiveUpMode::Pac(pac_mode) => match pac_mode {
Pac::SnapshotSystem => {
println!("Creating system snapshot...");
let _ = hive_system::snapshot_system()?;
println!("Ok.");
}
}
} }
Ok(()) Ok(())