From 2af7fa36f8a382645b8b0bf2053b3e48cc29d091 Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Mon, 22 May 2023 11:10:08 -0500 Subject: [PATCH] Initial Fedora package Signed-off-by: Michel Alexandre Salim --- .gitignore | 1 + 0001-Update-numtoa.patch | 104 +++++++++++++++++++++++++++++++++ rust-termion1.spec | 77 ++++++++++++++++++++++++ sources | 1 + termion-fix-metadata-auto.diff | 11 ++++ termion-fix-metadata.diff | 11 ++++ 6 files changed, 205 insertions(+) create mode 100644 .gitignore create mode 100644 0001-Update-numtoa.patch create mode 100644 rust-termion1.spec create mode 100644 sources create mode 100644 termion-fix-metadata-auto.diff create mode 100644 termion-fix-metadata.diff diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c3c51ab --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/termion-1.5.6.crate diff --git a/0001-Update-numtoa.patch b/0001-Update-numtoa.patch new file mode 100644 index 0000000..d542d80 --- /dev/null +++ b/0001-Update-numtoa.patch @@ -0,0 +1,104 @@ +From d80ab4617f79f68b85cc1d113250ad3d791a66d5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonathan=20Schleu=C3=9Fer?= +Date: Sat, 29 Dec 2018 17:15:18 +0100 +Subject: [PATCH] Update numtoa + +This now allows byte slices with lengths different than 20, so +specific lengths based on the biggest possible value for each +number can be used. +--- + src/color.rs | 8 ++++---- + src/cursor.rs | 10 +++++----- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/src/color.rs b/src/color.rs +index 6c543b69561f..6c0055b5e9e3 100644 +--- a/src/color.rs ++++ b/src/color.rs +@@ -125,14 +125,14 @@ impl AnsiValue { + impl AnsiValue { + /// Returns the ANSI sequence as a string. + pub fn fg_string(self) -> String { +- let mut x = [0u8; 20]; ++ let mut x = [0u8; 3]; + let x = self.0.numtoa_str(10, &mut x); + [csi!("38;5;"), x, "m"].concat() + } + + /// Returns the ANSI sequence as a string. + pub fn bg_string(self) -> String { +- let mut x = [0u8; 20]; ++ let mut x = [0u8; 3]; + let x = self.0.numtoa_str(10, &mut x); + [csi!("48;5;"), x, "m"].concat() + } +@@ -157,7 +157,7 @@ pub struct Rgb(pub u8, pub u8, pub u8); + impl Rgb { + /// Returns the ANSI sequence as a string. + pub fn fg_string(self) -> String { +- let (mut x, mut y, mut z) = ([0u8; 20], [0u8; 20], [0u8; 20]); ++ let (mut x, mut y, mut z) = ([0u8; 3], [0u8; 3], [0u8; 3]); + let (x, y, z) = ( + self.0.numtoa_str(10, &mut x), + self.1.numtoa_str(10, &mut y), +@@ -169,7 +169,7 @@ impl Rgb { + + /// Returns the ANSI sequence as a string. + pub fn bg_string(self) -> String { +- let (mut x, mut y, mut z) = ([0u8; 20], [0u8; 20], [0u8; 20]); ++ let (mut x, mut y, mut z) = ([0u8; 3], [0u8; 3], [0u8; 3]); + let (x, y, z) = ( + self.0.numtoa_str(10, &mut x), + self.1.numtoa_str(10, &mut y), +diff --git a/src/cursor.rs b/src/cursor.rs +index bbc039406746..8596c3f47fab 100644 +--- a/src/cursor.rs ++++ b/src/cursor.rs +@@ -36,7 +36,7 @@ pub struct Goto(pub u16, pub u16); + + impl From for String { + fn from(this: Goto) -> String { +- let (mut x, mut y) = ([0u8; 20], [0u8; 20]); ++ let (mut x, mut y) = ([0u8; 5], [0u8; 5]); + ["\x1B[", this.1.numtoa_str(10, &mut x), ";", this.0.numtoa_str(10, &mut y), "H"].concat() + } + } +@@ -60,7 +60,7 @@ pub struct Left(pub u16); + + impl From for String { + fn from(this: Left) -> String { +- let mut buf = [0u8; 20]; ++ let mut buf = [0u8; 5]; + ["\x1B[", this.0.numtoa_str(10, &mut buf), "D"].concat() + } + } +@@ -77,7 +77,7 @@ pub struct Right(pub u16); + + impl From for String { + fn from(this: Right) -> String { +- let mut buf = [0u8; 20]; ++ let mut buf = [0u8; 5]; + ["\x1B[", this.0.numtoa_str(10, &mut buf), "C"].concat() + } + } +@@ -94,7 +94,7 @@ pub struct Up(pub u16); + + impl From for String { + fn from(this: Up) -> String { +- let mut buf = [0u8; 20]; ++ let mut buf = [0u8; 5]; + ["\x1B[", this.0.numtoa_str(10, &mut buf), "A"].concat() + } + } +@@ -111,7 +111,7 @@ pub struct Down(pub u16); + + impl From for String { + fn from(this: Down) -> String { +- let mut buf = [0u8; 20]; ++ let mut buf = [0u8; 5]; + ["\x1B[", this.0.numtoa_str(10, &mut buf), "B"].concat() + } + } +-- +2.21.0 + diff --git a/rust-termion1.spec b/rust-termion1.spec new file mode 100644 index 0000000..023814b --- /dev/null +++ b/rust-termion1.spec @@ -0,0 +1,77 @@ +# Generated by rust2rpm 24 +# * tests can only be run on a real TTY +%bcond_with check +%global debug_package %{nil} + +%global crate termion + +Name: rust-termion1 +Version: 1.5.6 +Release: %autorelease +Summary: Bindless library for manipulating terminals + +License: MIT +URL: https://crates.io/crates/termion +Source: %{crates_source} +# Automatically generated patch to strip foreign dependencies +Patch: termion-fix-metadata-auto.diff +# Manually created patch for downstream crate metadata changes +# * bump numtoa from 0.1 to 0.2.3 +Patch: termion-fix-metadata.diff +# * port to numtoa 0.2: +# https://gitlab.redox-os.org/redox-os/termion/merge_requests/153 +Patch: 0001-Update-numtoa.patch + +BuildRequires: rust-packaging >= 21 + +%global _description %{expand: +A bindless library for manipulating terminals.} + +%description %{_description} + +%package devel +Summary: %{summary} +BuildArch: noarch + +%description devel %{_description} + +This package contains library source intended for building other packages which +use the "%{crate}" crate. + +%files devel +%license %{crate_instdir}/LICENSE +%doc %{crate_instdir}/README.md +%{crate_instdir}/ + +%package -n %{name}+default-devel +Summary: %{summary} +BuildArch: noarch + +%description -n %{name}+default-devel %{_description} + +This package contains library source intended for building other packages which +use the "default" feature of the "%{crate}" crate. + +%files -n %{name}+default-devel +%ghost %{crate_instdir}/Cargo.toml + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p1 +%cargo_prep + +%generate_buildrequires +%cargo_generate_buildrequires + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..675fb51 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (termion-1.5.6.crate) = 228b6fa7e2f280d6bfc7cef77e7a1d0d8f597178e66af0bde1b1fb6553857b511ba8a6786165815aac6d8a082fd37191f4ea35a47f1e1182f7f2c6086eb34a8c diff --git a/termion-fix-metadata-auto.diff b/termion-fix-metadata-auto.diff new file mode 100644 index 0000000..a4f2197 --- /dev/null +++ b/termion-fix-metadata-auto.diff @@ -0,0 +1,11 @@ +--- termion-1.5.6/Cargo.toml 1970-01-01T00:00:00+00:00 ++++ termion-1.5.6/Cargo.toml 2023-05-18T14:57:45.292786+00:00 +@@ -25,8 +25,3 @@ + features = ["std"] + [target."cfg(not(target_os = \"redox\"))".dependencies.libc] + version = "0.2" +-[target."cfg(target_os = \"redox\")".dependencies.redox_syscall] +-version = "0.2" +- +-[target."cfg(target_os = \"redox\")".dependencies.redox_termios] +-version = "0.1" diff --git a/termion-fix-metadata.diff b/termion-fix-metadata.diff new file mode 100644 index 0000000..c4d656e --- /dev/null +++ b/termion-fix-metadata.diff @@ -0,0 +1,11 @@ +--- termion-1.5.6/Cargo.toml 1970-01-01T00:00:00+00:00 ++++ termion-1.5.6/Cargo.toml 2023-05-18T14:57:50.801811+00:00 +@@ -21,7 +21,6 @@ + license = "MIT" + repository = "https://gitlab.redox-os.org/redox-os/termion" + [dependencies.numtoa] +-version = "0.1" +-features = ["std"] ++version = "0.2.3" + [target."cfg(not(target_os = \"redox\"))".dependencies.libc] + version = "0.2"