all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-perl-rs v5 04/17] add Perl mapping for OCI container image parser/extractor
Date: Wed,  8 Oct 2025 19:10:10 +0200	[thread overview]
Message-ID: <20251008171028.196998-5-f.schauer@proxmox.com> (raw)
In-Reply-To: <20251008171028.196998-1-f.schauer@proxmox.com>

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
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 e40c55c..8d87399 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 e5c2fc8..4b892a8 100644
--- a/pve-rs/debian/control
+++ b/pve-rs/debian/control
@@ -28,6 +28,7 @@ Build-Depends: cargo:native <!nocheck>,
                librust-proxmox-network-types-0.1+default-dev,
                librust-proxmox-notify-1+default-dev,
                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-section-config-3+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<Config, Error> {
+        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.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-10-08 17:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 17:10 [pve-devel] [PATCH container/docs/manager/proxmox{, -perl-rs}/storage v5 00/17] support OCI images as container templates Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH proxmox v5 01/17] io: introduce RangeReader for bounded reads Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH proxmox v5 02/17] add proxmox-oci crate Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH proxmox v5 03/17] proxmox-oci: add tests for whiteout handling Filip Schauer
2025-10-08 17:10 ` Filip Schauer [this message]
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 05/17] config: add `lxc.environment.runtime`/`hooks` Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 06/17] add support for OCI images as container templates Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 07/17] config: add entrypoint parameter Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 08/17] configure static IP in LXC config for custom entrypoint Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 09/17] setup: debian: create /etc/network path if missing Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 10/17] setup: recursively mkdir /etc/systemd/{network, system-preset} Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH container v5 11/17] implement host-managed DHCP for containers with `ipmanagehost` Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH storage v5 12/17] allow .tar container templates Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH storage v5 13/17] api: add storage/{storage}/oci-registry-pull method Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH manager v5 14/17] ui: storage upload: accept *.tar files as vztmpl Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH manager v5 15/17] api: add nodes/{node}/query-oci-repo-tags method Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH manager v5 16/17] ui: template view: add OCI registry pull dialog Filip Schauer
2025-10-08 17:10 ` [pve-devel] [PATCH docs v5 17/17] ct: add OCI image docs Filip Schauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251008171028.196998-5-f.schauer@proxmox.com \
    --to=f.schauer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal