diff --git a/common/src/apt/repositories.rs b/common/src/apt/repositories.rs index 72a240e1..aff35224 100644 --- a/common/src/apt/repositories.rs +++ b/common/src/apt/repositories.rs @@ -1,4 +1,89 @@ #[perlmod::package(name = "Proxmox::RS::APT::Repositories")] pub mod export { + use anyhow::Error; + + use proxmox_apt_api_types::{ + APTChangeRepositoryOptions, APTGetChangelogOptions, APTRepositoriesResult, + APTRepositoryHandle, APTUpdateInfo, APTUpdateOptions, + }; + use proxmox_config_digest::ConfigDigest; + + /// Get information about configured repositories and standard repositories for `product`. + #[export] + pub fn repositories(product: &str) -> Result { + proxmox_apt::list_repositories(product) + } + + /// Add the repository identified by the `handle` and `product`. + /// If the repository is already configured, it will be set to enabled. + /// + /// The `digest` parameter asserts that the configuration has not been modified. + #[export] + pub fn add_repository( + handle: APTRepositoryHandle, + product: &str, + digest: Option, + ) -> Result<(), Error> { + proxmox_apt::add_repository_handle(product, handle, digest) + } + + /// Change the properties of the specified repository. + /// + /// The `digest` parameter asserts that the configuration has not been modified. + #[export] + pub fn change_repository( + path: &str, + index: usize, + options: APTChangeRepositoryOptions, + digest: Option, + ) -> Result<(), Error> { + proxmox_apt::change_repository(path, index, &options, digest) + } + + /// Retrieve the changelog of the specified package. + #[export] + pub fn get_changelog(options: APTGetChangelogOptions) -> Result { + proxmox_apt::get_changelog(&options) + } + + /// List available APT updates + /// + /// Automatically updates an expired package cache. + #[export] + pub fn list_available_apt_update(apt_state_file: &str) -> Result, Error> { + proxmox_apt::list_available_apt_update(apt_state_file) + } + + /// Update the APT database + /// + /// You should update the APT proxy configuration before running this. + #[export] + pub fn update_database(apt_state_file: &str, options: APTUpdateOptions) -> Result<(), Error> { + proxmox_apt::update_database( + apt_state_file, + &options, + |updates: &[&APTUpdateInfo]| -> Result<(), Error> { + // fixme: howto send notifgications? + crate::send_updates_available(updates)?; + Ok(()) + }, + ) + } + + /// Get package information for a list of important product packages. + #[export] + pub fn get_package_versions( + product_virtual_package: &str, + api_server_package: &str, + running_api_server_version: &str, + package_list: Vec<&str>, + ) -> Result, Error> { + proxmox_apt::get_package_versions( + product_virtual_package, + api_server_package, + running_api_server_version, + &package_list, + ) + } } diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 5c892758..72d548d8 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -31,7 +31,7 @@ url = "2" perlmod = { version = "0.13", features = ["exporter"] } -#proxmox-apt = { version = "0.11", features = ["cache"] } +proxmox-apt = { version = "0.11", features = ["cache"] } proxmox-apt-api-types = "1.0" proxmox-config-digest = "0.1" proxmox-http = { version = "0.9", features = ["client-sync", "client-trait"] }