From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 43A951FF187 for ; Mon, 8 Sep 2025 17:04:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F22DA1577C; Mon, 8 Sep 2025 17:04:53 +0200 (CEST) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Mon, 8 Sep 2025 17:02:07 +0200 Message-ID: <20250908150224.155373-5-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250908150224.155373-1-f.schauer@proxmox.com> References: <20250908150224.155373-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1757343868410 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox-perl-rs v4 04/15] add Perl mapping for OCI container image parser/extractor X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Signed-off-by: Filip Schauer --- This patch depends on the proxmox-oci crate added in patch 02/15. Changed since v3: * improve rustdoc comments * parse_and_extract_image: add argument for CPU architecture Changed since v2: * rebase onto newest master (6132d4d36cbd) * forward all errors to Perl * remove oci-spec dependency Changed since v1: * rebase on latest master (3d9806cb3c7f) * add new dependencies to debian/control pve-rs/Cargo.toml | 1 + pve-rs/Makefile | 1 + pve-rs/debian/control | 1 + pve-rs/src/bindings/mod.rs | 3 +++ pve-rs/src/bindings/oci.rs | 29 +++++++++++++++++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 pve-rs/src/bindings/oci.rs diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 963031a..905c5c9 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -39,6 +39,7 @@ proxmox-http-error = "1" proxmox-log = "1" proxmox-network-types = "0.1" proxmox-notify = { version = "1", features = ["pve-context"] } +proxmox-oci = "0.1.0" proxmox-openid = "1.0.2" proxmox-resource-scheduling = "1" proxmox-section-config = "3" diff --git a/pve-rs/Makefile b/pve-rs/Makefile index 13a5418..aa7181e 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -27,6 +27,7 @@ PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \ PERLMOD_PACKAGES := \ PVE::RS::Firewall::SDN \ + PVE::RS::OCI \ PVE::RS::OpenId \ PVE::RS::ResourceScheduling::Static \ PVE::RS::SDN::Fabrics \ diff --git a/pve-rs/debian/control b/pve-rs/debian/control index d0b1af6..091406b 100644 --- a/pve-rs/debian/control +++ b/pve-rs/debian/control @@ -25,6 +25,7 @@ Build-Depends: cargo:native , librust-proxmox-log-1+default-dev, librust-proxmox-notify-1+default-dev (>= 0.5.4), librust-proxmox-notify-1+pve-context-dev, + librust-proxmox-oci-0.1+default-dev, librust-proxmox-openid-1+default-dev (>= 1.0.2-~~), librust-proxmox-resource-scheduling-1+default-dev, librust-proxmox-shared-cache-1+default-dev, diff --git a/pve-rs/src/bindings/mod.rs b/pve-rs/src/bindings/mod.rs index 7730de3..c21b328 100644 --- a/pve-rs/src/bindings/mod.rs +++ b/pve-rs/src/bindings/mod.rs @@ -1,5 +1,8 @@ //! This contains all the perl bindings. +mod oci; +pub use oci::pve_rs_oci; + mod resource_scheduling_static; pub use resource_scheduling_static::pve_rs_resource_scheduling_static; diff --git a/pve-rs/src/bindings/oci.rs b/pve-rs/src/bindings/oci.rs new file mode 100644 index 0000000..7f5acaf --- /dev/null +++ b/pve-rs/src/bindings/oci.rs @@ -0,0 +1,29 @@ +#[perlmod::package(name = "PVE::RS::OCI", lib = "pve_rs")] +pub mod pve_rs_oci { + //! The `PVE::RS::OCI` package. + //! + //! Provides bindings for the [`proxmox_oci`] crate. + + use anyhow::Error; + use proxmox_oci::Config; + + /// Extract the rootfs of an OCI image tar and return the image config. + /// + /// # Arguments + /// + /// * `oci_tar_path` - Path to the OCI image tar archive + /// * `rootfs_path` - Destination path where the rootfs will be extracted to + /// * `arch` - Optional CPU architecture used to pick the first matching manifest from a multi-arch + /// image index. If `None`, the first manifest will be used. + #[export] + pub fn parse_and_extract_image( + oci_tar_path: &str, + rootfs_path: &str, + arch: Option<&str>, + ) -> Result { + let arch = arch.map(Into::into); + proxmox_oci::parse_and_extract_image(oci_tar_path, rootfs_path, arch.as_ref()) + .map(|config| config.unwrap_or_default()) + .map_err(Into::into) + } +} -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel