Skip to content

Commit

Permalink
Finishing copying in code from ocipkg.
Browse files Browse the repository at this point in the history
  • Loading branch information
macklin-10x committed Apr 24, 2024
1 parent 50091fb commit 7abf75c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions intel-mkl-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ mkl-dynamic-ilp64-seq = []
[build-dependencies]
anyhow = "1.0.58"
ocipkg = "0.2.8"
flate2 = "1.0.28"
log = "0.4.21"
tar = "0.4.40"

[build-dependencies.intel-mkl-tool]
path = "../intel-mkl-tool"
Expand Down
19 changes: 16 additions & 3 deletions intel-mkl-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

use anyhow::Result;
use intel_mkl_tool::*;
use ocipkg::{distribution, local, ImageName};
use ocipkg::{
distribution::{get_layer_bytes, MediaType},
ImageName,
};
use std::{env, fs, path::PathBuf, str::FromStr};

macro_rules! def_mkl_config {
Expand Down Expand Up @@ -96,7 +99,6 @@ fn link_package(image_name: &str) -> Result<()> {
let image_name = ImageName::parse(image_name)?;

let mut dir = PathBuf::from(env::var("OUT_DIR").unwrap());
dir.push("ocipkg");
if let Some(port) = image_name.port {
dir.push(format!("{}__{}", image_name.hostname, port));
} else {
Expand All @@ -106,7 +108,18 @@ fn link_package(image_name: &str) -> Result<()> {
dir.push(format!("__{}", image_name.reference));

if !dir.exists() {
distribution::get_image(&image_name)?;
let blob = get_layer_bytes(&image_name, |media_type| {
match media_type {
MediaType::ImageLayerGzip => true,
// application/vnd.docker.image.rootfs.diff.tar.gzip case
MediaType::Other(ty) if ty.ends_with("tar.gzip") => true,
_ => false,
}
})?;
let buf = flate2::read::GzDecoder::new(blob.as_slice());

log::info!("Get {} into {}", image_name, dir.display());
tar::Archive::new(buf).unpack(&dir)?;
}
println!("cargo:rustc-link-search={}", dir.display());
for path in fs::read_dir(&dir)?.filter_map(|entry| {
Expand Down

0 comments on commit 7abf75c

Please sign in to comment.