diff mbox series

[bug#63065,v2,13/16] gnu: Add rust-reflink-0.1.

Message ID XNH5GMgt4nW6fRqeXsLGqPu_Sr7YJo1qu3hPkWsrP0-hI7eL_1lV9g7OWkbz6-SzjOotb3JbDoUfhED5zAOt_nO5j0MFsF9uB88NCBzxOVs=@proton.me
State New
Headers show
Series None | expand

Commit Message

Sughosha June 29, 2023, 10:25 a.m. UTC
* gnu/packages/crates-io.scm (rust-reflink-0.1): New variable.
* gnu/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch:
New patch file.
* gnu/local.mk: Register it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/crates-io.scm                    | 25 +++++++++++++++++++
 ...k-0.1-fix-64bit-toolchain-assumption.patch | 24 ++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 gnu/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e05602c4e5..dbb2143906 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1895,6 +1895,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/rust-nettle-disable-vendor.patch		 \
   %D%/packages/patches/rust-nettle-sys-disable-vendor.patch	 \
   %D%/packages/patches/rust-openssl-sys-no-vendor.patch	\
+  %D%/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch	\
   %D%/packages/patches/rust-webbrowser-remove-unsupported-os.patch	\
   %D%/packages/patches/rust-wl-clipboard-rs-newer-wl.patch      \
   %D%/packages/patches/rw-igraph-0.10.patch			\
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 315b1e8656..3874fddd09 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -49691,6 +49691,31 @@  (define-public rust-ref-cast-impl-0.2
         (base32
          "0av43xxjlinfqklb67rpj217cmaxfjsf8151gs0hbs4hnr5664ck"))))))
 
+(define-public rust-reflink-0.1
+  (package
+    (name "rust-reflink")
+    (version "0.1.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "reflink" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "1glcyqvryv2zj6kjbfji0cldrkincqx3ds3wjwl4qnsnig15wn5w"))
+       (patches
+        (search-patches
+          "rust-reflink-0.1-fix-64bit-toolchain-assumption.patch"))))
+    (build-system cargo-build-system)
+    (arguments
+     `(#:cargo-inputs
+       (("rust-libc" ,rust-libc-0.2)
+        ("rust-winapi" ,rust-winapi-0.3))))
+    (home-page "https://github.com/nicokoch/reflink")
+    (synopsis "Copy-on-write mechanism on supported file systems")
+    (description "This package provides copy-on-write mechanism on supported
+file systems.")
+    (license (list license:expat license:asl2.0))))
+
 (define-public rust-refpool-0.4
   (package
     (name "rust-refpool")
diff --git a/gnu/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch b/gnu/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch
new file mode 100644
index 0000000000..c16e1f720c
--- /dev/null
+++ b/gnu/packages/patches/rust-reflink-0.1-fix-64bit-toolchain-assumption.patch
@@ -0,0 +1,24 @@ 
+This patch fixes assuming a 64-bit toolchain.
+https://github.com/nicokoch/reflink/pull/5
+
+
+--- reflink-0.1.3/src/sys/unix.rs	2019-04-02 16:13:06.000000000 +0200
++++ "reflink-0.1.3 (Kopie)/src/sys/unix.rs"	2023-06-29 09:47:26.867681403 +0200
+@@ -7,7 +7,7 @@
+     use std::os::unix::io::AsRawFd;
+ 
+     // TODO is this equal on all archs? Just tested on x86_64 and x86.
+-    const IOCTL_FICLONE: u64 = 0x40049409;
++    macro_rules! IOCTL_FICLONE { () => (0x40049409) };
+ 
+     let src = fs::File::open(&from)?;
+ 
+@@ -18,7 +18,7 @@
+         .open(&to)?;
+     let ret = unsafe {
+         // http://man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.html
+-        libc::ioctl(dest.as_raw_fd(), IOCTL_FICLONE, src.as_raw_fd())
++        libc::ioctl(dest.as_raw_fd(), IOCTL_FICLONE!(), src.as_raw_fd())
+     };
+ 
+     if ret == -1 {