Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 4716cb7

Browse files
r-darwishbdaasemodularTacoMCOfficerfrezbo
authored
Add Bedrock Linux support (fix #745) (#747)
* Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
1 parent ab3ff0e commit 4716cb7

File tree

2 files changed

+60
-35
lines changed

2 files changed

+60
-35
lines changed

src/steps/os/archlinux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl ArchPackageManager for Pacman {
141141
impl Pacman {
142142
pub fn get(ctx: &ExecutionContext) -> Option<Self> {
143143
Some(Self {
144-
executable: which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman")),
144+
executable: which("powerpill").unwrap_or_else(|| PathBuf::from("pacman")),
145145
sudo: ctx.sudo().to_owned()?,
146146
})
147147
}
@@ -152,7 +152,7 @@ fn box_pacakge_manager<P: 'static + ArchPackageManager>(package_manager: P) -> B
152152
}
153153

154154
pub fn get_arch_package_manager(ctx: &ExecutionContext) -> Option<Box<dyn ArchPackageManager>> {
155-
let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman"));
155+
let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("pacman"));
156156

157157
match ctx.config().arch_package_manager() {
158158
config::ArchPackageManager::Autodetect => YayParu::get("paru", &pacman)

src/steps/os/linux.rs

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::utils::{require, require_option, which, PathExt};
77
use crate::Step;
88
use anyhow::Result;
99
use ini::Ini;
10-
use log::debug;
10+
use log::{debug, warn};
1111
use serde::Deserialize;
1212
use std::path::{Path, PathBuf};
1313
use std::process::Command;
@@ -26,6 +26,7 @@ struct OsRelease {
2626
pub enum Distribution {
2727
Alpine,
2828
Arch,
29+
Bedrock,
2930
CentOS,
3031
ClearLinux,
3132
Fedora,
@@ -80,6 +81,10 @@ impl Distribution {
8081
}
8182

8283
pub fn detect() -> Result<Self> {
84+
if PathBuf::from("/bedrock").exists() {
85+
return Ok(Distribution::Bedrock);
86+
}
87+
8388
if PathBuf::from(OS_RELEASE_PATH).exists() {
8489
let os_release = Ini::load_from_file(OS_RELEASE_PATH)?;
8590

@@ -105,6 +110,7 @@ impl Distribution {
105110
Distribution::Exherbo => upgrade_exherbo(ctx),
106111
Distribution::NixOS => upgrade_nixos(ctx),
107112
Distribution::KDENeon => upgrade_neon(ctx),
113+
Distribution::Bedrock => update_bedrock(ctx),
108114
}
109115
}
110116

@@ -119,6 +125,31 @@ impl Distribution {
119125
}
120126
}
121127

128+
fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
129+
let sudo = require_option(ctx.sudo().as_ref(), String::from("Sudo required"))?;
130+
131+
ctx.run_type().execute(sudo).args(&["brl", "update"]);
132+
133+
let output = Command::new("brl").arg("list").output()?;
134+
debug!("brl list: {:?} {:?}", output.stdout, output.stderr);
135+
136+
let parsed_output = String::from_utf8(output.stdout).unwrap();
137+
for distribution in parsed_output.trim().split('\n') {
138+
debug!("Bedrock distribution {}", distribution);
139+
match distribution {
140+
"arch" => archlinux::upgrade_arch_linux(ctx)?,
141+
"debian" | "ubuntu" => upgrade_debian(ctx)?,
142+
"centos" | "fedora" => upgrade_redhat(ctx)?,
143+
"bedrock" => upgrade_bedrock_strata(ctx)?,
144+
_ => {
145+
warn!("Unknown distribution {}", distribution);
146+
}
147+
}
148+
}
149+
150+
Ok(())
151+
}
152+
122153
fn is_wsl() -> Result<bool> {
123154
let output = Command::new("uname").arg("-r").check_output()?;
124155
debug!("Uname output: {}", output);
@@ -134,7 +165,7 @@ fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
134165
}
135166

136167
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
137-
let _ = if let Some(ostree) = Path::new("/usr/bin/rpm-ostree").if_exists() {
168+
let _ = if let Some(ostree) = Path::new("rpm-ostree").if_exists() {
138169
if ctx.config().rpm_ostree() {
139170
let mut command = ctx.run_type().execute(ostree);
140171
command.arg("upgrade");
@@ -149,11 +180,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
149180
if let Some(sudo) = &ctx.sudo() {
150181
let mut command = ctx.run_type().execute(&sudo);
151182
command
152-
.arg(
153-
Path::new("/usr/bin/dnf-3")
154-
.if_exists()
155-
.unwrap_or_else(|| Path::new("/usr/bin/yum")),
156-
)
183+
.arg(which("dnf").unwrap_or_else(|| Path::new("yum").to_path_buf()))
157184
.arg(if ctx.config().redhat_distro_sync() {
158185
"distro-sync"
159186
} else {
@@ -176,16 +203,23 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
176203
Ok(())
177204
}
178205

206+
fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
207+
if let Some(sudo) = ctx.sudo() {
208+
ctx.run_type().execute(&sudo).args(&["brl", "update"]).check_run()?;
209+
} else {
210+
print_warning("No sudo detected. Skipping system upgrade");
211+
}
212+
213+
Ok(())
214+
}
215+
179216
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
180217
if let Some(sudo) = ctx.sudo() {
181-
ctx.run_type()
182-
.execute(&sudo)
183-
.args(&["/usr/bin/zypper", "refresh"])
184-
.check_run()?;
218+
ctx.run_type().execute(&sudo).args(&["zypper", "refresh"]).check_run()?;
185219

186220
ctx.run_type()
187221
.execute(&sudo)
188-
.args(&["/usr/bin/zypper", "dist-upgrade"])
222+
.args(&["zypper", "dist-upgrade"])
189223
.check_run()?;
190224
} else {
191225
print_warning("No sudo detected. Skipping system upgrade");
@@ -198,12 +232,12 @@ fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
198232
if let Some(sudo) = ctx.sudo() {
199233
ctx.run_type()
200234
.execute(&sudo)
201-
.args(&["/usr/bin/xbps-install", "-Su", "xbps"])
235+
.args(&["xbps-install", "-Su", "xbps"])
202236
.check_run()?;
203237

204238
ctx.run_type()
205239
.execute(&sudo)
206-
.args(&["/usr/bin/xbps-install", "-u"])
240+
.args(&["xbps-install", "-u"])
207241
.check_run()?;
208242
} else {
209243
print_warning("No sudo detected. Skipping system upgrade");
@@ -223,7 +257,7 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
223257
println!("Syncing portage");
224258
run_type
225259
.execute(&sudo)
226-
.args(&["/usr/bin/emerge", "--sync"])
260+
.args(&["emerge", "--sync"])
227261
.args(
228262
ctx.config()
229263
.emerge_sync_flags()
@@ -238,7 +272,7 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
238272

239273
run_type
240274
.execute(&sudo)
241-
.arg("/usr/bin/emerge")
275+
.arg("emerge")
242276
.args(
243277
ctx.config()
244278
.emerge_update_flags()
@@ -255,7 +289,7 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
255289

256290
fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
257291
if let Some(sudo) = &ctx.sudo() {
258-
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("/usr/bin/apt-get"));
292+
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("apt-get"));
259293
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
260294

261295
let mut command = ctx.run_type().execute(&sudo);
@@ -287,10 +321,7 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
287321

288322
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
289323
if let Some(sudo) = ctx.sudo() {
290-
ctx.run_type()
291-
.execute(&sudo)
292-
.args(&["/usr/bin/eopkg", "upgrade"])
293-
.check_run()?;
324+
ctx.run_type().execute(&sudo).args(&["eopkg", "upgrade"]).check_run()?;
294325
} else {
295326
print_warning("No sudo detected. Skipping system upgrade");
296327
}
@@ -314,10 +345,7 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
314345

315346
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
316347
if let Some(sudo) = &ctx.sudo() {
317-
ctx.run_type()
318-
.execute(&sudo)
319-
.args(&["/usr/bin/swupd", "update"])
320-
.check_run()?;
348+
ctx.run_type().execute(&sudo).args(&["swupd", "update"]).check_run()?;
321349
} else {
322350
print_warning("No sudo detected. Skipping system upgrade");
323351
}
@@ -327,31 +355,28 @@ fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
327355

328356
fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
329357
if let Some(sudo) = ctx.sudo() {
330-
ctx.run_type()
331-
.execute(&sudo)
332-
.args(&["/usr/bin/cave", "sync"])
333-
.check_run()?;
358+
ctx.run_type().execute(&sudo).args(&["cave", "sync"]).check_run()?;
334359

335360
ctx.run_type()
336361
.execute(&sudo)
337-
.args(&["/usr/bin/cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
362+
.args(&["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
338363
.check_run()?;
339364

340365
if ctx.config().cleanup() {
341366
ctx.run_type()
342367
.execute(&sudo)
343-
.args(&["/usr/bin/cave", "purge", "-x"])
368+
.args(&["cave", "purge", "-x"])
344369
.check_run()?;
345370
}
346371

347372
ctx.run_type()
348373
.execute(&sudo)
349-
.args(&["/usr/bin/cave", "fix-linkage", "-x", "--", "-Cs"])
374+
.args(&["cave", "fix-linkage", "-x", "--", "-Cs"])
350375
.check_run()?;
351376

352377
ctx.run_type()
353378
.execute(&sudo)
354-
.args(&["/usr/bin/eclectic", "config", "interactive"])
379+
.args(&["eclectic", "config", "interactive"])
355380
.check_run()?;
356381
} else {
357382
print_warning("No sudo detected. Skipping system upgrade");

0 commit comments

Comments
 (0)