[pve-devel] [PATCH perl-rs 3/5] perl-rs: add further apt api calls
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Jul 9 08:20:24 CEST 2024
From: Dietmar Maurer <dietmar at proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
common/src/apt/repositories.rs | 49 +++++++++++++++++++++++++++++++++-
pmg-rs/Cargo.toml | 2 +-
pve-rs/Cargo.toml | 2 +-
pve-rs/src/lib.rs | 2 +-
4 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/common/src/apt/repositories.rs b/common/src/apt/repositories.rs
index 61824d7..ccf4f33 100644
--- a/common/src/apt/repositories.rs
+++ b/common/src/apt/repositories.rs
@@ -4,7 +4,8 @@ pub mod export {
use anyhow::Error;
use proxmox_apt_api_types::{
- APTChangeRepositoryOptions, APTRepositoriesResult, APTRepositoryHandle,
+ APTChangeRepositoryOptions, APTGetChangelogOptions, APTRepositoriesResult,
+ APTRepositoryHandle, APTUpdateInfo, APTUpdateOptions,
};
use proxmox_config_digest::ConfigDigest;
@@ -39,4 +40,50 @@ pub mod export {
) -> 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<String, Error> {
+ 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<Vec<APTUpdateInfo>, 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?
+ 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<String>,
+ ) -> Result<Vec<APTUpdateInfo>, Error> {
+ let package_list: Vec<&str> = package_list.iter().map(|s| s.as_ref()).collect();
+ proxmox_apt::get_package_versions(
+ product_virtual_package,
+ api_server_package,
+ running_api_server_version,
+ &package_list,
+ )
+ }
}
diff --git a/pmg-rs/Cargo.toml b/pmg-rs/Cargo.toml
index ad3a107..2706fcb 100644
--- a/pmg-rs/Cargo.toml
+++ b/pmg-rs/Cargo.toml
@@ -29,7 +29,7 @@ url = "2"
perlmod = { version = "0.13.4", features = ["exporter"] }
proxmox-acme = { version = "0.5", features = ["client", "api-types"] }
-proxmox-apt = "0.11"
+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"] }
diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml
index ce7059d..3ba649e 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 = "0.11"
+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"] }
diff --git a/pve-rs/src/lib.rs b/pve-rs/src/lib.rs
index 42be39e..73780f8 100644
--- a/pve-rs/src/lib.rs
+++ b/pve-rs/src/lib.rs
@@ -17,6 +17,6 @@ mod export {
#[export]
pub fn init() {
common::logger::init("PVE_LOG", "info");
- proxmox_notify::context::set_context(&PVE_CONTEXT)
+ proxmox_notify::context::set_context(&PVE_CONTEXT);
}
}
--
2.39.2
More information about the pve-devel
mailing list