git: 318ca527e27a - main - sysutils/onefetch: fix build on big-endian architectures

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Fri, 24 Jun 2022 18:38:54 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=318ca527e27ad9ca7e081d2fd1fa61a7aab4f0f3

commit 318ca527e27ad9ca7e081d2fd1fa61a7aab4f0f3
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2022-06-24 18:37:23 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2022-06-24 18:38:37 +0000

    sysutils/onefetch: fix build on big-endian architectures
    
    Backport
    https://github.com/image-rs/image/commit/ed8337afc795571795482882236acf14196e10db
    to fix build.
    
    Approved by:    Tier 2 blanket
---
 .../patch-cargo-crates_image-0.24.1_Cargo.toml     | 11 +++++++++++
 ...cargo-crates_image-0.24.1_src_codecs_openexr.rs | 11 +++++++++++
 .../patch-cargo-crates_image-0.24.1_src_image.rs   | 22 ++++++++++++++++++++++
 ...o-crates_image-0.24.1_src_io_free__functions.rs | 22 ++++++++++++++++++++++
 .../patch-cargo-crates_image-0.24.1_src_lib.rs     | 12 ++++++++++++
 5 files changed, 78 insertions(+)

diff --git a/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_Cargo.toml b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_Cargo.toml
new file mode 100644
index 000000000000..e91f7c00ee42
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_Cargo.toml
@@ -0,0 +1,11 @@
+--- cargo-crates/image-0.24.1/Cargo.toml.orig	1970-01-01 00:00:01 UTC
++++ cargo-crates/image-0.24.1/Cargo.toml
+@@ -59,7 +59,7 @@ optional = true
+ version = "0.4.0"
+ optional = true
+ 
+-[dependencies.exr]
++[target.'cfg(target_endian = "little")'.dependencies.exr]
+ version = "1.4.1"
+ optional = true
+ 
diff --git a/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_codecs_openexr.rs b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_codecs_openexr.rs
new file mode 100644
index 000000000000..a04173ae29c6
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_codecs_openexr.rs
@@ -0,0 +1,11 @@
+--- cargo-crates/image-0.24.1/src/codecs/openexr.rs.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/image-0.24.1/src/codecs/openexr.rs
+@@ -20,8 +20,6 @@
+ //!     - meta data is lost
+ //!     - dwaa/dwab compressed images not supported yet by the exr library
+ //!     - (chroma) subsampling not supported yet by the exr library
+-
+-extern crate exr;
+ use exr::prelude::*;
+ 
+ use crate::error::{DecodingError, EncodingError, ImageFormatHint};
diff --git a/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_image.rs b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_image.rs
new file mode 100644
index 000000000000..2086b1094162
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_image.rs
@@ -0,0 +1,22 @@
+--- cargo-crates/image-0.24.1/src/image.rs.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/image-0.24.1/src/image.rs
+@@ -290,7 +290,8 @@ pub enum ImageOutputFormat {
+     /// An Image in TGA Format
+     Tga,
+ 
+-    #[cfg(feature = "openexr")]
++    #[cfg(feature = "exr")]
++    #[cfg(target_endian = "little")]
+     /// An Image in OpenEXR Format
+     OpenExr,
+ 
+@@ -327,7 +328,8 @@ impl From<ImageFormat> for ImageOutputFormat {
+             ImageFormat::Farbfeld => ImageOutputFormat::Farbfeld,
+             #[cfg(feature = "tga")]
+             ImageFormat::Tga => ImageOutputFormat::Tga,
+-            #[cfg(feature = "openexr")]
++            #[cfg(feature = "exr")]
++            #[cfg(target_endian = "little")]
+             ImageFormat::OpenExr => ImageOutputFormat::OpenExr,
+             #[cfg(feature = "tiff")]
+             ImageFormat::Tiff => ImageOutputFormat::Tiff,
diff --git a/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_io_free__functions.rs b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_io_free__functions.rs
new file mode 100644
index 000000000000..07e2f2f5ff07
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_io_free__functions.rs
@@ -0,0 +1,22 @@
+--- cargo-crates/image-0.24.1/src/io/free_functions.rs.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/image-0.24.1/src/io/free_functions.rs
+@@ -72,7 +72,8 @@ pub(crate) fn load_decoder<R: BufRead + Seek, V: Decod
+         image::ImageFormat::Ico => visitor.visit_decoder(ico::IcoDecoder::new(r)?),
+         #[cfg(feature = "hdr")]
+         image::ImageFormat::Hdr => visitor.visit_decoder(hdr::HdrAdapter::new(BufReader::new(r))?),
+-        #[cfg(feature = "openexr")]
++        #[cfg(feature = "exr")]
++        #[cfg(target_endian = "little")]
+         image::ImageFormat::OpenExr => visitor.visit_decoder(openexr::OpenExrDecoder::new(r)?),
+         #[cfg(feature = "pnm")]
+         image::ImageFormat::Pnm => visitor.visit_decoder(pnm::PnmDecoder::new(r)?),
+@@ -230,7 +231,8 @@ pub(crate) fn write_buffer_impl<W: std::io::Write + Se
+         ImageOutputFormat::Tga => {
+             tga::TgaEncoder::new(buffered_write).write_image(buf, width, height, color)
+         }
+-        #[cfg(feature = "openexr")]
++        #[cfg(feature = "exr")]
++        #[cfg(target_endian = "little")]
+         ImageOutputFormat::OpenExr => {
+             openexr::OpenExrEncoder::new(buffered_write).write_image(buf, width, height, color)
+         }
diff --git a/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_lib.rs b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_lib.rs
new file mode 100644
index 000000000000..ed43d9f76a8e
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_image-0.24.1_src_lib.rs
@@ -0,0 +1,12 @@
+--- cargo-crates/image-0.24.1/src/lib.rs.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/image-0.24.1/src/lib.rs
+@@ -234,7 +234,8 @@ pub mod codecs {
+     pub mod ico;
+     #[cfg(feature = "jpeg")]
+     pub mod jpeg;
+-    #[cfg(feature = "openexr")]
++    #[cfg(feature = "exr")]
++    #[cfg(target_endian = "little")]
+     pub mod openexr;
+     #[cfg(feature = "png")]
+     pub mod png;