Updated to 0.9 : Added fwupdmgr support for firmware updates.
This commit is contained in:
parent
b5cc58b2b6
commit
925673811d
3 changed files with 74 additions and 40 deletions
64
osupdater/Cargo.lock
generated
64
osupdater/Cargo.lock
generated
|
@ -1,12 +1,12 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.6.15"
|
version = "0.6.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"anstyle-parse",
|
"anstyle-parse",
|
||||||
|
@ -19,33 +19,33 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle"
|
name = "anstyle"
|
||||||
version = "1.0.8"
|
version = "1.0.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-parse"
|
name = "anstyle-parse"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"utf8parse",
|
"utf8parse",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-query"
|
name = "anstyle-query"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "3.0.4"
|
version = "3.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
|
@ -53,9 +53,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.19"
|
version = "4.5.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
|
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -63,9 +63,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.19"
|
version = "4.5.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
|
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -87,24 +87,24 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.7.2"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color-print"
|
name = "color-print"
|
||||||
version = "0.3.6"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ee543c60ff3888934877a5671f45494dd27ed4ba25c6670b9a7576b7ed7a8c0"
|
checksum = "3aa954171903797d5623e047d9ab69d91b493657917bdfb8c2c80ecaf9cdb6f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"color-print-proc-macro",
|
"color-print-proc-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color-print-proc-macro"
|
name = "color-print-proc-macro"
|
||||||
version = "0.3.6"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77ff1a80c5f3cb1ca7c06ffdd71b6a6dd6d8f896c42141fbd43f50ed28dcdb93"
|
checksum = "692186b5ebe54007e45a59aea47ece9eb4108e141326c304cdc91699a7118a22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nom",
|
"nom",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -114,9 +114,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorchoice"
|
name = "colorchoice"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
|
@ -154,7 +154,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "osupdater"
|
name = "osupdater"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"color-print",
|
"color-print",
|
||||||
|
@ -162,9 +162,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.87"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
@ -186,9 +186,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.79"
|
version = "2.0.90"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -197,9 +197,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.13"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
|
@ -209,9 +209,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.59.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "osupdater"
|
name = "osupdater"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::path::{Path};
|
||||||
use color_print::{cprintln};
|
use color_print::{cprintln};
|
||||||
use clap::{command, Arg, ArgAction};
|
use clap::{command, Arg, ArgAction};
|
||||||
|
|
||||||
const VERSION: &'static str = "0.8";
|
const VERSION: &'static str = "0.999999999";
|
||||||
|
|
||||||
fn trim_newline(s: &mut String) {
|
fn trim_newline(s: &mut String) {
|
||||||
if s.ends_with('\n') {
|
if s.ends_with('\n') {
|
||||||
|
@ -106,11 +106,6 @@ fn update_flatpak() {
|
||||||
let mut sudo_bin = String::from_utf8(find_sudo.stdout).unwrap();
|
let mut sudo_bin = String::from_utf8(find_sudo.stdout).unwrap();
|
||||||
trim_newline(&mut sudo_bin);
|
trim_newline(&mut sudo_bin);
|
||||||
|
|
||||||
let find_sudo = Command::new("which")
|
|
||||||
.arg("sudo").stdout(Stdio::piped()).output().unwrap();
|
|
||||||
let mut sudo_bin = String::from_utf8(find_sudo.stdout).unwrap();
|
|
||||||
trim_newline(&mut sudo_bin);
|
|
||||||
|
|
||||||
let find_flatpak = Command::new("which")
|
let find_flatpak = Command::new("which")
|
||||||
.arg("flatpak").stdout(Stdio::piped()).output().unwrap();
|
.arg("flatpak").stdout(Stdio::piped()).output().unwrap();
|
||||||
let mut flatpak_bin = String::from_utf8(find_flatpak.stdout).unwrap();
|
let mut flatpak_bin = String::from_utf8(find_flatpak.stdout).unwrap();
|
||||||
|
@ -138,6 +133,37 @@ fn update_flatpak() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_firmware() {
|
||||||
|
let find_sudo = Command::new("which")
|
||||||
|
.arg("sudo").stdout(Stdio::piped()).output().unwrap();
|
||||||
|
let mut sudo_bin = String::from_utf8(find_sudo.stdout).unwrap();
|
||||||
|
trim_newline(&mut sudo_bin);
|
||||||
|
|
||||||
|
let find_fwupdmgr = Command::new("which")
|
||||||
|
.arg("fwupdmgr").stdout(Stdio::piped()).output().unwrap();
|
||||||
|
let mut fwupdmgr_bin = String::from_utf8(find_fwupdmgr.stdout).unwrap();
|
||||||
|
trim_newline(&mut fwupdmgr_bin);
|
||||||
|
|
||||||
|
let path = Path::new(&fwupdmgr_bin);
|
||||||
|
if path.exists(){
|
||||||
|
cprintln!("<bold><rev>osupdater: Updating firware db</rev></bold>");
|
||||||
|
let mut cmd =
|
||||||
|
Command::new(&sudo_bin)
|
||||||
|
.arg(&fwupdmgr_bin).arg("refresh").arg("-y")
|
||||||
|
.stdout(Stdio::inherit()).stderr(Stdio::inherit())
|
||||||
|
.spawn().unwrap();
|
||||||
|
let _output = cmd.wait();
|
||||||
|
cprintln!("<bold><rev>osupdater: Updating firware</rev></bold>");
|
||||||
|
let mut cmd =
|
||||||
|
Command::new(&sudo_bin)
|
||||||
|
.arg(&fwupdmgr_bin).arg("get-updates").arg("-y")
|
||||||
|
.stdout(Stdio::inherit()).stderr(Stdio::inherit())
|
||||||
|
.spawn().unwrap();
|
||||||
|
let _output = cmd.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fn update_pacman() {
|
fn update_pacman() {
|
||||||
let find_sudo = Command::new("which")
|
let find_sudo = Command::new("which")
|
||||||
.arg("sudo").stdout(Stdio::piped()).output().unwrap();
|
.arg("sudo").stdout(Stdio::piped()).output().unwrap();
|
||||||
|
@ -331,6 +357,10 @@ fn update_all() {
|
||||||
cprintln!("<bold><rev>osupdater: Checking containers</rev></bold>");
|
cprintln!("<bold><rev>osupdater: Checking containers</rev></bold>");
|
||||||
update_distrobox();
|
update_distrobox();
|
||||||
update_podman();
|
update_podman();
|
||||||
|
|
||||||
|
// Update firmware
|
||||||
|
cprintln!("<bold><rev>osupdater: Checking firmware</rev></bold>");
|
||||||
|
update_firmware();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -349,7 +379,7 @@ fn main() {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("UPDATE_TOOL")
|
Arg::new("UPDATE_TOOL")
|
||||||
.help("What updater to run")
|
.help("What updater to run")
|
||||||
.value_parser(["all", "apt", "distrobox", "dnf", "flatpak", "pacman","podman", "python","snap", "urpmi", "zypper"])
|
.value_parser(["all", "apt", "distrobox", "dnf", "flatpak", "firmware", "pacman","podman", "python","snap", "urpmi", "zypper"])
|
||||||
.required(false)
|
.required(false)
|
||||||
.default_value("all")
|
.default_value("all")
|
||||||
.action(ArgAction::Append)
|
.action(ArgAction::Append)
|
||||||
|
@ -387,6 +417,10 @@ fn main() {
|
||||||
update_flatpak()
|
update_flatpak()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.contains(&"firmware") {
|
||||||
|
update_firmware()
|
||||||
|
}
|
||||||
|
|
||||||
if args.contains(&"pacman") {
|
if args.contains(&"pacman") {
|
||||||
update_pacman()
|
update_pacman()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue