Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e580457a5 | ||
|
|
5350658dab | ||
|
|
1ec0ac50a5 | ||
|
|
635bfce198 | ||
|
|
1307d2d7e8 |
84
Cargo.lock
generated
84
Cargo.lock
generated
@@ -17,17 +17,6 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ahash"
|
|
||||||
version = "0.7.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
"once_cell",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.20"
|
version = "0.7.20"
|
||||||
@@ -406,6 +395,28 @@ dependencies = [
|
|||||||
"windows-sys 0.45.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-random"
|
||||||
|
version = "0.1.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e"
|
||||||
|
dependencies = [
|
||||||
|
"const-random-macro",
|
||||||
|
"proc-macro-hack",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-random-macro"
|
||||||
|
version = "0.1.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro-hack",
|
||||||
|
"tiny-keccak",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation-sys"
|
name = "core-foundation-sys"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
@@ -439,6 +450,12 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crunchy"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -513,9 +530,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dlv-list"
|
name = "dlv-list"
|
||||||
version = "0.3.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
|
checksum = "d529fd73d344663edfd598ccb3f344e46034db51ebd103518eae34338248ad73"
|
||||||
|
dependencies = [
|
||||||
|
"const-random",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
@@ -814,9 +834,12 @@ name = "hashbrown"
|
|||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
dependencies = [
|
|
||||||
"ahash",
|
[[package]]
|
||||||
]
|
name = "hashbrown"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -980,7 +1003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown 0.12.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1291,12 +1314,12 @@ checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ordered-multimap"
|
name = "ordered-multimap"
|
||||||
version = "0.4.3"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a"
|
checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dlv-list",
|
"dlv-list",
|
||||||
"hashbrown",
|
"hashbrown 0.13.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1420,6 +1443,12 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-hack"
|
||||||
|
version = "0.5.20+deprecated"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.63"
|
version = "1.0.63"
|
||||||
@@ -1612,9 +1641,9 @@ checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-ini"
|
name = "rust-ini"
|
||||||
version = "0.18.0"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df"
|
checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"ordered-multimap",
|
"ordered-multimap",
|
||||||
@@ -2042,6 +2071,15 @@ dependencies = [
|
|||||||
"time-core",
|
"time-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tiny-keccak"
|
||||||
|
version = "2.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
|
||||||
|
dependencies = [
|
||||||
|
"crunchy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
@@ -2126,7 +2164,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "topgrade"
|
name = "topgrade"
|
||||||
version = "12.0.1"
|
version = "12.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ categories = ["os"]
|
|||||||
keywords = ["upgrade", "update"]
|
keywords = ["upgrade", "update"]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
repository = "https://github.com/topgrade-rs/topgrade"
|
repository = "https://github.com/topgrade-rs/topgrade"
|
||||||
version = "12.0.1"
|
version = "12.0.2"
|
||||||
authors = ["Roey Darwish Dror <roey.ghost@gmail.com>", "Thomas Schönauer <t.schoenauer@hgs-wt.at>"]
|
authors = ["Roey Darwish Dror <roey.ghost@gmail.com>", "Thomas Schönauer <t.schoenauer@hgs-wt.at>"]
|
||||||
exclude = ["doc/screenshot.gif"]
|
exclude = ["doc/screenshot.gif"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -63,7 +63,7 @@ depends = "$auto,git"
|
|||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
libc = "~0.2"
|
libc = "~0.2"
|
||||||
nix = "~0.24"
|
nix = "~0.24"
|
||||||
rust-ini = "~0.18"
|
rust-ini = "~0.19"
|
||||||
self_update_crate = { version = "~0.30", default-features = false, optional = true, package = "self_update", features = ["archive-tar", "compression-flate2", "rustls"] }
|
self_update_crate = { version = "~0.30", default-features = false, optional = true, package = "self_update", features = ["archive-tar", "compression-flate2", "rustls"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
|||||||
@@ -57,6 +57,9 @@
|
|||||||
# Whether to self update (this is ignored if the binary has been built without self update support, available also via setting the environment variable TOPGRADE_NO_SELF_UPGRADE)
|
# Whether to self update (this is ignored if the binary has been built without self update support, available also via setting the environment variable TOPGRADE_NO_SELF_UPGRADE)
|
||||||
#no_self_update = true
|
#no_self_update = true
|
||||||
|
|
||||||
|
# Extra Home Manager arguments
|
||||||
|
#home_manager_arguments = ["--flake", "file"]
|
||||||
|
|
||||||
# Commands to run before anything
|
# Commands to run before anything
|
||||||
[pre_commands]
|
[pre_commands]
|
||||||
#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
|
#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
|
||||||
|
|||||||
@@ -351,6 +351,9 @@ pub struct Linux {
|
|||||||
|
|
||||||
#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
|
#[merge(strategy = crate::utils::merge_strategies::string_append_opt)]
|
||||||
emerge_update_flags: Option<String>,
|
emerge_update_flags: Option<String>,
|
||||||
|
|
||||||
|
#[merge(strategy = crate::utils::merge_strategies::vec_prepend_opt)]
|
||||||
|
home_manager_arguments: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug, Merge)]
|
#[derive(Deserialize, Default, Debug, Merge)]
|
||||||
@@ -1275,6 +1278,14 @@ impl Config {
|
|||||||
.and_then(|linux| linux.nix_arguments.as_deref())
|
.and_then(|linux| linux.nix_arguments.as_deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra Home Manager arguments
|
||||||
|
pub fn home_manager(&self) -> Option<&Vec<String>> {
|
||||||
|
self.config_file
|
||||||
|
.linux
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|misc| misc.home_manager_arguments.as_ref())
|
||||||
|
}
|
||||||
|
|
||||||
/// Distrobox use root
|
/// Distrobox use root
|
||||||
pub fn distrobox_root(&self) -> bool {
|
pub fn distrobox_root(&self) -> bool {
|
||||||
self.config_file
|
self.config_file
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ pub enum TopgradeError {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
UnknownLinuxDistribution,
|
UnknownLinuxDistribution,
|
||||||
|
|
||||||
|
#[error("File \"/etc/os-release\" does not exist or is empty")]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
EmptyOSReleaseFile,
|
||||||
|
|
||||||
#[error("Failed getting the system package manager")]
|
#[error("Failed getting the system package manager")]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
FailedGettingPackageManager,
|
FailedGettingPackageManager,
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ use std::process::Command;
|
|||||||
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
||||||
print_separator("DragonFly BSD Packages");
|
print_separator("DragonFly BSD Packages");
|
||||||
ctx.execute(sudo)
|
let mut cmd = ctx.execute(sudo);
|
||||||
.args(["/usr/local/sbin/pkg", "upgrade"])
|
cmd.args(["/usr/local/sbin/pkg", "upgrade"]);
|
||||||
.arg(if ctx.config().yes(Step::System) { "-y" } else { "" })
|
if ctx.config().yes(Step::System) {
|
||||||
.status_checked()
|
cmd.arg("-y");
|
||||||
|
}
|
||||||
|
cmd.status_checked()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn audit_packages(ctx: &ExecutionContext) -> Result<()> {
|
pub fn audit_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
@@ -114,10 +114,14 @@ impl Distribution {
|
|||||||
if PathBuf::from(OS_RELEASE_PATH).exists() {
|
if PathBuf::from(OS_RELEASE_PATH).exists() {
|
||||||
let os_release = Ini::load_from_file(OS_RELEASE_PATH)?;
|
let os_release = Ini::load_from_file(OS_RELEASE_PATH)?;
|
||||||
|
|
||||||
|
if os_release.general_section().is_empty() {
|
||||||
|
return Err(TopgradeError::EmptyOSReleaseFile.into());
|
||||||
|
}
|
||||||
|
|
||||||
return Self::parse_os_release(&os_release);
|
return Self::parse_os_release(&os_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(TopgradeError::UnknownLinuxDistribution.into())
|
Err(TopgradeError::EmptyOSReleaseFile.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upgrade(self, ctx: &ExecutionContext) -> Result<()> {
|
pub fn upgrade(self, ctx: &ExecutionContext) -> Result<()> {
|
||||||
@@ -248,16 +252,18 @@ fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.args(["zypper", "refresh"])
|
.args(["zypper", "refresh"])
|
||||||
.status_checked()?;
|
.status_checked()?;
|
||||||
|
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.arg("zypper");
|
||||||
.arg("zypper")
|
cmd.arg(if ctx.config().suse_dup() {
|
||||||
.arg(if ctx.config().suse_dup() {
|
"dist-upgrade"
|
||||||
"dist-upgrade"
|
} else {
|
||||||
} else {
|
"update"
|
||||||
"update"
|
});
|
||||||
})
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) { "-y" } else { "" })
|
cmd.arg("-y");
|
||||||
.status_checked()?;
|
}
|
||||||
|
|
||||||
|
cmd.status_checked()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -269,24 +275,26 @@ fn upgrade_opensuse_tumbleweed(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.args(["zypper", "refresh"])
|
.args(["zypper", "refresh"])
|
||||||
.status_checked()?;
|
.status_checked()?;
|
||||||
|
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.args(["zypper", "dist-upgrade"]);
|
||||||
.arg("zypper")
|
if ctx.config().yes(Step::System) {
|
||||||
.arg("dist-upgrade")
|
cmd.arg("-y");
|
||||||
.arg(if ctx.config().yes(Step::System) { "-y" } else { "" })
|
}
|
||||||
.status_checked()?;
|
|
||||||
|
cmd.status_checked()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upgrade_suse_micro(ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_suse_micro(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.arg("transactional-update");
|
||||||
.arg("transactional-update")
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) { "-n" } else { "" })
|
cmd.arg("-n");
|
||||||
.arg("dup")
|
}
|
||||||
.status_checked()?;
|
|
||||||
|
cmd.arg("dup").status_checked()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -325,12 +333,13 @@ fn upgrade_pclinuxos(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
command_update.status_checked()?;
|
command_update.status_checked()?;
|
||||||
|
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.arg(&which("apt-get").unwrap());
|
||||||
.arg(&which("apt-get").unwrap())
|
cmd.arg("dist-upgrade");
|
||||||
.arg("dist-upgrade")
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) { "-y" } else { "" })
|
cmd.arg("-y");
|
||||||
.status_checked()?;
|
}
|
||||||
|
cmd.status_checked()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -502,12 +511,12 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.arg("eopkg");
|
||||||
.arg("eopkg")
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) { "-y" } else { "" })
|
cmd.arg("-y");
|
||||||
.arg("upgrade")
|
}
|
||||||
.status_checked()?;
|
cmd.arg("upgrade").status_checked()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -546,15 +555,12 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let new_version = string.contains("version: 1");
|
let new_version = string.contains("version: 1");
|
||||||
|
|
||||||
if new_version {
|
if new_version {
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(&pacdef);
|
||||||
.execute(&pacdef)
|
cmd.args(["package", "sync"]);
|
||||||
.args(["package", "sync"])
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) {
|
cmd.arg("--noconfirm");
|
||||||
"--noconfirm"
|
}
|
||||||
} else {
|
cmd.status_checked()?;
|
||||||
""
|
|
||||||
})
|
|
||||||
.status_checked()?;
|
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
ctx.run_type()
|
ctx.run_type()
|
||||||
@@ -562,15 +568,13 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.args(["package", "review"])
|
.args(["package", "review"])
|
||||||
.status_checked()?;
|
.status_checked()?;
|
||||||
} else {
|
} else {
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(&pacdef);
|
||||||
.execute(&pacdef)
|
cmd.arg("sync");
|
||||||
.arg("sync")
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) {
|
cmd.arg("--noconfirm");
|
||||||
"--noconfirm"
|
}
|
||||||
} else {
|
|
||||||
""
|
cmd.status_checked()?;
|
||||||
})
|
|
||||||
.status_checked()?;
|
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
ctx.run_type().execute(&pacdef).arg("review").status_checked()?;
|
ctx.run_type().execute(&pacdef).arg("review").status_checked()?;
|
||||||
@@ -616,15 +620,12 @@ pub fn run_packer_nu(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?;
|
||||||
ctx.run_type()
|
let mut cmd = ctx.run_type().execute(sudo);
|
||||||
.execute(sudo)
|
cmd.args(["swupd", "update"]);
|
||||||
.args(["swupd", "update"])
|
if ctx.config().yes(Step::System) {
|
||||||
.arg(if ctx.config().yes(Step::System) {
|
cmd.arg("--assume=yes");
|
||||||
"--assume=yes"
|
}
|
||||||
} else {
|
cmd.status_checked()?;
|
||||||
""
|
|
||||||
})
|
|
||||||
.status_checked()?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -442,7 +442,15 @@ pub fn run_home_manager(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let home_manager = require("home-manager")?;
|
let home_manager = require("home-manager")?;
|
||||||
|
|
||||||
print_separator("home-manager");
|
print_separator("home-manager");
|
||||||
ctx.run_type().execute(home_manager).arg("switch").status_checked()
|
|
||||||
|
let mut cmd = ctx.run_type().execute(home_manager);
|
||||||
|
cmd.arg("switch");
|
||||||
|
|
||||||
|
if let Some(extra_args) = ctx.config().home_manager() {
|
||||||
|
cmd.args(extra_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.status_checked()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_tldr(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_tldr(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use tracing::debug;
|
|||||||
use crate::command::CommandExt;
|
use crate::command::CommandExt;
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::terminal::{print_separator, print_warning};
|
use crate::terminal::{print_separator, print_warning};
|
||||||
use crate::utils::require;
|
use crate::utils::{require, which};
|
||||||
use crate::{error::SkipStep, steps::git::Repositories};
|
use crate::{error::SkipStep, steps::git::Repositories};
|
||||||
use crate::{powershell, Step};
|
use crate::{powershell, Step};
|
||||||
|
|
||||||
@@ -69,6 +69,10 @@ pub fn run_scoop(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_wsl(ctx: &ExecutionContext) -> Result<()> {
|
pub fn update_wsl(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
if !is_wsl_installed()? {
|
||||||
|
return Err(SkipStep("WSL not installed".to_string()).into());
|
||||||
|
}
|
||||||
|
|
||||||
let wsl = require("wsl")?;
|
let wsl = require("wsl")?;
|
||||||
|
|
||||||
print_separator("Update WSL");
|
print_separator("Update WSL");
|
||||||
@@ -87,6 +91,30 @@ pub fn update_wsl(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Detect if WSL is installed or not.
|
||||||
|
///
|
||||||
|
/// For WSL, we cannot simply check if command `wsl` is installed as on newer
|
||||||
|
/// versions of Windows (since windows 10 version 2004), this commmand is
|
||||||
|
/// installed by default.
|
||||||
|
///
|
||||||
|
/// If the command is installed and the user hasn't installed any Linux distros
|
||||||
|
/// on it, command `wsl -l` would print a help message and exit with failure, we
|
||||||
|
/// use this to check whether WSL is install or not.
|
||||||
|
fn is_wsl_installed() -> Result<bool> {
|
||||||
|
if let Some(wsl) = which("wsl") {
|
||||||
|
// Don't use `output_checked` as an execution failure log is not wanted
|
||||||
|
#[allow(clippy::disallowed_methods)]
|
||||||
|
let output = Command::new(wsl).arg("-l").output()?;
|
||||||
|
let status = output.status;
|
||||||
|
|
||||||
|
if status.success() {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
|
||||||
fn get_wsl_distributions(wsl: &Path) -> Result<Vec<String>> {
|
fn get_wsl_distributions(wsl: &Path) -> Result<Vec<String>> {
|
||||||
let output = Command::new(wsl).args(["--list", "-q"]).output_checked_utf8()?.stdout;
|
let output = Command::new(wsl).args(["--list", "-q"]).output_checked_utf8()?.stdout;
|
||||||
Ok(output
|
Ok(output
|
||||||
@@ -115,6 +143,10 @@ fn upgrade_wsl_distribution(wsl: &Path, dist: &str, ctx: &ExecutionContext) -> R
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_wsl_topgrade(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_wsl_topgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
if !is_wsl_installed()? {
|
||||||
|
return Err(SkipStep("WSL not installed".to_string()).into());
|
||||||
|
}
|
||||||
|
|
||||||
let wsl = require("wsl")?;
|
let wsl = require("wsl")?;
|
||||||
let wsl_distributions = get_wsl_distributions(&wsl)?;
|
let wsl_distributions = get_wsl_distributions(&wsl)?;
|
||||||
let mut ran = false;
|
let mut ran = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user