Skip to content

Commit

Permalink
fix(oma-pm): check dpkg --configure and dpkg --triggers-only exit…
Browse files Browse the repository at this point in the history
… status
  • Loading branch information
eatradish committed Feb 20, 2025
1 parent aed50c3 commit 7e6ba67
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions oma-pm/src/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,7 @@ impl OmaApt {
.spawn()
.map_err(OmaAptError::DpkgFailedConfigure)?;

if let Err(e) = cmd.wait_with_output() {
return Err(OmaAptError::DpkgFailedConfigure(io::Error::new(
ErrorKind::Other,
format!("dpkg return non-zero code: {:?}", e),
)));
}

Ok(())
dpkg_exit_status(cmd)
}

pub(crate) fn run_dpkg_triggers(&self) -> OmaAptResult<()> {
Expand All @@ -713,14 +706,7 @@ impl OmaApt {
.spawn()
.map_err(OmaAptError::DpkgFailedConfigure)?;

if let Err(e) = cmd.wait_with_output() {
return Err(OmaAptError::DpkgTriggers(io::Error::new(
ErrorKind::Other,
format!("dpkg return non-zero code: {:?}", e),
)));
}

Ok(())
dpkg_exit_status(cmd)
}

/// Get apt archive dir
Expand Down Expand Up @@ -1160,6 +1146,30 @@ impl OmaApt {
}
}

fn dpkg_exit_status(mut cmd: std::process::Child) -> Result<(), OmaAptError> {
match cmd.wait() {
Ok(status) => match status.code() {
Some(0) => Ok(()),
Some(x) => {
return Err(OmaAptError::DpkgFailedConfigure(io::Error::new(
ErrorKind::Other,
format!("dpkg return non-zero code: {}", x),
)))

Check warning on line 1157 in oma-pm/src/apt.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> oma-pm/src/apt.rs:1154:17 | 1154 | / return Err(OmaAptError::DpkgFailedConfigure(io::Error::new( 1155 | | ErrorKind::Other, 1156 | | format!("dpkg return non-zero code: {}", x), 1157 | | ))) | |___________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 1154 ~ Err(OmaAptError::DpkgFailedConfigure(io::Error::new( 1155 + ErrorKind::Other, 1156 + format!("dpkg return non-zero code: {}", x), 1157 + ))) |
}
None => {
return Err(OmaAptError::DpkgFailedConfigure(io::Error::new(
ErrorKind::Other,
"Could not get dpkg exit status",
)));

Check warning on line 1163 in oma-pm/src/apt.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> oma-pm/src/apt.rs:1160:17 | 1160 | / return Err(OmaAptError::DpkgFailedConfigure(io::Error::new( 1161 | | ErrorKind::Other, 1162 | | "Could not get dpkg exit status", 1163 | | ))); | |___________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 1160 ~ Err(OmaAptError::DpkgFailedConfigure(io::Error::new( 1161 + ErrorKind::Other, 1162 + "Could not get dpkg exit status", 1163 ~ ))) |
}
},
Err(e) => Err(OmaAptError::DpkgFailedConfigure(io::Error::new(
ErrorKind::Other,
e,
))),
}
}

fn get_package_url(cand: &Version<'_>) -> Vec<PackageUrl> {
let uri = cand
.version_files()
Expand Down

0 comments on commit 7e6ba67

Please sign in to comment.