diff --git a/.gitignore b/.gitignore index 90607fd..0a2adc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /libbpf-cargo-0.7.1.crate /libbpf-cargo-0.7.2.crate /libbpf-cargo-0.8.1.crate +/libbpf-cargo-0.9.2.crate diff --git a/libbpf-cargo-fix-metadata.diff b/libbpf-cargo-fix-metadata.diff new file mode 100644 index 0000000..b37dc9c --- /dev/null +++ b/libbpf-cargo-fix-metadata.diff @@ -0,0 +1,10 @@ +--- libbpf-cargo-0.9.2/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ libbpf-cargo-0.9.2/Cargo.toml 2021-10-14T20:31:08.630116+00:00 +@@ -74,6 +74,7 @@ + version = "0.2" + + [features] ++default = ["novendor"] + novendor = ["libbpf-sys/novendor"] + [badges.maintenance] + status = "actively-developed" diff --git a/libbpf-cargo-novendor.patch b/libbpf-cargo-novendor.patch deleted file mode 100644 index 9d9864d..0000000 --- a/libbpf-cargo-novendor.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff -Naur a/Cargo.toml b/Cargo.toml ---- a/Cargo.toml 1969-12-31 16:00:00.000000000 -0800 -+++ b/Cargo.toml 2021-07-29 14:53:18.250244180 -0700 -@@ -26,6 +26,10 @@ - [lib] - path = "src/lib.rs" - -+[features] -+default = ["novendor"] -+novendor = ["libbpf-sys/novendor"] -+ - [[bin]] - name = "cargo-libbpf" - path = "src/main.rs" -diff -Naur a/src/build.rs b/src/build.rs ---- a/src/build.rs 1969-12-31 16:00:00.000000000 -0800 -+++ b/src/build.rs 2021-07-29 14:52:48.099107574 -0700 -@@ -1,7 +1,5 @@ - use std::collections::HashSet; - use std::fs; --use std::fs::OpenOptions; --use std::io::Write; - use std::path::{Path, PathBuf}; - use std::process::Command; - -@@ -47,7 +45,11 @@ - /// Extract vendored libbpf header files to a temporary directory. - /// - /// Directory and enclosed contents will be removed when return object is dropped. --fn extract_libbpf_headers_to_disk() -> Result { -+#[cfg(not(feature = "novendor"))] -+fn extract_libbpf_headers_to_disk() -> Result> { -+ use std::fs::OpenOptions; -+ use std::io::Write; -+ - let tempdir = TempDir::new()?; - let dir = tempdir.path().join("bpf"); - fs::create_dir_all(&dir)?; -@@ -57,7 +59,12 @@ - file.write_all(contents.as_bytes())?; - } - -- Ok(tempdir) -+ Ok(Some(tempdir)) -+} -+ -+#[cfg(feature = "novendor")] -+fn extract_libbpf_headers_to_disk() -> Result> { -+ return Ok(None); - } - - fn check_clang(debug: bool, clang: &Path, skip_version_checks: bool) -> Result<()> { -@@ -148,7 +155,11 @@ - - fn compile(debug: bool, objs: &[UnprocessedObj], clang: &Path) -> Result<()> { - let header_dir = extract_libbpf_headers_to_disk()?; -- let compiler_options = format!("-I{}", header_dir.path().to_str().unwrap()); -+ let compiler_options = if let Some(dir) = &header_dir { -+ format!("-I{}", dir.path().to_str().unwrap()) -+ } else { -+ "".to_string() -+ }; - - for obj in objs { - let dest_name = if let Some(f) = obj.path.file_stem() { -@@ -222,7 +233,11 @@ - let clang = extract_clang_or_default(clang); - check_clang(debug, &clang, skip_clang_version_checks)?; - let header_dir = extract_libbpf_headers_to_disk()?; -- let compiler_options = format!("{} -I{}", options, header_dir.path().to_str().unwrap()); -+ let compiler_options = if let Some(dir) = &header_dir { -+ format!("{} -I{}", options, dir.path().to_str().unwrap()) -+ } else { -+ options.to_string() -+ }; - compile_one(debug, source, out, &clang, &compiler_options)?; - - Ok(()) diff --git a/rust-libbpf-cargo.spec b/rust-libbpf-cargo.spec index ce5b307..5dfa654 100644 --- a/rust-libbpf-cargo.spec +++ b/rust-libbpf-cargo.spec @@ -4,7 +4,7 @@ %global crate libbpf-cargo Name: rust-%{crate} -Version: 0.8.1 +Version: 0.9.2 Release: %autorelease Summary: Cargo plugin to build bpf programs @@ -12,8 +12,8 @@ Summary: Cargo plugin to build bpf programs License: LGPLv2 or BSD URL: https://crates.io/crates/libbpf-cargo Source: %{crates_source} -# PR#125: libbpf-rs, libbpf-cargo: Support novendor feature -Patch0: libbpf-cargo-novendor.patch +# Turn on the novendor feature by default +Patch0: libbpf-cargo-fix-metadata.diff ExclusiveArch: %{rust_arches} %if %{__cargo_skip_build} diff --git a/sources b/sources index 835124e..51c81c5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (libbpf-cargo-0.8.1.crate) = 2eedf493e650aadfc4946fab1103dbc6491141d2a548cbaac328b61c9fae5dd46ca689ef8ee12d8848a996510fed7ed9bc22b0a34a21f2951a893003d17e12d6 +SHA512 (libbpf-cargo-0.9.2.crate) = 7ab7c4b46a8c44f5f69eb3779af8cbabb17a8dfc50fe6c226420b8fc7ba6a7f36ddc70e65fbeb9be4e51efc32abb8f01bf7a9343814b407f3a0737fedd06cce9