From cf377f18ae255f7272fb72c6730f3749b7f083c2 Mon Sep 17 00:00:00 2001 From: Ast-x64 Date: Fri, 19 Nov 2021 15:16:10 +0800 Subject: [PATCH] addpkg: libredefender --- libredefender/fix_ptrace_enum.patch | 54 +++++++++++++++++++++++++++++ libredefender/fix_type.patch | 40 +++++++++++++++++++++ libredefender/riscv64.patch | 31 +++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 libredefender/fix_ptrace_enum.patch create mode 100644 libredefender/fix_type.patch create mode 100644 libredefender/riscv64.patch diff --git a/libredefender/fix_ptrace_enum.patch b/libredefender/fix_ptrace_enum.patch new file mode 100644 index 000000000..4c649af4b --- /dev/null +++ b/libredefender/fix_ptrace_enum.patch @@ -0,0 +1,54 @@ +diff --git a/linux.rs b/linux.rs +index ba0e614..662425a 100644 +--- a/linux.rs ++++ b/linux.rs +@@ -46,7 +46,6 @@ libc_enum!{ + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", +- target_arch = "riscv64", + target_pointer_width = "32"))))] + PTRACE_GETREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), +@@ -54,7 +53,6 @@ libc_enum!{ + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", +- target_arch = "riscv64", + target_pointer_width = "32"))))] + PTRACE_SETREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), +@@ -62,7 +60,6 @@ libc_enum!{ + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", +- target_arch = "riscv64", + target_pointer_width = "32"))))] + PTRACE_GETFPREGS, + #[cfg(any(all(target_os = "android", target_pointer_width = "32"), +@@ -70,7 +67,6 @@ libc_enum!{ + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86_64", +- target_arch = "riscv64", + target_pointer_width = "32"))))] + PTRACE_SETFPREGS, + PTRACE_ATTACH, +@@ -79,15 +75,13 @@ libc_enum!{ + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86", +- target_arch = "x86_64", +- target_arch = "riscv64")))] ++ target_arch = "x86_64")))] + PTRACE_GETFPXREGS, + #[cfg(all(target_os = "linux", any(target_env = "musl", + target_arch = "mips", + target_arch = "mips64", + target_arch = "x86", +- target_arch = "x86_64", +- target_arch = "riscv64")))] ++ target_arch = "x86_64")))] + PTRACE_SETFPXREGS, + PTRACE_SYSCALL, + PTRACE_SETOPTIONS, diff --git a/libredefender/fix_type.patch b/libredefender/fix_type.patch new file mode 100644 index 000000000..8acb54c8c --- /dev/null +++ b/libredefender/fix_type.patch @@ -0,0 +1,40 @@ +diff --git a/engine.rs b/engine.rs +index 5f2fe24..e26bc58 100644 +--- a/engine.rs ++++ b/engine.rs +@@ -78,7 +78,7 @@ pub struct Engine { + unsafe impl Send for Engine {} + unsafe impl Sync for Engine {} + +-fn map_scan_result(result: cl_error_t, virname: *const i8) -> Result { ++fn map_scan_result(result: cl_error_t, virname: *const u8) -> Result { + match result { + cl_error_t::CL_CLEAN => Ok(ScanResult::Clean), + cl_error_t::CL_BREAK => Ok(ScanResult::Whitelisted), +@@ -231,7 +231,7 @@ impl Engine { + pub fn scan_file(&self, path: &str, settings: &mut ScanSettings) -> Result { + let raw_path = CString::new(path).unwrap(); + unsafe { +- let mut virname: *const i8 = ptr::null(); ++ let mut virname: *const u8 = ptr::null(); + let result = clamav_sys::cl_scanfile( + raw_path.as_ptr(), + &mut virname, +@@ -249,7 +249,7 @@ impl Engine { + /// loaded and compiled. + pub fn scan_descriptor(&self, descriptor: i32, settings: &mut ScanSettings, filename: Option< &str >) -> Result { + unsafe { +- let mut virname: *const i8 = ptr::null(); ++ let mut virname: *const u8 = ptr::null(); + let filename_cstr = filename.map(|x| CString::new(x).expect("CString::new failed")); + let mut scanned : c_ulong = 0; + let result = clamav_sys::cl_scandesc( +@@ -283,7 +283,7 @@ impl Engine { + /// @param engine The scanning engine. + /// @param scanoptions The scanning options. + pub fn scan_map(&self, map : & Fmap, filename: Option<&str>, settings: &mut ScanSettings) -> Result { +- let mut virname: *const i8 = ptr::null(); ++ let mut virname: *const u8 = ptr::null(); + let c_filename = filename.map(|n| CString::new(n).expect("CString::new failed")); + let result = unsafe { + clamav_sys::cl_scanmap_callback( diff --git a/libredefender/riscv64.patch b/libredefender/riscv64.patch new file mode 100644 index 000000000..30a1ca6e2 --- /dev/null +++ b/libredefender/riscv64.patch @@ -0,0 +1,31 @@ +diff --git PKGBUILD PKGBUILD +index b090525a..ac8da04d 100644 +--- PKGBUILD ++++ PKGBUILD +@@ -10,15 +10,23 @@ license=('GPL2') + depends=('libclamav.so' 'hicolor-icon-theme') + makedepends=('cargo' 'clang') + source=(https://github.com/kpcyrd/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz +- https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc) ++ https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc ++ fix_ptrace_enum.patch ++ fix_type.patch) + b2sums=('ae67c49a464d33249f1d11bd32eaa827c0f1410021ce5638eda8a522d0ec70100b07d817559bbda6ba6e90cb6c3f55824b763076e8b7cf5c81f25a29dee95d9a' +- 'SKIP') ++ 'SKIP' ++ 'cf82f590fcdf3b98c62a8494e685d8e1e53a7009e5361be91e8c480a55af7040dbbdf2ede22f49a5cbb027be37b75e225a7da37a4110d2c4d3165bb51ef75ddd' ++ '9226d72280a7b408575cb6789193ed61f1861e5c465510a7b1bf555e238f482e73b645d50d3b5d03dd6d7afe96fb975ba73ef6fd5accca3df0d2204c0ea75a6d') + + validpgpkeys=("64B13F7117D6E07D661BBCE0FE763A64F5E54FD6") + + prepare() { + cd "${pkgname}-${pkgver}" +- cargo fetch --locked --target "$CARCH-unknown-linux-gnu" ++ cargo fetch --locked --target "riscv64gc-unknown-linux-gnu" ++ cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.17.0/src/sys/ptrace ++ patch -Np1 -i "${srcdir}/fix_ptrace_enum.patch" ++ cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/clamav-rs-0.5.5/src ++ patch -Np1 -i "${srcdir}/fix_type.patch" + } + + build() {