IN DEVELOPMENT
Storekit is still in development. Expect it to not work
Getting backends and the arch backend to work is our main focus right now. Expect debian/ubuntu and derivatives later.
Storekit is like packagekit, but better. It's a library, so not other processes running and no leaking memory in the background and it's easily extensible.
You send a message to the backend and the backend talks to your package manager to do what you want it to do.
Example:
use storekit;
fn main() {
set_backend(storekit::backends::arch);
send_message(storekit::Message::Install("sl"))
}- Arch (IN DEVELOPMENT!!!)
- needs libalpm bindings, then it's just doing the functions
- partial updates not allowed
-
Add a rust file in
src/backends/modules/, set its name to the id of your backend followed by.rs. -
Copy the following code:
pub struct Handler;
impl crate::Backend for Handler {
fn send_message(message: crate::Message) -> Result<(), String> {
// ...
// example: Ok(())
}
fn get_status() -> crate::BackendStatus {
// ...
// example: return crate::BackendStatus::Waiting;
}
}- Update the send_message() function to interact with your package manager:
- If you need to use the library of your package manager, write your own bindings. Avoid adding packages. Your bindings can be in
src/backends/bindings/yourModule.rs.- Do: Create your own binding file that uses the library of your package manager.
- Don't: Add a seperate package like
libaptand then use it.
- Never run commands to interface with the package manager if you don't have to. Use its library instead.
- Always use official libraries.
- Do: Use an official library, such as for Arch, use
libalpm
- Do: Use an official library, such as for Arch, use
- Do not use packagekit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- If you need to use the library of your package manager, write your own bindings. Avoid adding packages. Your bindings can be in
fn send_message(message: crate::Message) -> Result<(), crate::FailureReason> {
// replace the Ok(())'s with your code
return match message {
crate::Message::Install(_) => Ok(()),
crate::Message::Remove(_) => Ok(()),
crate::Message::Query(_) => Ok(()),
crate::Message::Upgrade(_) => Ok(()),
crate::Message::Sync() => Ok(()),
crate::Message::Clean() => Ok(()),
}
}- Add the get_status function (do not use
static mut!):
static mut currentStatus: crate::BackendStatus = crate::BackendStatus::Waiting;
impl crate::Backend for Handler {
fn send_message(message: crate::Message) -> Result<(), crate::FailureReason> {
// ...
// this will set status when doing an action
}
fn get_status() -> crate::BackendStatus {
return currentStatus;
}
}- Add your module to the
src/backends/modules/mod.rsfile:
// #[cfg(feature = "arch")]
// pub mod arch;
#[cfg(feature = "yourBackend")]
pub mod yourBackend;- Add your module to the
src/backends/mod.rsfile:
// #[cfg(feature = "arch")]
// pub use modules::arch::Handler as arch;
#[cfg(feature = "yourBackend")]
pub use modules::yourBackend::Handler as yourBackend;- Add your backend to the Cargo.toml:
[features]
# arch = []
# libalpm = []
yourBackend = []
# yourBindings = []
# ...- Done, now your backend is importable. It should be imported automatically by storekit.
Since you need to interact with libraries that are not written in rust, you need to create bindings.
This section does not cover on how to build bindings, but what you need to do after building one.
- Add your bindings to the Cargo.toml. Seperate the backends and bindings with spaces:
[features]
# arch = []
# libalpm = []
yourBackend = []
yourBindings = []- Add your bindings to the
src/backends/bindings/mod.rsfile:
#[cfg(feature = "yourBindings")]
pub mod yourBindings;- Done!
Storekit uses a build script, so you can select which backend to build:
% BACKEND=arch BINDS=libalpm cargo build
Builds with arch.rs backend and libalpm.rs bindings.
% BACKEND=null BINDS=null cargo build
Builds with null.rs backend and null.rs bindings.
Never partially update. Therefore, syncing is not recommended - Some backends also have features that prevent partial updates - Such as the Arch Linux backend.
