From 6becd1fb716d0c0918597ca653042f166da7b731 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Jun 09 2019 19:56:37 +0000 Subject: Switch to tempfile Signed-off-by: Igor Gnatenko --- diff --git a/0001-chore-Switch-from-tempdir-to-tempfile.patch b/0001-chore-Switch-from-tempdir-to-tempfile.patch new file mode 100644 index 0000000..332f97e --- /dev/null +++ b/0001-chore-Switch-from-tempdir-to-tempfile.patch @@ -0,0 +1,287 @@ +From 1abf458554788f6bc91e454b671ec4b41dc0eb44 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Sun, 9 Jun 2019 21:53:22 +0200 +Subject: [PATCH] chore: Switch from tempdir to tempfile + +Former is deprecated. + +Signed-off-by: Igor Gnatenko +--- + src/icon.rs | 18 +++++++++--------- + src/main.rs | 2 +- + src/meta/filetype.rs | 14 +++++++------- + src/meta/name.rs | 13 ++++++------- + src/sort.rs | 12 ++++++------ + 5 files changed, 29 insertions(+), 30 deletions(-) + +diff --git a/src/icon.rs b/src/icon.rs +index ac43e88..634fdd2 100644 +--- a/src/icon.rs ++++ b/src/icon.rs +@@ -311,11 +311,11 @@ mod test { + use super::{Icons, Theme, ICON_SPACE}; + use crate::meta::Meta; + use std::fs::File; +- use tempdir::TempDir; ++ use tempfile::tempdir; + + #[test] + fn get_no_icon() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path().join("file.txt"); + File::create(&file_path).expect("failed to create file"); + let meta = Meta::from_path(&file_path).unwrap(); +@@ -328,7 +328,7 @@ mod test { + + #[test] + fn get_default_file_icon() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path().join("file"); + File::create(&file_path).expect("failed to create file"); + let meta = Meta::from_path(&file_path).unwrap(); +@@ -341,7 +341,7 @@ mod test { + + #[test] + fn get_default_file_icon_unicode() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path().join("file"); + File::create(&file_path).expect("failed to create file"); + let meta = Meta::from_path(&file_path).unwrap(); +@@ -354,7 +354,7 @@ mod test { + + #[test] + fn get_directory_icon() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path(); + let meta = Meta::from_path(&file_path.to_path_buf()).unwrap(); + +@@ -366,7 +366,7 @@ mod test { + + #[test] + fn get_directory_icon_unicode() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path(); + let meta = Meta::from_path(&file_path.to_path_buf()).unwrap(); + +@@ -378,7 +378,7 @@ mod test { + + #[test] + fn get_directory_icon_with_ext() { +- let tmp_dir = TempDir::new("test_file_type.rs").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let file_path = tmp_dir.path(); + let meta = Meta::from_path(&file_path.to_path_buf()).unwrap(); + +@@ -390,7 +390,7 @@ mod test { + + #[test] + fn get_icon_by_name() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + for (file_name, file_icon) in &Icons::get_default_icons_by_name() { + let file_path = tmp_dir.path().join(file_name); +@@ -406,7 +406,7 @@ mod test { + + #[test] + fn get_icon_by_extension() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + for (ext, file_icon) in &Icons::get_default_icons_by_extension() { + let file_path = tmp_dir.path().join(format!("file.{}", ext)); +diff --git a/src/main.rs b/src/main.rs +index d826d84..87440b6 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -12,7 +12,7 @@ extern crate chrono_humanize; + extern crate libc; + extern crate lscolors; + #[cfg(test)] +-extern crate tempdir; ++extern crate tempfile; + extern crate term_grid; + extern crate terminal_size; + extern crate time; +diff --git a/src/meta/filetype.rs b/src/meta/filetype.rs +index d3b3b23..a031a08 100644 +--- a/src/meta/filetype.rs ++++ b/src/meta/filetype.rs +@@ -102,12 +102,12 @@ mod test { + use std::os::unix::net::UnixListener; + #[cfg(unix)] + use std::process::Command; +- use tempdir::TempDir; ++ use tempfile::tempdir; + + #[test] + #[cfg(unix)] // Windows uses different default permissions + fn test_file_type() { +- let tmp_dir = TempDir::new("test_file_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let file_path = tmp_dir.path().join("file.txt"); +@@ -122,7 +122,7 @@ mod test { + + #[test] + fn test_dir_type() { +- let tmp_dir = TempDir::new("test_dir_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let meta = + Meta::from_path(&tmp_dir.path().to_path_buf()).expect("failed to get tempdir path"); + let metadata = tmp_dir.path().metadata().expect("failed to get metas"); +@@ -136,7 +136,7 @@ mod test { + #[test] + #[cfg(unix)] // Symlink support is *hard* on Windows + fn test_symlink_type() { +- let tmp_dir = TempDir::new("test_symlink_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let file_path = tmp_dir.path().join("file.tmp"); +@@ -158,7 +158,7 @@ mod test { + #[test] + #[cfg(unix)] // Windows pipes aren't like Unix pipes + fn test_pipe_type() { +- let tmp_dir = TempDir::new("test_pipe_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the pipe; + let pipe_path = tmp_dir.path().join("pipe.tmp"); +@@ -179,7 +179,7 @@ mod test { + #[test] + #[cfg(feature = "sudo")] + fn test_char_device_type() { +- let tmp_dir = TempDir::new("test_char_device_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the char device; + let char_device_path = tmp_dir.path().join("char-device.tmp"); +@@ -204,7 +204,7 @@ mod test { + #[test] + #[cfg(unix)] // Sockets don't work the same way on Windows + fn test_socket_type() { +- let tmp_dir = TempDir::new("test_socket_type").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the socket; + let socket_path = tmp_dir.path().join("socket.tmp"); +diff --git a/src/meta/name.rs b/src/meta/name.rs +index 36dfb19..7c784f4 100644 +--- a/src/meta/name.rs ++++ b/src/meta/name.rs +@@ -112,12 +112,12 @@ mod test { + use std::path::Path; + #[cfg(unix)] + use std::process::Command; +- use tempdir::TempDir; ++ use tempfile::tempdir; + + #[test] + #[cfg(unix)] // Windows uses different default permissions + fn test_print_file_name() { +- let tmp_dir = TempDir::new("test_print_file_name").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let icons = Icons::new(icon::Theme::Fancy); + + // Create the file; +@@ -137,7 +137,7 @@ mod test { + + #[test] + fn test_print_dir_name() { +- let tmp_dir = TempDir::new("test_print_dir_name").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let icons = Icons::new(icon::Theme::Fancy); + + // Chreate the directory +@@ -156,7 +156,7 @@ mod test { + #[test] + #[cfg(unix)] // Symlinks are hard on Windows + fn test_print_symlink_name() { +- let tmp_dir = TempDir::new("test_symlink_name").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let icons = Icons::new(icon::Theme::Fancy); + + // Create the file; +@@ -183,7 +183,7 @@ mod test { + #[test] + #[cfg(unix)] + fn test_print_other_type_name() { +- let tmp_dir = TempDir::new("test_other_type_name").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let icons = Icons::new(icon::Theme::Fancy); + + // Create the pipe; +@@ -208,8 +208,7 @@ mod test { + + #[test] + fn test_print_without_icon_or_color() { +- let tmp_dir = +- TempDir::new("test_print_without_icon_or_color").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + let icons = Icons::new(icon::Theme::NoIcon); + + // Create the file; +diff --git a/src/sort.rs b/src/sort.rs +index c1fe81b..b6a8c36 100644 +--- a/src/sort.rs ++++ b/src/sort.rs +@@ -91,11 +91,11 @@ mod tests { + use crate::flags::Flags; + use std::fs::{create_dir, File}; + use std::process::Command; +- use tempdir::TempDir; ++ use tempfile::tempdir; + + #[test] + fn test_sort_by_meta_by_name_with_dirs_first() { +- let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let path_a = tmp_dir.path().join("zzz"); +@@ -120,7 +120,7 @@ mod tests { + + #[test] + fn test_sort_by_meta_by_name_with_files_first() { +- let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let path_a = tmp_dir.path().join("zzz"); +@@ -144,7 +144,7 @@ mod tests { + + #[test] + fn test_sort_by_meta_by_name_unordered() { +- let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let path_a = tmp_dir.path().join("aaa"); +@@ -169,7 +169,7 @@ mod tests { + + #[test] + fn test_sort_by_meta_by_name_unordered_2() { +- let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let path_a = tmp_dir.path().join("zzz"); +@@ -194,7 +194,7 @@ mod tests { + + #[test] + fn test_sort_by_meta_by_time() { +- let tmp_dir = TempDir::new("test_dir").expect("failed to create temp dir"); ++ let tmp_dir = tempdir().expect("failed to create temp dir"); + + // Create the file; + let path_a = tmp_dir.path().join("aaa"); +-- +2.22.0.rc3 + diff --git a/lsd-fix-metadata.diff b/lsd-fix-metadata.diff index 8e5888a..1853323 100644 --- a/lsd-fix-metadata.diff +++ b/lsd-fix-metadata.diff @@ -1,5 +1,16 @@ ---- lsd-0.15.1/Cargo.toml 1970-01-01T00:00:00+00:00 -+++ lsd-0.15.1/Cargo.toml 2019-05-30T15:04:56.517283+00:00 +--- lsd-0.15.1/Cargo.toml 1970-01-01T00:00:00+00:00 ++++ lsd-0.15.1/Cargo.toml 2019-06-09T19:55:03.190034+00:00 +@@ -56,8 +56,8 @@ + + [dependencies.wild] + version = "2.0.1" +-[dev-dependencies.tempdir] +-version = "0.3.7" ++[dev-dependencies.tempfile] ++version = "3" + [build-dependencies.clap] + version = "2.32.0" + @@ -68,6 +68,3 @@ sudo = [] [target."cfg(unix)".dependencies.users] diff --git a/rust-lsd.spec b/rust-lsd.spec index d2f02d1..951af2e 100644 --- a/rust-lsd.spec +++ b/rust-lsd.spec @@ -6,7 +6,7 @@ Name: rust-%{crate} Version: 0.15.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: ls command with a lot of pretty colors and some other stuff # Upstream license specification: Apache-2.0 @@ -15,7 +15,10 @@ URL: https://crates.io/crates/lsd Source: %{crates_source} # Initial patched metadata # - Remove Windows only dependencies +# - Switch to tempfile, https://github.com/Peltoche/lsd/pull/233 Patch0: lsd-fix-metadata.diff +# Finish switch to tempfile +Patch0001: 0001-chore-Switch-from-tempdir-to-tempfile.patch ExclusiveArch: %{rust_arches} @@ -36,7 +39,7 @@ BuildRequires: (crate(users/default) >= 0.9.0 with crate(users/default) < 0.10. BuildRequires: (crate(version_check/default) >= 0.1.3 with crate(version_check/default) < 0.2.0) BuildRequires: (crate(wild/default) >= 2.0.1 with crate(wild/default) < 3.0.0) %if %{with check} -BuildRequires: (crate(tempdir/default) >= 0.3.7 with crate(tempdir/default) < 0.4.0) +BuildRequires: (crate(tempfile/default) >= 3.0.0 with crate(tempfile/default) < 4.0.0) %endif %global _description %{expand: @@ -70,6 +73,9 @@ Summary: %{summary} %endif %changelog +* Sun Jun 09 21:55:03 CEST 2019 Igor Gnatenko - 0.15.1-3 +- Switch to tempfile + * Sun Jun 09 19:54:30 CEST 2019 Igor Gnatenko - 0.15.1-2 - Regenerate