6 releases (breaking)
0.5.1 | Feb 14, 2023 |
---|---|
0.5.0 | Feb 13, 2023 |
0.4.1 | Sep 1, 2022 |
0.3.0 | Jul 1, 2022 |
0.1.0 | May 6, 2022 |
#82 in Operating systems
108 downloads per month
Used in 4 crates
(3 directly)
125KB
2K
SLoC
RUST-APT
rust-apt
provides bindings to libapt-pkg
.
Currently there is only basic package querying.
The goal is to eventually have all of the functionality that python-apt
has.
This Crate is Under Active Development
This API is far from what could be considered stable. If you plan on using it in a real project make sure to pin the exact version. Breaking changes will be frequent and potentially unnannouned as the API comes together.
Each module has a raw
submodule containing c++ bindings to libapt-pkg
.
These are safe to use in terms of memory, but may cause segfaults if you do something wrong.
If you find a way to segfault without using the libapt-pkg
bindings directly, please report this as a bug.
Documentation and Examples
For more instructions on how to use rust-apt
see our crates.io page.
Getting packages
The cache.packages()
method is an iterator of all packages that can be sorted with the PackageSort
struct.
Here is how you could iterate over packages that are upgradable.
They will also be sorted by name using the .names()
method on PackageSort
use rust_apt::cache::{Cache, PackageSort};
let cache = Cache::new();
let sort = PackageSort::default().upgradable().names();
for pkg in cache.packages(&sort) {
println!(
"Package: {} {} is upgradable to {}",
pkg.name(),
pkg.installed().unwrap().version(),
pkg.candidate().unwrap().version(),
);
}
License Note
This crate is licensed under the GPLv3 or later.
Building
libapt-pkg-dev
must be installed.
Thread safety
It is not advised to use this crate in multiple threads.
You're free to try it but development will not be focused on making this crate thread safe.
Development
Make sure cargo
and rustup
are installed before you run the following commands.
You will need the stable and nightly toolchain. Nightly is only used for rustfmt
.
Install just
, a command runner we use to simplify some tasks.
cargo install just
Now that cargo
and just
are installed, You can setup your dev environment.
setup-dev
will:
-
Install the necessary dependencies with
apt
. -
Ensure the proper toolchains are installed with
rustup
. -
Create
compile_commands.json
withbear
for better c++ linting
just setup-dev
Before you commit, check formatting and basic code QA.
just fmt
just check
Dependencies
~0.6–1.5MB
~29K SLoC