fix: debian without bindings
reimplemented parts of the Debian backend to get rid of the apt library that has a different version everywhere and therefore won't play nicely with our pacdef
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::Result;
|
||||
use rust_apt::cache::PackageSort;
|
||||
use rust_apt::new_cache;
|
||||
|
||||
use crate::backend::root::build_base_command_with_privileges;
|
||||
use crate::cmd::run_external_command;
|
||||
@@ -33,25 +33,21 @@ impl Backend for Debian {
|
||||
}
|
||||
|
||||
fn get_all_installed_packages(&self) -> Result<Packages> {
|
||||
let cache = new_cache!()?;
|
||||
let sort = PackageSort::default().installed();
|
||||
let mut cmd = Command::new("apt");
|
||||
cmd.args(&["list", "--installed"]);
|
||||
|
||||
let mut result = Packages::new();
|
||||
for pkg in cache.packages(&sort) {
|
||||
result.insert(Package::from(pkg.name().to_string()));
|
||||
}
|
||||
Ok(result)
|
||||
let output = String::from_utf8(cmd.output()?.stdout)?;
|
||||
|
||||
output_to_packages(output)
|
||||
}
|
||||
|
||||
fn get_explicitly_installed_packages(&self) -> Result<Packages> {
|
||||
let cache = new_cache!()?;
|
||||
let sort = PackageSort::default().installed().manually_installed();
|
||||
let mut cmd = Command::new("apt-mark");
|
||||
cmd.args(&["showmanual"]);
|
||||
|
||||
let mut result = Packages::new();
|
||||
for pkg in cache.packages(&sort) {
|
||||
result.insert(Package::from(pkg.name().to_string()));
|
||||
}
|
||||
Ok(result)
|
||||
let output = String::from_utf8(cmd.output()?.stdout)?;
|
||||
|
||||
output_to_packages(output)
|
||||
}
|
||||
|
||||
fn make_dependency(&self, packages: &Packages) -> Result<()> {
|
||||
@@ -101,3 +97,11 @@ impl Backend for Debian {
|
||||
run_external_command(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
fn output_to_packages(output: String) -> Result<Packages> {
|
||||
let mut result = Packages::new();
|
||||
for line in output.lines() {
|
||||
result.insert(Package::from(line));
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#[cfg(feature = "arch")]
|
||||
pub mod arch;
|
||||
#[cfg(feature = "debian")]
|
||||
pub mod debian;
|
||||
pub mod fedora;
|
||||
pub mod flatpak;
|
||||
|
||||
@@ -55,7 +55,6 @@ impl ManagedBackend {
|
||||
pub enum AnyBackend {
|
||||
#[cfg(feature = "arch")]
|
||||
Arch(actual::arch::Arch),
|
||||
#[cfg(feature = "debian")]
|
||||
Debian(actual::debian::Debian),
|
||||
Flatpak(Flatpak),
|
||||
Fedora(Fedora),
|
||||
@@ -70,7 +69,6 @@ impl AnyBackend {
|
||||
vec![
|
||||
#[cfg(feature = "arch")]
|
||||
Self::Arch(actual::arch::Arch::new(config)),
|
||||
#[cfg(feature = "debian")]
|
||||
Self::Debian(actual::debian::Debian::new()),
|
||||
Self::Flatpak(Flatpak::new(config)),
|
||||
Self::Fedora(Fedora::new()),
|
||||
@@ -86,7 +84,6 @@ impl AnyBackend {
|
||||
match section {
|
||||
#[cfg(feature = "arch")]
|
||||
"arch" => Ok(Self::Arch(actual::arch::Arch::new(config))),
|
||||
#[cfg(feature = "debian")]
|
||||
"debian" => Ok(Self::Debian(actual::debian::Debian::new())),
|
||||
"flatpak" => Ok(Self::Flatpak(Flatpak::new(config))),
|
||||
"fedora" => Ok(Self::Fedora(Fedora::new())),
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::{ensure, Context, Result};
|
||||
use anyhow::{Context, Result, ensure};
|
||||
|
||||
use crate::env::{get_editor, should_print_debug_info};
|
||||
|
||||
|
||||
+2
-3
@@ -1,14 +1,13 @@
|
||||
pub use crate::backend::AnyBackend;
|
||||
pub use crate::backend::ManagedBackend;
|
||||
#[cfg(feature = "arch")]
|
||||
pub use crate::backend::actual::arch::Arch;
|
||||
#[cfg(feature = "debian")]
|
||||
pub use crate::backend::actual::debian::Debian;
|
||||
pub use crate::backend::actual::{
|
||||
fedora::Fedora, flatpak::Flatpak, python::Python, rust::Rust, rustup::Rustup, void::Void,
|
||||
};
|
||||
pub use crate::backend::backend_trait::{Backend, BackendInfo, Switches, Text};
|
||||
pub use crate::backend::todo_per_backend::ToDoPerBackend;
|
||||
pub use crate::backend::AnyBackend;
|
||||
pub use crate::backend::ManagedBackend;
|
||||
pub use crate::cli::CleanPackageAction;
|
||||
pub use crate::cli::EditGroupAction;
|
||||
pub use crate::cli::ExportGroupAction;
|
||||
|
||||
Reference in New Issue
Block a user